You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Shoop, Michael R." <Mi...@jhuapl.edu> on 2004/10/08 15:07:36 UTC

Ant not accepting arguments

Hi,

I'm fairly new with ant and am having a problem with command line arguments.

For practice I have the following build.xml file:

<project name="TEST_PROJ" default="testing" basedir=".">
        <property name="test.dir" value="c:/temp"/>
	<target name="test1" unless="${testType}">
		<echo message="Doing test1"/>
	</target>
	<target name="test2" if="${testType}">
		<echo message="Doing test2"/>
	</target>
	<target name="testing" depends="test1, test2"/>
</project>

And I call it from the command line with
 ant -DtestType=true 

I should expect that target "test2" would execute and echo the "Doing test2"
message.  However, it executes target test1 and skips target test2.  I've
tried calling without the argument and still just target test1 executes.

I've tried running with the -debug option and the feedback from running:

   C:\Temp\antbuild>ant -DtestType=true -debug
  Apache Ant version 1.6.2 compiled on July 16 2004  
  Buildfile: build.xml
  Adding reference: ant.PropertyHelper
  Detected Java version: 1.4 in: c:\j2sdk1.4.2_04\jre
  Detected OS: Windows XP
  Adding reference: ant.ComponentHelper
  Setting ro project property: ant.version -> Apache Ant version 1.6.2
compiled on
    July 16 2004
  Setting ro project property: testType -> true
  Setting ro project property: ant.file -> C:\Temp\antbuild\build.xml
  Adding reference: ant.projectHelper
  Adding reference: ant.parsing.context
  Adding reference: ant.targets
    parsing buildfile C:\Temp\antbuild\build.xml with URI =
file:///C:/Temp/antbuild <file:///C:/Temp/antbuild> 
    /build.xml
  Setting ro project property: ant.project.name -> TEST_PROJ
  Adding reference: TEST_PROJ
  Setting ro project property: ant.file.TEST_PROJ ->
C:\Temp\antbuild\build.xml
  Project base dir set to: C:\Temp\antbuild
    +Target:
   +Target: test1
   +Target: test2
   +Target: testing
  Setting project property: test.dir -> c:/temp
  Build sequence for target `testing' is [test1, test2, testing]
  Complete build sequence is [test1, test2, testing, ]

  test1:
       [echo] Doing test1
 
  test2:
   Skipped because property 'true' not set.

   testing:

BUILD SUCCESSFUL

I've also tried using a properties file  <ant -propertyfile test.properties
> and get similar results.  The properties file has one entry:
testType=true

I've tried this both on a Windows platform (WinXP) and Unix Solaris machine
with the same versions of ant (1.6.x)

I'm baffled.

Thanks for any help,

Mike