I'm using eclipse to build an ear file using ant. I'm using oc4j, and I want to make sure that orion-application.xml is included in the build. What I'm currently using but does not work is:
<target name="ear" depends=""> <echo>Building the ear file</echo> <copy todir="${build.dir}/META-INF"> <fileset dir="${conf.dir}" includes="orion-application.xml"/> </copy> <ear destfile="${dist.dir}/${ant.project.name}.ear" appxml="${conf.dir}/application.xml"> <fileset dir="${dist.dir}" includes="*.jar,*.war"/> </ear> </target>
What is the right way to add this to the ear?
An EAR file (see Figure 1-6) contains Java EE modules and, optionally, deployment descriptors. A deployment descriptor, an XML document with an . xml extension, describes the deployment settings of an application, a module, or a component.
First, build a war using this;
http://ant.apache.org/manual/Tasks/war.html
than an EAR in the same Ant task.
http://ant.apache.org/manual/Tasks/ear.html
Put this in your java project directory structure:
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="test_ear" name="myProject">
<property name="build.dir" value="WebContent"/>
<target name="test_ear">
<war destfile="C:/projects/test1.war" needxmlfile='false'>
<fileset dir="${build.dir}" excludes="*build*.xml"/>
</war>
<ear destfile="C:/projects/test1EAR.ear" appxml="WebContent/META-INF/application.xml">
<fileset dir="C:/projects/" includes="*.jar,*.war"/>
</ear>
</target>
</project>
Try this code:
<ear destfile="deploy/iapp.ear"
appxml="workspace/appEAR/EarContent/META-INF/application.xml">
<fileset file="workspace/appEJB/appEJB.jar" />
<fileset file="workspace/appWAR/appWAR.war" />
<zipfileset file="workspace/appLIB/appLIB.jar"
prefix="APP-INF/lib" />
<zipfileset dir="lib/fop" includes="*.jar" prefix="APP-INF/lib" />
<zipfileset dir="lib/poi" includes="*.jar" prefix="APP-INF/lib" />
<zipfileset dir="lib/gxt" includes="*.jar" prefix="APP-INF/lib" />
<metainf dir="workspace/appEAR/EarContent/META-INF">
<exclude name="**/application.xml" />
<exclude name="**/MANIFEST.MF" />
</metainf>
<manifest>
<attribute name="Weblogic-Application-Version"
value="${deploy.revision}" />
</manifest>
</ear>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With