You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Gilbert Rebhan <gi...@maksimo.de> on 2010/09/22 18:47:34 UTC

Problems with and

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.

Even tried with =
<ant antfile="path/to/generated/antfile" inheritall="false"
 dir="path/to/generated/antfile">
 <property name="user.dir" value="path/to/generated/antfile"/>
</ant>

but that's nonsense and didn't work either.

Any ideas beside an ugly =
<exec dir="path/to/generated/antfile" executable="java".../>

??

Regards, Gilbert

















---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Problems with and - (directory path issues)

Posted by Gilbert Rebhan <gi...@maksimo.de>.
-------- Original Message  --------
Subject: Re: Problems with <ant antfile..> and <java> - (directory path
issues)
From: Laurence <la...@gmail.com>
To: user@ant.apache.org
Date: 01.01.2011 21:31

Hi, Laurence

> Gilbert,
> 
> I was basically having the same problem you were (I discovered your post
> when I was trying to find a better fix).

> It's 1/1/2011 now and I am using the latest ANT (v1.8.2 was released on Dec
> 27) and have been trying every sort of combination with no luck at all.

we should create a bug report with our experience !?
Didn't try with ant 1.8.2 and also no further investigations since my
last post in September 2010

> I finally gave up and am using a Jython script block to do a "os.chdir" if I
> detect the paths are messed up. 
> I actually do two dir checks/fixes for each ant antfile call (if I have to
> change the working dir for the build.xml that gets called, I also have to
> undo it).

sounds interesting, could you provide more details, some snippets ?
Actually i'm using groovy for scripting purposes after switching from
javascript and lately from (j)ruby, so there should be similar
possibilities.

> I'm trying to avoid external bat files and shell scripts to try and keep
> things simple.

i dynamically create exec task with executable java.exe via <groovy>
task. Not very elegant but it works..


Regards, Gilbert



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Problems with and - (directory path issues)

Posted by Laurence <la...@gmail.com>.
Gilbert,

I was basically having the same problem you were (I discovered your post
when I was trying to find a better fix).

It's 1/1/2011 now and I am using the latest ANT (v1.8.2 was released on Dec
27) and have been trying every sort of combination with no luck at all.

I finally gave up and am using a Jython script block to do a "os.chdir" if I
detect the paths are messed up.

I actually do two dir checks/fixes for each ant antfile call (if I have to
change the working dir for the build.xml that gets called, I also have to
undo it).

I'm trying to avoid external bat files and shell scripts to try and keep
things simple.

My ANT directory problem was on a Windows Vista machine, I have not yet
tried the same build on OS X yet.

Laurence

-- 
View this message in context: http://ant.1045680.n5.nabble.com/Problems-with-ant-antfile-and-java-tp2849976p3324419.html
Sent from the Ant - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Problems with and

Posted by Gilbert Rebhan <gi...@maksimo.de>.
-------- Original Message  --------
Subject: Re: Problems with <ant antfile..> and <java>
From: Stefan Bodewig <bo...@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-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Problems with and

Posted by Stefan Bodewig <bo...@apache.org>.
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.  Note that the <ant> task can change the
basedir of your invoked build file in unexpected ways.

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"/>

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org