On Wednesday 17 September 2003 12:17, Stefan Bodewig wrote: > On Wed, 17 Sep 2003, peter reilly <[EMAIL PROTECTED]> wrote: > > The javadoc on the import task says that <import> should only > > be used at the top-level. > > OK. > > > This statement is not in the manual. > > Let's fix it ;-) Yes... > > > The code does not check the precondition. > > Maybe it should? Yes - see below. > > > so it could be said that the top-level tasks (including import) do > > not get evaluated at parser time. > > OK, if I nest <import> into a target, something like > > <target name="define-paths" depends="detect-platform"> > <import file="${platform.specific.paths}"/> > </target> > > and this would import a file that had only <path> definitions - the > definitions are platform specific - will it work as expected? > > With "expected" I mean it would include the <path> defitions for my > platform (based on a property set by a task in target > detect-platform). And certainly make those <path>s usable for > subsequent targets.
using <import> within a target does not work as the code that was placed in to handle top-level tasks/types does not work in this case (it assumes the pre-condition). (This is revision 1.21 of ProjectHelper2). We get a crash and burn ;-) build.xml <project name="test"> <target name="use2"> <import file="echo.xml"/> </target> </project> echo.xml <project> <echo>Hello world</echo> </project> ant use2 BUILD FAILED java.lang.IndexOutOfBoundsException: Index: 8, Size: 7 at java.util.ArrayList.addAll(ArrayList.java:460) at org.apache.tools.ant.Target.endImportedTasks(Target.java:201) at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:159) at org.apache.tools.ant.taskdefs.ImportTask.execute(ImportTask.java:188) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:309) at org.apache.tools.ant.Task.perform(Task.java:401) at org.apache.tools.ant.Target.execute(Target.java:363) at org.apache.tools.ant.Target.performTasks(Target.java:390) at org.apache.tools.ant.Project.executeTarget(Project.java:1237) at org.apache.tools.ant.Project.executeTargets(Project.java:1094) at org.apache.tools.ant.Main.runBuild(Main.java:667) at org.apache.tools.ant.Main.startAnt(Main.java:220) at org.apache.tools.ant.Main.start(Main.java:184) at org.apache.tools.ant.Main.main(Main.java:267) Peter. > > Stefan > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]