Main Page

Saturday, 27 October 2012

Ant Script deployment in weblogic 10.3

Step 1:Create build.xml file


<project name="testapp" default="deploy">
<property name="wls.username" value="weblogic"/>
<property name="wls.password" value="weblogic"/>
<property name="wls.hostname" value="localhost"/>
<property name="wls.port" value="7001"/>
<property name="admin.server.name" value="AdminServer"/>
<property name="deploy.targets" value="ms1,ms2"/>
<property name="deploy.name1" value="jsf"/>
<property name="deploy.name2" value="jstl"/>
<property name="deploy.name3" value="bstr"/>
<property name="deploy.name4" value="medrec"/>
<property name="deploy.name5" value="physician"/>
<property name="deploy.source.jsf" value="C:\bea\wlserver_10.3\common\deployable-libraries\jsf-1.2.war"/>
<property name="deploy.source.jstl" value="C:\bea\wlserver_10.3\common\deployable-libraries\jstl-1.2.war"/>
<property name="deploy.source.browserstarter" value="C:\bea\wlserver_10.3\samples\server\medrec\modules\browser-starter\target\browser-starter.war"/>
<property name="deploy.source.medrec" value="C:\bea\wlserver_10.3\samples\server\medrec\modules\medrec\assembly\target\medrec.ear"/>
<property name="deploy.source.physician" value="C:\bea\wlserver_10.3\samples\server\medrec\modules\physician\assembly\target\physician.ear"/>
<taskdef name="wldeploy" classname="weblogic.ant.taskdefs.management.WLDeploy">
<classpath>
<pathelement location="C:\bea\wlserver_10.3\server\lib\weblogic.jar"/>
</classpath>
</taskdef>
<target name="deploy">

<wldeploy action="deploy"
        name="${deploy.name1}"
        source="${deploy.source.jsf}"
        user="${wls.username}"
       nostage="true"
        password="${wls.password}"
        verbose="true"
        library="true"
        adminurl="t3://${wls.hostname}:${wls.port}"
        targets="${deploy.targets}"/>
<wldeploy action="deploy"
        name="${deploy.name2}"
        source="${deploy.source.jstl}"
        user="${wls.username}"
       nostage="true"
        password="${wls.password}"
        verbose="true"
        library="true"
        adminurl="t3://${wls.hostname}:${wls.port}"
        targets="${deploy.targets}"/>

<wldeploy action="deploy"
        name="${deploy.name4}"
        source="${deploy.source.medrec}"
        user="${wls.username}"
       nostage="true"
        password="${wls.password}"
        verbose="true"
        library="false"
        adminurl="t3://${wls.hostname}:${wls.port}"
        targets="${deploy.targets}"/>

<wldeploy action="deploy"
        name="${deploy.name5}"
        source="${deploy.source.physician}"
        user="${wls.username}"
       nostage="true"
        password="${wls.password}"
        verbose="true"
        library="false"
        adminurl="t3://${wls.hostname}:${wls.port}"
        targets="${deploy.targets}"/>

<wldeploy action="deploy"
        name="${deploy.name3}"
        source="${deploy.source.browserstarter}"
        user="${wls.username}"
       nostage="true"
        password="${wls.password}"
        verbose="true"
        library="false"
        adminurl="t3://${wls.hostname}:${wls.port}"
        targets="${deploy.targets}"/>
 </target>
<target name="undeploy">
<wldeploy action="undeploy"
        name="${deploy.name5}"
        failonerror="false"
         user="${wls.username}"
         password="${wls.password}"
         verbose="true"
         adminurl="t3://${wls.hostname}:${wls.port}"
targets="${deploy.targets}"/>
<wldeploy action="undeploy"
        name="${deploy.name4}"
        failonerror="false"
        user="${wls.username}"
        password="${wls.password}"
        verbose="true"
        adminurl="t3://${wls.hostname}:${wls.port}"
        targets="${deploy.targets}"/>
<wldeploy action="undeploy"
        name="${deploy.name3}"
        failonerror="false"
        user="${wls.username}"
       password="${wls.password}"
       verbose="true"
       adminurl="t3://${wls.hostname}:${wls.port}"
       targets="${deploy.targets}"/>
<wldeploy action="undeploy"
        name="${deploy.name2}"
        failonerror="false"
        user="${wls.username}"
        password="${wls.password}"
        verbose="true"
        adminurl="t3://${wls.hostname}:${wls.port}"
      targets="${deploy.targets}"/>
<wldeploy action="undeploy"
        name="${deploy.name1}"
        failonerror="false"
        user="${wls.username}"
        password="${wls.password}"
        verbose="true"
       adminurl="t3://${wls.hostname}:${wls.port}"
       targets="${deploy.targets}"/>
</target>
</project>

Step 2: Set the classpath
 Execute setDomainEnv.sh script.

Step3: Execute the below command for deployment

ant -f build.xml deploy

Step4: Execute the below command for undeploying the application

ant -f build.xml undeploy



No comments:

Post a Comment