如何创建一个Ant构建包括某些文件的EAR文件?
题
我使用Eclipse来构建使用蚂蚁EAR文件。我使用的是OC4J,我想确保的orion-application.xml中包含在构建中。我目前使用但不工作是什么:
<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>
什么是把它添加到耳朵的正确方法?
解决方案
这应该进入META-INF
文件夹的所有内容都应经由嵌套<metainf>
文件集来指定:
<ear destfile="${dist.dir}/${ant.project.name}.ear"
appxml="${conf.dir}/application.xml">
<metainf dir="${build.dir/META-INF}"/>
<fileset dir="${dist.dir}" includes="*.jar,*.war"/>
</ear>
其他提示
试试这个代码:
<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>
首先,使用该建一个战;
http://ant.apache.org/manual/Tasks/war.html 结果
比在相同Ant任务的EAR。结果
http://ant.apache.org/manual/Tasks/ear.html
在你的Java项目的目录结构将这个:
<?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>
不隶属于 StackOverflow