I am newbie to ANT and trying a simple ANT script to create .war file of my project.
Here is my script
When I run this script everything works fine but .jar file present in WebContent/WEB-INF/lib are copied twice inside the .war file.
<?xml version="1.0" ?>
<project name="AutoComplete">
<path id="compile.classpath">
<fileset dir="WebContent/WEB-INF/lib">
<include name="*.jar"/>
</fileset>
</path>
<target name="init">
<mkdir dir="build/classes"/>
</target>
<target name="compile" depends="init" >
<javac includeantruntime="false" destdir="build/classes" debug="true" srcdir="src" >
<classpath refid="compile.classpath"/>
</javac>
</target>
<target name="build.war" depends="compile">
<war destfile="AutoComplete.war" webxml="WebContent/WEB-INF/web.xml">
<fileset dir="WebContent"/>
<lib dir="WebContent/WEB-INF/lib"/>
<classes dir="build/classes"/>
</war>
</target>
<target name="clean">
<delete dir="build" />
</target>
</project>
Please let me know if I am making any blunder.
Thanks.
Your
build.wartask looks to be the culprit:The first nested
<fileset>pulls in all the files fromWebContentto the root of the WAR. The second line then explicitly says that everything inWebContent/WEB-INF/libshould be considered a library (and thus copied toWEB-INF/libinside the WAR).Deleting one of these lines should mean that the libs get copied once – if you do want everything inside WebContent to be copied as-is within the WAR, you can just delete the
<lib>line.