【发布时间】:2009-08-12 16:36:23
【问题描述】:
我正在使用 eclipse 使用 ant 构建一个 ear 文件。我正在使用 oc4j,我想确保构建中包含 orion-application.xml。我目前正在使用但不起作用的是:
构建ear文件 复制> 目标>
将它添加到耳朵的正确方法是什么?
【问题讨论】:
标签: java ant jakarta-ee oc4j ear
我正在使用 eclipse 使用 ant 构建一个 ear 文件。我正在使用 oc4j,我想确保构建中包含 orion-application.xml。我目前正在使用但不起作用的是:
构建ear文件 复制> 目标>
将它添加到耳朵的正确方法是什么?
【问题讨论】:
标签: java ant jakarta-ee oc4j ear
应该进入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>
【讨论】: