Making test-enabled WAR with Ant
medloh Jun 18, 2009 12:24 PMI tried using the org.jboss.jsfunit.ant.JSFUnitWarTask to make a JSFUnit-enabled WAR file. It worked, but I ran into a couple problems with it that made me switch to doing it myself:
1) Its very very slow. Takes 2+ minutes to make the war. Not sure what its doing, but whatever it is takes forever. Doing the same thing myself takes about 10 seconds. Why is it so slow?
2) It leaves a copy of the war files in my /tmp dir. I only noticed this after I ran out of diskspace on my tmp disk.
Here's my ant tasks that do the same thing (AFAIK )much faster without leaving garbage behind:
<javac debug="on" srcdir="${test.src.dir}" destdir="${test.classes.dir}" classpath="${debug.classpath}:${libs.JSFUnit.classpath}:${libs.junit_4.classpath}:${j2ee.platform.classpath}"> </javac> <!-- Copy all the test stuff over to build classes. --> <copy todir="${build.classes.dir}"> <fileset dir="${test.classes.dir}"/> </copy> <tstamp> <format property="jsfunit-war.start.ts" pattern="HH:mm:ss" /> </tstamp> <echo message="Starting to make JSFUnit War at ${jsfunit-war.start.ts}"/> <!-- copy test libs to the lib dir in build dir --> <copy todir="${build.lib.dir}"> <fileset dir="${test.lib.dir}/jsfunit"> <include name="**/*.jar"/> </fileset> <fileset dir="${test.lib.dir}/junit_4"> <include name="**/*.jar"></include> </fileset> </copy> <!-- Edit the web.xml in the build dir to include the defs for the JSFUnit test servlet --> <echo message="Filtering"/> <filter token="JSFUnit-servlet-tags-start" value="JSFUnit servlet tags start -->"/> <filter token="JSFUnit-servlet-tags-end" value="<!-- JSFUnit servlet tags end"/> <touch file="${build.webinf.dir}/web.xml"/> <copy file="${build.webinf.dir}/web.xml" tofile="${build.webinf.dir}/test-web.xml" filtering="true"/> <move file="${build.webinf.dir}/web.xml" tofile="${build.webinf.dir}/notest-web.xml"/> <move file="${build.webinf.dir}/test-web.xml" tofile="${build.webinf.dir}/web.xml"/> <echo message="Done Filtering"/> <!-- make the war from the build dir, which now contains all the files needed for testing. --> <jar compress="${jar.compress}" jarfile="${dist.dir}/jsfunit-${war.name}"> <fileset dir="${build.web.dir}"/> </jar> <tstamp> <format property="jsfunit-war.end.ts" pattern="HH:mm:ss" /> </tstamp> <echo message="Finished making JSFUnit War at ${jsfunit-war.end.ts}"/> <move file="${dist.dir}/${war.name}" tofile="${dist.dir}/notests-${war.name}"/> <move file="${dist.dir}/jsfunit-${war.name}" tofile="${dist.dir}/${war.name}"/> <!-- copying to this dir redeploys the app as long as glassfish is configured to autodeploy. --> <copy file="${dist.dir}/${war.name}" todir="${glassfish.autodeploy.dir}" />