Showing posts with label Ant weblogic sample. Show all posts
Showing posts with label Ant weblogic sample. Show all posts

Wednesday, July 17, 2013

ANT Weblogic WebApp Sample File

This article contains the Weblogic Web Application Ant Sample deployment script.

Very useful for configuration and deployment.

<project name="AppBuilder" default="deploy" basedir="."> 
        <property file="build.properties"/> 
<!-- 
Tasks to be done 
1. clean 
2. init 
3. compile 
4. copy 
5. war 
 --> 
        <path id="classpath"> 
                <!--<fileset dir="${lib.dir}" includes="*.jar"/>--> 
                <fileset dir="common" includes="*.jar"/> 
        </path> 

        <target name="clean"> 
                <echo>Cleaning the ${build.dir} and ${dist.dir}</echo> 
                <delete dir="${build.dir}"/> 
                <delete dir="${dist.dir}"/> 
        </target> 
        <target name="init" depends="clean"> 
                <echo>Creating the required directories</echo> 
                <mkdir dir="${dist.dir}"/> 
                <mkdir dir="${build.dir}\WEB-INF\classes"/>                 
                <mkdir dir="${build.dir}\WEB-INF\lib"/> 
        </target> 

        <target name="compile" depends="init"> 
                <echo>Compile the source files</echo> 
                <javac srcdir="${src.dir}" destdir="${build.dir}\WEB-INF\classes"> 
                        <classpath refid="classpath"/> 
                </javac> 
        </target>         
        
        <target name="copy" depends="compile"> 
                <copy todir="${build.dir}"> 
                        <fileset dir="${web.content}"/> 
                </copy> 
                <copy todir="${build.dir}/WEB-INF/classes"> 
                        <fileset dir="${src.dir}" includes="**/*.properties, **/*.xml, **/*.wsdl"/> 
                </copy> 
        </target>                 

        <target name="war" depends="copy"> 
                <echo>Building the war file</echo> 
                <war destfile="${dist.dir}\${project.name}.war" webxml="${build.dir}\WEB-INF\web.xml"> 
                        <fileset dir="${build.dir}"/> 
                </war> 
        </target> 

        <taskdef name="wldeploy" classname="weblogic.ant.taskdefs.management.WLDeploy"> 
          <classpath> 
          <pathelement location="common/weblogic.jar"/> 
          </classpath> 
        </taskdef> 

        <target name="deploy"> 
           <wldeploy action="deploy" 
                  source="dist/SMDBWebservice.war" name="SMDBWebservice" 
                  user="weblogic" password="weblogic" verbose="true" adminurl="t3://localhost:7001" 
                  debug="true" targets="AdminServer"/> 
        </target> 

        <target name="undeploy"> 
           <wldeploy action="undeploy" name="SMDBWebservice" 
                  user="weblogic" password="weblogic" verbose="true" adminurl="t3://localhost:7001" 
                  debug="true" targets="AdminServer"/> 
        </target> 

        <target name="redeploy"> 
           <wldeploy action="redeploy" 
                  source="dist/SMDBWebservice.war" name="SMDBWebservice" 
                  user="weblogic" password="weblogic" verbose="true" 
                  adminurl="t3://localhost:7001" 
                  debug="true" targets="AdminServer"> 
                 <!--<files file="index.jsp"/>--> 
           </wldeploy> 
        </target> 

        <taskdef name="wlconfig" classname="weblogic.ant.taskdefs.management.WLConfig"> 
          <classpath> 
          <pathelement location="common/weblogic.jar"/> 
          </classpath> 
        </taskdef> 

        <taskdef name="wlserver" classname="weblogic.ant.taskdefs.management.WLServer"> 
          <classpath> 
          <pathelement location="common/weblogic.jar"/> 
          <pathelement location="common/ant-weblogic.jar"/> 
          </classpath> 
        </taskdef> 

<target name="JDBCPool"> 
                <wlconfig url="t3://localhost:7001" username="weblogic" password="weblogic"> 
                        
                        <query domain="base_domain" type="Server" name="AdminServer"  property="server"/> 
                <create type="JDBCConnectionPool" 
                         name="CMSPool"       
                         property="cmspool">       
                         <set attribute="CapacityIncrement" value="1"/>       
                         <set attribute="DriverName"         
                                         value="com.ibm.db2.jcc.DB2Driver"/>       
                         <set attribute="InitialCapacity" value="1"/>       
                         <set attribute="MaxCapacity" value="10"/>       
                         <set attribute="Password" value="smdbuat"/>       
                         <set attribute="Properties" value="user=dsmdd1d;SecurityMechanism=EncryptedUIDPassword;databaseName=DPSMSSMD;serverName=160.254.49.155;batchPerformanceWorkaround=true;portNumber=3600;"/>       
                         <set attribute="RefreshMinutes" value="0"/>       
                         <set attribute="ShrinkPeriodMinutes" value="15"/>       
                         <set attribute="ShrinkingEnabled" value="true"/>       
                         <set attribute="TestConnectionsOnRelease" value="false"/>       
                         <set attribute="TestConnectionsOnReserve" value="false"/>       
                         <set attribute="URL" value="jdbc:db2://160.254.49.155:3600/DPSMSSMD"/>       
                         <set attribute="Targets" value="${server}"/>   
                 </create> 

                 <create type="JDBCTxDataSource" name="CMSDataSource"> 
                        <set attribute="JNDIName" value="JDBCIBM2"/> 
                        <set attribute="PoolName" value="CMSPool"/> 
                        <set attribute="Targets" value="${server}"/> 
                 </create> 
        </wlconfig> 
</target> 

</project>