DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=29052>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=29052 getProject() method returns null when called from Custom Tasks [EMAIL PROTECTED] changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |WORKSFORME ------- Additional Comments From [EMAIL PROTECTED] 2004-05-18 07:00 ------- I have tested your code against Ant 1.4.0, 1.5.4, 1.6.1 and CVS and it works well on all: JustBuild.java -------------- import org.apache.tools.ant.Task; import org.apache.tools.ant.Project; public class JustBuild extends Task { private String myVersion; public void setVersion(String version) { myVersion = version; } public void execute() { System.out.println("In execute"); myVersion = getProject().getProperty("version"); if (myVersion == null) { System.out.println("myVersion is null"); } else { System.out.println(" myVersion: " + myVersion.toString()); int dot = myVersion.lastIndexOf("."); System.out.println(" got dot: " + String.valueOf(dot)); String buildnum = myVersion.substring(dot+1); System.out.println(" got buildnum: " + buildnum); System.out.println(" project is :"); System.out.println(" project: "+ getProject().toString()); getProject().setProperty("buildnum", buildnum); } } } build.xml --------- <project default="run"> <target name="compile"> <javac srcdir="."/> </target> <target name="run" depends="compile"> <taskdef name="justbuild" classname="JustBuild" classpath="."/> <echo>Ant-Version: ${ant.version}</echo> <justbuild/> </target> </project> output: ------- C:\TEMP\xxx>ant -version Ant version 1.4 compiled on September 3 2001 C:\TEMP\xxx>ant Buildfile: build.xml compile: [javac] Compiling 1 source file run: [echo] Ant-Version: Ant version 1.4 compiled on September 3 2001 [justbuild] In execute [justbuild] myVersion is null BUILD SUCCESSFUL Total time: 1 second C:\TEMP\xxx>set ant_home=c:\seu\ant154 C:\TEMP\xxx>ant Buildfile: build.xml compile: run: [echo] Ant-Version: Apache Ant version 1.5.4 compiled on August 12 2003 [justbuild] In execute [justbuild] myVersion is null BUILD SUCCESSFUL Total time: 1 second C:\TEMP\xxx>set ant_home=c:\seu\ant161 C:\TEMP\xxx>ant Buildfile: build.xml compile: run: [echo] Ant-Version: Apache Ant version 1.6.1 compiled on February 12 2004 [justbuild] In execute [justbuild] myVersion is null BUILD SUCCESSFUL Total time: 2 seconds C:\TEMP\xxx>set ant_home=c:\seu\ant17.5 C:\TEMP\xxx>ant Buildfile: build.xml compile: run: [echo] Ant-Version: Apache Ant version 1.7alpha compiled on May 10 2004 [justbuild] In execute [justbuild] myVersion is null BUILD SUCCESSFUL Total time: 1 second --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]