如何使用包含某些文件的ant构建创建EAR文件?

use*_*100 11 java ant ear oc4j java-ee

我正在使用eclipse使用ant构建一个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>

将此添加到耳朵的正确方法是什么?

Chs*_*y76 22

Ant 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>
Run Code Online (Sandbox Code Playgroud)

  • 运行良好,虽然我收到一个恼人的警告:"选定的ear文件包含一个META-INF/application.xml,它将被忽略(请使用appxml属性进行ear任务)" (3认同)

sas*_*sah 8

试试这段代码:

    <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>
Run Code Online (Sandbox Code Playgroud)


小智 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>
Run Code Online (Sandbox Code Playgroud)