views:

32

answers:

1

I'm using ANT to build the WAR file for my Java web app. However, when I look inside the WAR file I see every file appear twice (not the folders, just the files). When I extract the WAR file there are no errors and the file structure appears to be correct, no double files. If I then compess the extracted file back into a ZIP file the archive is almost exactly half the size in bytes of the original WAR file created by ANT.

I'm using the following task to create my WAR file:

<target name="dist" depends="package">          
    <war destfile="${bin.dir}/webapp.war" basedir="${tmp.dir}">
        <fileset dir="${tmp.dir}" />
    </war>
</target>

When I inspect the file structure in the tmp.dir the files seem to appear OK. I'm running ANT from within Eclipse (Helios) on Ubuntu 9.10.

A: 

I found out what caused the problem. The <fileset> tag inside the <war> task is somehow causing the files to be added to the archive twice. It would be good if ANT would throw up an error but it didn't. Since I want to add the entire tmp.dir to my archive, I should have used to following:

<target name="dist" depends="package">          
    <war destfile="${bin.dir}/webapp.war" basedir="${tmp.dir}">
        <!-- No extra <fileset> -->
    </war>
</target>

In case someone else comes across this problem, I leave this question here rather than deleting it.

Luke