Monday, September 30, 2013

quick hit: minimal war building with ant

Sometimes I want a .war file but just with a few static files. While I have been known to use the hack of "zip the folder, rename it .war", that really requires a few extra files be inserted by hand into the folder (like META-INF etc) to do properly. Since I have ant on my system, I should use that.

If I have a folder of files, I just add this build.xml, and then typing ant makes me my "mything" war...

<project name="mything" default="build">
        <target name="build">
                <delete file="mything.war"/>

                <war destfile="mything.war" needxmlfile="false">
                        <fileset dir=".">
                                <exclude name="build.xml"/>
                                <exclude name="mything.war"/>
                        </fileset>
                </war>
        </target>
</project>

That's about as simple as it can get and still be doing the right thing, I think.

No comments:

Post a Comment