Reputation: 20136
At build time, I am updating some variables that are stored in the web.xml file using variables in a properties file, Is there a way to simplify what I am doing here:
<target name="war-test" depends="compile">
<mkdir dir="${dist}"/>
<mkdir dir="${dist}/tmp"/>
<copy file="WebContent/WEB-INF/web.xml.templ" tofile="${dist}/tmp/web.xml">
<filterchain>
<replacetokens>
<token key="smtp.hostname" value="${test.smtp.hostname}"/>
<token key="smtp.port" value="${test.smtp.port}"/>
</replacetokens>
</filterchain>
</copy>
<war destfile="${dist}/mywarfile-test.war" webxml="${dist}/tmp/web.xml">
<fileset dir="WebContent">
<exclude name="META-INF/**"/>
<exclude name="META-INF"/>
<exclude name="WEB-INF/**"/>
<exclude name="WEB-INF"/>
</fileset>
<lib dir="lib">
<exclude name="somelibrary.jar"/>
</lib>
<classes dir="${build}"/>
</war>
<delete dir="${dist}/tmp"/>
<antcall target="clean"/>
</target>
Do I need to make the tmp directory?
Upvotes: 3
Views: 2912
Reputation: 945
You need to put the web.xml in a temporary location if you do not want to copy it directly to WebContent/WEB-INF and remove the exclude for that folder. There is no subelement for <war> that lets you create it on the fly, as there is for the manifest.
As oers says there seems to be something strange, typo or similar. You create "${dist}/metainf/web.xml but include "${dist}/tmp/web.xml.
If you want less lines you can replace the filter chain with:
<filterset>
<filter token="smtp.hostname" value="${test.smtp.hostname}" />
<filter token="smtp.port" value="${test.smtp.port}" />
</filterset>
Upvotes: 1