Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-ant-dev] Eclipse v2.1.2 ant problems

Hello,

  I am using v2.1.2 of eclipse.  I have created a new ant task (code below).
This works fine using ant from a command line (the property is changed).
But, under eclipse it does not work; here is the output

command line:

info:
     [echo] *** ant.version       Apache Ant version 1.5.3 compiled on April
16 2003 ...
     [echo] *** ant.java.version  1.3 ...
     [echo] *** java.version      1.3.1_10 ...
     [echo] *** java.home         C:\Apps\Java\j2se\v1.3.1-10\jre ...
     [echo] *** Using user        property file
C:\Home\make\properties\localWin32.properties ...
     [echo] *** Using project     property file
c:/home/make/projectMake.properties ...

dwfa:
     [echo] Property dwfa = dwfa
[modifyProperty] Changing value for property dwfa
     [echo] Property dwfa = ceb

BUILD SUCCESSFUL
Total time: 1 second

eclipse output:

info:
        [echo] *** ant.version       Apache Ant version 1.5.3 compiled on
April 9 2003 ...
        [echo] *** ant.java.version  1.3 ...
        [echo] *** java.version      1.3.1_10 ...
        [echo] *** java.home         C:\Apps\Java\j2se\v1.3.1-10\jre ...
        [echo] *** Using user        property file
c:\home\make\properties\localWin32.properties ...
        [echo] *** Using project     property file
c:/home/make/projectMake.properties ...

dwfa:
        [echo] Property dwfa = dwfa
        [echo] Property dwfa = dwfa
BUILD SUCCESSFUL
Total time: 370 milliseconds

<--------------------->

The task is:

 <target name = "dwfa">
   <property name = "dwfa" value = "dwfa"/>
   <echo>Property dwfa = ${dwfa}</echo>
   <modifyProperty name = "dwfa" value = "ceb"/>
   <echo>Property dwfa = ${dwfa}</echo>
 </target>

My expectation is that it should work the same for both.  Any help would be
appreciated.

Regards,
Douglas WF Acheson

<---------------------------->
package ca.dwfa.ant.tasks ;

import org.apache.tools.ant.BuildException ; import
org.apache.tools.ant.Project ; import org.apache.tools.ant.taskdefs.Property
;

/**
 *
 */
public class ModifyProperty extends Property {
	/**
	 * The entry point
	 */
	public void execute() throws BuildException
	{
		if ((name != null) && (value != null))
		{
			modifyProperty(name, value);
		}
		else
		{
			super.execute();
		}
	} //end method execute
	
	/**
	 * this is how I modify a property
	 */
	protected void modifyProperty(String name, String value)
		throws BuildException
	{
		Project project = getProject() ;
		if (project.getProperty(name) == null) // property does not
exist
		{
			addProperty(name, value) ;
		}		
		else
		{
System.out.println("Changing value for property " + name)  ;
			project.setProperty(name, value) ;
		}
	} // end method modifyProperty
} // end class ModifyProperty




Back to the top