ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tankertux <>
Subject Overriding a Target programmatically - task not being executed
Date Fri, 09 May 2008 15:57:27 GMT

I am trying to write unit tests for my build.  Part of the build that I am
testing would create a war, but I do not want a war to be created every time
I run the tests.  However, I do want to see that the target to build the war
was executed.

I am using jUnit to run the ant tasks and am trying to override the target
that will create a war, replacing it with a simple property task that I can
test against.  

The target I am testing looks like:

      <target name="determineDeployOrigin" >
			<equals arg1="${buildWar}" arg2="yes" />
				<antcall target="createWar" />
				<property name="deploy.origin" value="${deploy.dir}/${deploy.warname}"
				<property name="deploy.origin" value="${deploy.webcontent}" />

I am testing this logic in Junit, simply by asserting that "deploy.origin"
and "executed.properly" are what I expect after overriding createWar:

   public void determineWarDeployOrigin(){

      Target createWar = new Target();
      Property createWarTestProperty = new Property();

      if(project.getTargets().get("createWar") == null){
         fail("createWar target not found in web-deploy.xml");
      project.addOrReplaceTarget("createWar", createWar);

      project.setProperty("buildWar", "yes");


The problem is that "executed.properly" is always null, unless I explicitly
call execute() on createWarTestProperty task.  Is there something that I am
doing wrong in creating the createWar target?
Any suggestions are appreciated...
View this message in context:
Sent from the Ant - Users mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message