RSS

Deploy ear file in to App.server using ANT

05 Mar

Hi folks,

Here is the post to generate ear file and deploy in to the application server using the ant build.xml file.

Below is the build.xml file which will create war and ear file and deploy in to application server.

<project name=”sampledemo” basedir=”.” default=”deploy”>
<property name=”build” value=”./bin” />
<property name=”src” value=”./src” />
<property name=”version” value=”0.1″ />
<property name=”deployDir” value=”${harcode path here where should it deploy}” />
<property name=”warFile” value=”${dist}/${ant.project.name}.war” />
<property name=”earFile” value=”${dist}/${ant.project.name}-${version}.ear” />

<target name=”clean”>
<echo>********* deleting directories *********</echo>
<delete dir=”${build}” />
<delete dir=”${dist}” />
</target>

<target name=”init”>
<echo>********* creating directories *********</echo>
<tstamp />
<mkdir dir=”${build}” />
<mkdir dir=”${dist}” />
<mkdir dir=”${web}” />
</target>

<target name=”compile” depends=”init”>
<echo>********* compiling the java source code *********</echo>
<javac srcdir=”${src}” destdir=”${build}” optimize=”on”>
<classpath refid=”build.classpath” />
</javac>
</target>

<target name=”war” depends=”compile” >
<echo>********* generating war file ${ant.project.name}.war *********</echo>
<war destfile=”${dist}/${ant.project.name}.war” webxml=””>
<classes dir=”${build}”/>
<zipfileset dir=”${web}” />
</war>
</target>

<target name=”ear” depends=”war”>
<echo>********* generating ear file ${ant.project.name}-${version}.ear *********</echo>
<ear destfile=”${dist}/${ant.project.name}-${version}.ear” appxml=””>
<fileset dir=”${dist}” includes=”*.war” />
</ear>
</target>

<target name=”deploy” depends=”ear”>
<echo>********* deploying ear file to ${deployDir} *********</echo>
<copy todir=”${deployDir}”>
<fileset dir=”${dist}” includes=”*.ear” />
</copy>
</target>
</project>

Hope this will save your time for some extent.

Use below URL to get more information about build.xml file.

http://penguindreams.org/blog/building-java-ear-files-using-ant/

Sample build.xml

Happy Coding!.

Stay tuned for more updates.

Have a nice day:-)

Advertisements
 
1 Comment

Posted by on March 5, 2013 in Uncategorized

 

One response to “Deploy ear file in to App.server using ANT

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: