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>
@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:
Setting needxmlfile to “true” causes Ant to complain if no web.xml file can be found during “waring”.