Reputation: 27286
I have the following war task in my build.xml and even though needxmlfile is set to false, Ant (version 1.8.2) complains when the web.xml file does not exist ("BUILD FAILED ... Deployment descriptor: /home/.../web/WEB-INF/web.xml does not exist")
What am I missing?
<target name="war" depends="build">
<mkdir dir="${build.dir}"/>
<war
needxmlfile="false"
basedir="${webroot.dir}"
warfile="${build.dir}/${project.distname}.war"
webxml="${webinf.dir}/web.xml">
<exclude name="WEB-INF/${build.dir}/**"/>
<exclude name="WEB-INF/src/**"/>
<exclude name="WEB-INF/web.xml"/>
</war>
</target>
Upvotes: 1
Views: 6664
Reputation: 27286
@O'Connor: thanks for the hint for using a fileset to pull the web.xml. However I am not sure you are correct about the needxmlfile set to true (at least in my experimentation I witnessed the opposite of what you describe). In any case, in the end I realized that not even the fileset is necessary since the war Ant task apparently packages everything under the basedir (unless explicitly excluded) so I am now using the following war task that works whether a web.xml file is present or not:
<target name="war" depends="build">
<mkdir dir="${build.dir}"/>
<war
needxmlfile="false"
basedir="${webroot.dir}"
destfile="${build.dir}/${project.distname}.war">
<exclude name="WEB-INF/${build.dir}/**"/>
<exclude name="WEB-INF/src/**"/>
</war>
</target>
Setting needxmlfile to "true" causes Ant to complain if no web.xml file can be found during "waring".
Upvotes: 1
Reputation: 77971
The ANT documentation states that the webxml attribute is mandatory unless the needxmlfile attribute is set to true
Try this and use a fileset to pull in the optional web.xml file.
Upvotes: 1