Hi,

Jay SenSharma

Jay SenSharma

Many Times we have the Application ready with us and we frequently want to change it and then again-again repackage it and deploy,redeploy, Undeploy, recompile it…Then it is always easy to use Ant Build script.

Many people doesnt know how to develop a “build.xml” file. But in WebLogic it is very easy to automatically generate the “build.xml” file for all the purpose like redeploy,deploy,undeploy,Appc…etc.

WebLogic provides us a very simple and easy to use utility(?weblogic.BuildXMLGen) to generate the “build.xml” file in  seconds.

Step1). Open a Command Window and then run “setDomainEnv.sh” (Unix) or “setDomainEnv.cmd” (Windows).

Step2). Now move to the directory where your appication exests…

Suppose if i have my “TestAppEAR” in “C:Blog_Reply” directory. Then run the following command.

java weblogic.BuildXMLGen -file build.xml C:Blog_ReplyTestAppEAR

Now yoo will find that in “C:Blog_Reply” a new “build.xml” file is generated…something like following…

<project name="DD_Test" default="help">
<!-- This build file was automatically generated at 5:40:01 PM on Feb 12, 2010 by weblogic.BuildXMLGen -->

<!-- BUILD PROPERTIES ADJUST THESE FOR YOUR ENVIRONMENT -->
<property name="tmp.dir" value="/tmp" />
<property name="dist.dir" value="${tmp.dir}/dist"/>
<property name="app.name" value="DD_Test" />
<property name="ear" value="${dist.dir}/${app.name}.ear"/>
<property name="ear.exploded" value="${dist.dir}/${app.name}_exploded"/>
<property name="verbose" value="true" />
<property name="user" value="USERNAME" />
<property name="password" value="PASSWORD" />
<property name="servername" value="myserver" />
<property name="adminurl" value="iiop://localhost:7001" />

<property name="src.dir" value="C:DELETEBLOG_REPLYEJB3_TimerServiceDD_Test" />
<property name="dest.dir" value="${tmp.dir}/${app.name}" />

<!-- Print's out the project help -->
<target name="help">
<java fork="no" classname="org.apache.tools.ant.Main">
<arg line="-projecthelp"/>
</java>
</target>

<!-- Builds the entire DD_Test application -->
<target name="build" depends="compile, appc" description="Compiles DD_Test application and runs appc" />

<!-- Only compiles DD_Test application, no appc -->
<target name="compile" description="Only compiles DD_Test application, no appc">
<wlcompile srcdir="${src.dir}" destdir="${dest.dir}" />
</target>

<!-- Deletes the dest.dir to clean the build -->
<target name="clean" description="Deletes the build directory">
<delete dir="${dest.dir}" />
</target>

<!-- Runs weblogic.appc on your application -->
<target name="appc" description="Runs weblogic.appc on your application">
<wlappc source="${dest.dir}" verbose="${verbose}" />
</target>

<!-- Builds just MyEJBApp of the application -->
<target name="compile.MyEJBApp" description="Compiles just the MyEJBApp module of the application">
<wlcompile srcdir="${src.dir}" destdir="${dest.dir}"
includes="MyEJBApp" />
</target>

<!-- Builds just MyWebApp of the application -->
<target name="compile.MyWebApp" description="Compiles just the MyWebApp module of the application">
<wlcompile srcdir="${src.dir}" destdir="${dest.dir}"
includes="MyWebApp" />
</target>

<!-- Deploys the entire DD_Test application -->
<target name="deploy" description="Deploys (and redeploys) the entire DD_Test application">
<wldeploy user="${user}" password="${password}" adminurl="${adminurl}"
action="deploy" source="${dest.dir}"
name="${app.name}" />
</target>

<!-- Undeploys the entire DD_Test application -->
<target name="undeploy" description="Undeploys the entire DD_Test application">
<wldeploy user="${user}" password="${password}" adminurl="${adminurl}"
action="undeploy" name="${app.name}" />
</target>

<!-- Redeploys just MyEJBApp of the application -->
<target name="redeploy.MyEJBApp" description="Redeploys just the MyEJBApp module of the application">
<wldeploy user="${user}" password="${password}" adminurl="${adminurl}"
action="redeploy" targets="MyEJBApp@${servername}"
name="${app.name}" />
</target>

<!-- Redeploys just MyWebApp of the application -->
<target name="redeploy.MyWebApp" description="Redeploys just the MyWebApp module of the application">
<wldeploy user="${user}" password="${password}" adminurl="${adminurl}"
action="redeploy" targets="MyWebApp@${servername}"
name="${app.name}" />
</target>

<!-- Package a standard J2EE ear for distribution  -->
<target name="ear" depends="build" description="Package a standard J2EE EAR for distribution">
<mkdir dir="${dist.dir}"/>
<wlpackage srcdir="${src.dir}" destdir="${dest.dir}"
toFile="${ear}" />
</target>

<!-- Package a standard exploded J2EE ear for distribution  -->
<target name="ear.exploded" depends="build" description="Package a standard exploded J2EE EAR">
<mkdir dir="${dist.dir}"/>
<wlpackage srcdir="${src.dir}" destdir="${dest.dir}"
toDir="${ear.exploded}" />
</target>

<!-- Configure WebLogic Server with resources required by application -->
<!-- For example you can configure JDBCConnection Pools and Data Sources, and JMS Destinations etc -->
<target name="config.server" description="Configure server with resources required by application">
<echo message="You will need to customize this based on your application.  Medrec/setup/build.xml has examples..."/>
<!--
<wlconfig url="${adminurl}" username="${user}"
password="${password}">
</wlconfig>
-->
</target>
</project>

.
.
Thanks
Jay SenSharma

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.