I have been adapting this suggested code for making a war file, and have created the following contents of the BuildWar.xml file show in the image above:
<?xml version="1.0" encoding="UTF-8"?>
<project name="myproject" default="default">
<target name="default" depends="setup,compile,buildwar,deploy"></target>
<target name="setup">
<mkdir dir="dist" />
<echo>Copying web into dist</echo>
<copydir dest="dist/web" src="web" />
<copydir dest="dist/web/WEB-INF/lib" src="${basedir}/../web/WEB-INF/lib" />
</target>
<target name="compile">
<delete dir="${dist.dir}/web/WEB-INF/classes" />
<mkdir dir="${dist.dir}/web/WEB-INF/classes" />
<javac destdir="${dist.dir}/web/WEB-INF/classes" srcdir="src">
<classpath>
<fileset dir="${basedir}/myapp/web/WEB-INF/lib">
<include name="*" />
</fileset>
</classpath>
</javac>
<copy todir="${dist.dir}/web/WEB-INF/classes">
<fileset dir="src">
<include name="**/*.properties" />
<include name="**/*.xml" />
</fileset>
</copy>
</target>
<target name="buildwar">
<war basedir="${basedir}/dist/web" destfile="My.war"
webxml="${basedir}/dist/web/WEB-INF/web.xml">
<exclude name="WEB-INF/**" />
<webinf dir="${basedir}/dist/web/WEB-INF/">
<include name="**/*.jar" />
</webinf>
</war>
</target>
<target name="deploy">
<copy file="My.war" todir="${tomcat.deploydir}" />
</target>
</project>
Running the above code as an ant buildfile in eclipse produces some warnings that copydir has been deprecated, and also produces the following error message:
BUILD FAILED
C:\mypath\myapp\BuildWar.xml:10: srcdir C:\mypath\web\WEB-INF\lib does not exist!
However, when I replace the .. in line 10 with myapp, I get an error message saying that
BUILD FAILED
C:\mypath\myapp\BuildWar.xml:10: srcdir C:\mypath\myapp\myapp\web\WEB-INF\lib does not exist!
How do I fix the code so that it no longer gives the BUILD FAILED message?