2009-08-12 33 views
9

我正在使用eclipse构建使用ant的耳朵文件。我正在使用oc4j,并且我想确保构建中包含orion-application.xml。我目前使用但不起作用的是:如何创建包含某些文件的ant版本的EAR文件?

 <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文件夹

回答

20

Ant EAR task

一切都应该通过嵌套<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> 
+1

工作太棒了!我在理解文档方面有点困难。 – user149100 2009-08-12 17:00:46

+2

Ant EAR task => http://ant.apache.org/manual/Tasks/ear.html – 2010-06-04 06:37:40

+2

工作的很好,虽然我得到一个令人讨厌的警告:“选择的耳朵文件包括一个META-INF/application.xml,它将会忽略(请使用appxml属性来完成任务)“ – stian 2011-06-30 13:53:17

5

首先,建立使用经此一战;

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> 
6

试试这个代码:

<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> 
+0

虽然这没有足够的upvotes,但我认为这比'接受'的答案更全面,因为它涵盖了所有变体 - war,jar,appxml,manifest,app-inf/lib和meta-inf。 – 2014-04-21 12:46:34

相关问题