-------- Original Message -------- Subject: Re: Problems with <ant antfile..> and <java> From: Stefan Bodewig <bode...@apache.org> To: user@ant.apache.org Date: 23.09.2010 06:16
> On 2010-09-22, Gilbert Rebhan wrote: > >> My workflow (Env : ant1.7.1,sun jdk1.6.0_17,windows) >> dynamically creates an antfile. > >> The antfile has nothing special, only a <java> task and >> some <echo> for logging purposes. > >> <java classname="..." resultproperty=".." outputproperty=".." >> resultproperty=".." failonerror="true"> >> <arg value="some arg"/> >> <arg value="foobar.xsd"/> >> <arg value="foobar.xsd"/> >> <classpath> >> <fileset dir="path/to/generated/antfile"> >> <includes="*.jar"/> >> </fileset> >> </java> > > >> foobar.xsd resides under path/to/generated/antfile, >> means = >> /path/to/generated/antfile >> antfile.xml >> foobar.xsd >> ... > >> The generated antfile has to be called from another >> antscript, but with = > >> <ant antfile="path/to/generated/antfile/anfile.xml" inheritall="false" >> dir="path/to/generated/antfile"/> > >> i get a java.io.FileNotFoundException for <arg value="foobar.xsd"/> >> whereas running the generated antfile standalone just works fine. > > You could use the dir attribute of the <java> task - which also means > you'd have to fork the task. Fork ain't no option as i need to catch the stdout/stderr/rc for further processing.. > Another approach may be to give your generated project a name - say > "generated" - via the project's name attribute and then use > > <dirname property="generated.basedir" file="${ant.file.generated}"/> > > inside your generated file to find the absolute path of the directory > holding it and finally use > > <arg value="${ant.file.generated}/foobar.xsd"/> Thought of that already, but i need a more generic way to get the given args into a working java task. The given arguments are not always filenames like foobar.xsd. No strict rules for the arguments to be used ,may get filenames and sometimes i'll get only strings. Used groovy to create the antfile with a leading static part in java task args part like arg value '-cp' arg value '/path/to/generated/antfile' (where also userlibs reside..) and then simply for all other user given args for (arg : args) { arg value ...) > Note that the <ant> task can change the > basedir of your invoked build file in unexpected ways. IMO it's a bug, when ant -debug .. shows the correct basedir and user.dir, but it doesn't work as expected. It works without any problems when started standalone though. In both cases with -debug i see the same correct basedir/user.dir, but one time it fails the other time it works !? In the meantime i use the workaround with exec task = <exec dir=".." executable="java" errorproperty=".." .. when the dir attribute works without forking Regards, Gilbert --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@ant.apache.org For additional commands, e-mail: user-h...@ant.apache.org