有一个无法编辑的构建过程,需要在生成的耳朵中打包另一场战争。耳朵爆炸,所以只需要将war文件复制到其中,但是application.xml需要更新,所以我想找到一个可以执行此操作的ant任务。有人知道哪一个会起作用吗?
答案 0 :(得分:1)
结束了:
<replace file="${j2ee.build.dir}/${j2ee.app..name}/META-INF/application.xml" token="</application>" value="<module><web><web-uri>admin.war</web-uri><context-root>/admin</context-root></web></module></application>"/>
相当hackish但是无法想出另一种方法来轻松编辑文件
答案 1 :(得分:0)
答案 2 :(得分:0)
想法是创建war并将文件放入ear目录,请参阅以下build.xml代码
<?xml version="1.0"?>
<project name="Add war to ear example" default="all" basedir=".">
<target name="init">
<property name="root.directory" value="${basedir}"/>
<property name="classdir" value="${root.directory}/build/src"/>
<property name="src" value="${root.directory}/src"/>
<property name="web" value="${root.directory}/web"/>
<property name="deploymentdescription" value="${root.directory}/build/deploymentdescriptors"/>
<property name="war.file" value="test.war"/>
<property name="ear.file" value="test.ear"/>
<property name="ear.directory" value="${root.directory}/build/ear"/>
<property name="war.directory" value="${root.directory}/build/war"/>
<!-- Create Web-inf and classes directories -->
<mkdir dir="${war.directory}/WEB-INF"/>
<mkdir dir="${war.directory}/WEB-INF/classes"/>
<!-- Create Meta-inf and classes directories -->
<mkdir dir="${ear.directory}/META-INF"/>
</target>
<!-- Main target -->
<target name="all" depends="init,build,buildWar,buildEar"/>
<!-- Compile Java Files and store in /build/src directory -->
<target name="build" >
<javac srcdir="${src}" destdir="${classdir}" debug="true" includes="**/*.java" />
</target>
<!-- Create the War File -->
<target name="buildWar" depends="init">
<copy todir="${war.directory}/WEB-INF/classes">
<fileset dir="${classdir}" includes="**/*.class" />
</copy>
<copy todir="${war.directory}/WEB-INF">
<fileset dir="${deploymentdescription}" includes="web.xml" />
</copy>
<copy todir="${war.directory}">
<fileset dir="${web}" includes="**/*.*" />
</copy>
<!-- Create war file and place in ear directory -->
<jar jarfile="${ear.directory}/${war.file}" basedir="${war.directory}" />
</target>
<!-- Create the War File -->
<target name="buildEar" depends="init">
<copy todir="${ear.directory}/META-INF">
<fileset dir="${deploymentdescription}" includes="application.xml" />
</copy>
<!-- Create ear file and place in ear directory -->
<jar jarfile="${root.directory}/${ear.file}" basedir="${ear.directory}" />
</target>
</project>