when calling subant without inheritall="true" ant.version is not set. example top level build file: <target name="test1"> <echo message="${ant.project.name}" /> <echo message="${ant.version}" /> <subant target="test" buildpathref="subpath" /> </target> and in the build file specified by the path "subpath": <target name="test1"> <echo message="${ant.project.name}" /> <echo message="${ant.version}" /> </target> The output of "ant test" is: test project Apache Ant version 1.7.0 compiled on December 13 2006 test project subcomponent ${ant.version}
I am seeing this too. =================================================================== = SSH 2.4.1, (C) Copyright 1998-2007 Hewlett-Packard Development Company, LP (${ant.version})
as you can see, we dont get ant.version passed down in subant, more importanly we dont get any other ant built in props handed down. ] What#s happening is that the Ant init code creates a new project and calls setJavaVersionProperty(), whereas it maybe ought to be doing something like initProperties(): public void initProperties() throws BuildException { setJavaVersionProperty(); setSystemProperties(); setPropertyInternal(MagicNames.ANT_VERSION, Main.getAntVersion()); setAntLib(); } As it is, there's probably a fair bit of the initial state of a subant project that isnt being set up right. What to do? (a) stay broken and hope nobody notices (b) fix and hope nothing breaks. if (b), what do we pass down? Everything from initProperties()?
(In reply to comment #2) > as you can see, we dont get ant.version passed down in subant, more importanly > we dont get any other ant built in props handed down. > ] > What#s happening is that the Ant init code creates a new project and calls > setJavaVersionProperty(), whereas it maybe ought to be doing something like > initProperties(): > > > public void initProperties() throws BuildException { > setJavaVersionProperty(); > setSystemProperties(); > setPropertyInternal(MagicNames.ANT_VERSION, Main.getAntVersion()); > setAntLib(); > } > > > As it is, there's probably a fair bit of the initial state of a subant project > that isnt being set up right. > > What to do? > (a) stay broken and hope nobody notices > (b) fix and hope nothing breaks. > > if (b), what do we pass down? Everything from initProperties()? Yep, probably so. Looks like the right thing to do is replace newProject.setJavaVersionProperty() with newProject.init() in Ant.init() IMO.
It does look like a bug all right. The code in Ant.java calls newProject.setSystemProperties(); but does not call setJavaVersion() or setPropertyInternal(MagicNames.ANT_VERSION, Main.getAntVersion()) The one thing I would be concerened about from Project#initProperties() is setAntLib() which from some reason calls Locator.getClassSource() which does some File IO and antlib.getAbsolutePath() which does more FileIO. Maybe the solution would be to make ant.version and the java version properties to be user properties, these always get copied to sub-projects.
Just note that at least ant.version worked fine in 1.6.5, so it's probably 1.7.0 regression.
Yep, you are correct, the problem does not happen with ant 1.6.5.
ant.version was a user property this change seems to have made it a normal version http://svn.apache.org/viewvc?view=rev&revision=388848
that's good, I can change it without fear of lots of things breaking. Which properties were passed down in ant1.6.5?
Doing a quick grep in the ant 1.6.5 codebase I see the following uses of project.setUserProperty. Main.java: "ant.version", "ant.file" ProjectHelper2.java "ant.file" Project.java: "ant.project.name" VAJBuildInfo.java: "ant.file" Ant.java: "ant.file"
Fixed in SVN_HEAD...with a test to catch any regressions. I'm calling Oroject.initProperties() to do the initialisation, not Project.init().
Yeah, looks like initProperties() is better than init() for ComponentHelper reasons I'm sure you already deduced. :)
*** Bug 42715 has been marked as a duplicate of this bug. ***
Updating title as this bug affects all <ant>, <subant> and <antcall>
*** Bug 42970 has been marked as a duplicate of this bug. ***
Also affected ${ant.core.lib} in Ant 1.7.0. Manually confirmed fixed in 1.7.1 and dev. Added test and updated WHATSNEW in trunk (#643076), just WHATSNEW in branch (#643079).