Wednesday January 15, 2003
Conditional Task Execution with Ant I'm trying to conditionally include my test jar files based on an Ant property. My problem is that the "if" attribute of the <task> element only accounts for the property being present or not. I'd love to be able to specify:
ant -Denable.cactus=false
But Ant seemingly executes my task if a property is present - so even though the value is false, it still executes. Any ideas? Here's my task:
<target name="copy-test-jars" depends="init" if="enable.cactus"
description="Copy test-related JAR files to WEB-INF/lib">
<echo>Copying Cactus, StrutsTestCase and JUnit JARs</echo>
<mkdir dir="${webapp.target}/WEB-INF/lib"/>
<!-- Copy jars -->
<copy todir="${webapp.target}/WEB-INF/lib">
<fileset dir="${strutstestcase.dir}" includes="*.jar"/>
<fileset dir="${cactus.dir}">
<include name="*.jar"/>
<exclude name="commons-logging.jar"/>
<exclude name="log4j-*.jar"/>
<exclude name="servlet.jar"/>
</fileset>
<fileset dir="${env.ANT_HOME}/lib" includes="junit.jar"/>
<fileset dir="${env.ANT_HOME}" includes="junit-noframes.xsl"/>
</copy>
</target>
BTW, this XML was made web-savvy by the E2 Source Code Formatter - a must-have bookmark. I got this tip from The FuzzyBlog!. Posted in Java at Jan 15 2003, 11:19:10 AM MST 6 Comments
Search This Site
Recent Entries
- My TSSJS 2010 Presentations and Summary
- What's New in Spring 3.0
- Developing Rich Web Service APIs with Java
- C++, Java and .NET: Lessons Learned from the Internet Age
- Highly Interactive Software with Java and Flex
- The Cloud Computing Continuum with Bob McWhirter
- Software Quality: The Quest for the Holy Grail?
- What's Happening in the Java World?
- Fantastic Fun in Jackson Hole
- How We Hired a Team of 10 in 2 Months
Posted by Danno Ferrin on January 15, 2003 at 03:50 PM MST #
Posted by Erik Hatcher on January 16, 2003 at 06:17 AM MST #
Posted by Matt Raible on January 16, 2003 at 06:34 AM MST #
Posted by Matt Raible on January 16, 2003 at 07:35 AM MST #
Posted by Anonymous on January 17, 2003 at 05:08 AM MST #
Posted by 155.70.39.45 on February 09, 2007 at 06:41 AM MST #