How do I create an EAR file with an ant build including certain files?

雨燕双飞 提交于 2019-11-28 18:02:20
ChssPly76

Ant EAR task

Everything that should go into META-INF folder should be specified via nested <metainf> fileset:

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

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

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>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!