You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Akbar Ibrahim <ak...@wipro.com> on 2000/07/07 15:24:09 UTC

Problem with Property Task

Hi,

I am using ant 3.1 (Release version) on WinNT4. In this version the
following

    <property name="x" value="a"/>
    <property name="x" value="${x}a"/>
    <property name="x" value="${x}a"/>
    <property name="x" value="${x}a"/>
    <echo message="${x}"/>

gives the output

aaaa

I just downloaded ant3.2 Beta 1 (Milestone Version). But in this version I
get

a

The concatenation is not working. Am I missing something ?

I am using this concat method to concat paths to the classpath property
which I later pass to the javac Task. Well the original reason why I
downloaded ant3.2Beta1 is that I could not get ant 3.1 to recognise
classpath properly.

I was previously working in C:/ and the javac Task used to work perfectly. I
am now working in D:/ and the javac Task is not able to find classes from
the classpath (which has dirs and jars from C:/ - appending to it using the
above concat method). Is this a problem with working in D:/ and using
classes from C:/ ? The classpath is getting reflected properly (in ant3.1)
and the classes *are available* in that classpath.

I thought this might be a problem with ant3.1 and dowloaded ant3.2Beta1 and
found the concatenation problem. In any case I am not able to compile :(

Any suggestions. I suppose I am missing something (have not been able to
follow the list for a long time so things might have changed without my
noticing).

Cheers,
Akbar
PS : Sorry for such a rambling mail


Re: Problem with Property Task

Posted by Akbar Ibrahim <ak...@wipro.com>.
----- Original Message -----
From: <tc...@lisa.com.au>
To: <an...@jakarta.apache.org>
Sent: Monday, July 10, 2000 10:48 AM
Subject: Re: Problem with Property Task


> Akbar Ibrahim writes:
>  > Well, changing C:/ and D:/ to C:\ and D:\ made it work (with ant3.1 and
>  > classpath concatenation). But I don't understand why. Earlier it worked
with
>  > C:/ but when I added D:/ it didn't, and when that is changed to C:\ and
D:\
>  > it works :(  Maybe I can try to have a look at the "/" and "\" anomaly
and
>  > send in a patch.
>  >
>  > I agree about the case where ant is run as an inner instance of another
ant
>  > so overriding property values should not be allowed. Couldn't each
>  > target/Task have properties of it's own which it can choose to change
or do
>  > whatever it wanted with and which wouldn't affect the outer version of
the
>  > property.
>  >
>  > I feel that there should be a way to allow properties, or specifically
>  > paths, to be built incrementally in this, or some other, manner. I hate
to
>  > have classpaths running to several lines (and wrapping around in the
>  > editor). I like to have each path in the classpath to be on a separate
line.
>  > This make it very clear and easy to edit. If all the paths are in one
single
>  > line it is very difficult to read/edit and easy to make mistakes.
>
> Doing this implicitly is, IMHO, not the way to do it.
>
> <property name="classpath" value="C:\"/>
> <property name="classpath" value="D:\"/>
> <property name="classpath" value="C:\lib"/>
> <property name="classpath" value="C:\classes\jaxp.jar"/>
>
> does not, to me, look as though it should concatenate all these
> values; it looks like a mistake which will end up with ${classpath}
> evaluating to "C:\classes\jaxp.jar". Doing it this way is pretty
> counter-intuitive, I reckon.


(Tom, maybe you are thinking aloud - suggesting a new method and vetoing it
yourself - or you have got my way of concatenating classpaths wrong.
Assuming the latter, apologies if it is the former, here goes...)
That was not how I was doing it. My code looked like

<property name="classpath" value="C:\"/>
<property name="classpath" value="${classpath};D:\"/>
<property name="classpath" value="${classpath};C:\lib"/>
<property name="classpath" value="${classpath};C:\classes\jaxp.jar"/>

This is intuitive and is exactly how it is done in Unix/Dos shells. Though
that should not be a reason why it should be done this way in ant too. There
*must* be some better way to do it.

> But you're right, wrapped classpaths are
> ugly. Is syntax like:
>
> <property name="classpath" value="C:\;\
> D:\;\
> C:\lib;\
> C:\classes\jaxp.jar"/>
>
> recognized, or is that deemed to make-like? ;-)


I don't think this is (or should be) recognized. Anyway, this is not good to
look at either. And there would be umpteen other (superior) ways to acheive
the same effect in XML.


>
> Regards
> Tom
> --
> Tom Cook - Software Engineer

Regards,
Akbar



Re: Problem with Property Task

Posted by tc...@lisa.com.au.
Akbar Ibrahim writes:
 > Well, changing C:/ and D:/ to C:\ and D:\ made it work (with ant3.1 and
 > classpath concatenation). But I don't understand why. Earlier it worked with
 > C:/ but when I added D:/ it didn't, and when that is changed to C:\ and D:\
 > it works :(  Maybe I can try to have a look at the "/" and "\" anomaly and
 > send in a patch.
 > 
 > I agree about the case where ant is run as an inner instance of another ant
 > so overriding property values should not be allowed. Couldn't each
 > target/Task have properties of it's own which it can choose to change or do
 > whatever it wanted with and which wouldn't affect the outer version of the
 > property.
 > 
 > I feel that there should be a way to allow properties, or specifically
 > paths, to be built incrementally in this, or some other, manner. I hate to
 > have classpaths running to several lines (and wrapping around in the
 > editor). I like to have each path in the classpath to be on a separate line.
 > This make it very clear and easy to edit. If all the paths are in one single
 > line it is very difficult to read/edit and easy to make mistakes.

Doing this implicitly is, IMHO, not the way to do it.

<property name="classpath" value="C:\"/>
<property name="classpath" value="D:\"/>
<property name="classpath" value="C:\lib"/>
<property name="classpath" value="C:\classes\jaxp.jar"/>

does not, to me, look as though it should concatenate all these
values; it looks like a mistake which will end up with ${classpath}
evaluating to "C:\classes\jaxp.jar". Doing it this way is pretty
counter-intuitive, I reckon. But you're right, wrapped classpaths are
ugly. Is syntax like:

<property name="classpath" value="C:\;\
																	D:\;\
																	C:\lib;\
																	C:\classes\jaxp.jar"/>

recognized, or is that deemed to make-like? ;-)

Regards
Tom
-- 
Tom Cook - Software Engineer

"The brain is a wonderful organ. It starts functioning the moment you get
up in the morning, and does not stop until you get into the office."
	- Robert Frost

LISAcorp - www.lisa.com.au

--------------------------------------------------
38 Greenhill Rd.          Level 3, 228 Pitt Street
Wayville, SA, 5034        Sydney, NSW, 2000

Phone:   +61 8 8272 1555  Phone:   +61 2 9283 0877
Fax:     +61 8 8271 1199  Fax:     +61 2 9283 0866
--------------------------------------------------

RE: Problem with Property Task

Posted by Conor MacNeill <co...@cognet.com.au>.
Akbar,

>
> Well, changing C:/ and D:/ to C:\ and D:\ made it work (with ant3.1 and
> classpath concatenation). But I don't understand why. Earlier it
> worked with
> C:/

OK - This is why. Say you are running ant from your C: drive and you have
put in a path of C:/test. The version of translatePath you have been using
converts this to C;\test. which is a path consisting of a directory C, which
probably doesn't exist, and a directory \test. Now since you are running on
C: this resolves to C:\test which is what you wanted but for the wrong
reasons :-)

Now when you have D:/test this is translated to a directory D and a
directory \test which resolves to C:\test which is not what you wanted.

> but when I added D:/ it didn't, and when that is changed to
> C:\ and D:\
> it works :(  Maybe I can try to have a look at the "/" and "\" anomaly and
> send in a patch.
>

In any case I committed a patch on the weekend which means translatePath
will now translate D:/test to D:\test. (If Phil Hanna is reading - you were
right :-)

>
> <javac ...>
>     <classpath>
>         <path value="C:\" />
>         <path value="D:\" />
>         <path value="E:\" />
>         <path value="F:\" />
>     </classpath>
> </javac>
>
> Ugh! This doesn't look too good but it is better than a classpath
> which runs

Thomas Haas has proposed something quite similar and I think there is some
agreement that we will eventualy adopt that as a way of definining paths.

Conor


Re: Problem with Property Task

Posted by Akbar Ibrahim <ak...@wipro.com>.
Well, changing C:/ and D:/ to C:\ and D:\ made it work (with ant3.1 and
classpath concatenation). But I don't understand why. Earlier it worked with
C:/ but when I added D:/ it didn't, and when that is changed to C:\ and D:\
it works :(  Maybe I can try to have a look at the "/" and "\" anomaly and
send in a patch.

I agree about the case where ant is run as an inner instance of another ant
so overriding property values should not be allowed. Couldn't each
target/Task have properties of it's own which it can choose to change or do
whatever it wanted with and which wouldn't affect the outer version of the
property.

I feel that there should be a way to allow properties, or specifically
paths, to be built incrementally in this, or some other, manner. I hate to
have classpaths running to several lines (and wrapping around in the
editor). I like to have each path in the classpath to be on a separate line.
This make it very clear and easy to edit. If all the paths are in one single
line it is very difficult to read/edit and easy to make mistakes.

Could there be some way to add paths incrementally to the classpath of the
javac task. Maybe..

<javac ...>
    <classpath>
        <path value="C:\" />
        <path value="D:\" />
        <path value="E:\" />
        <path value="F:\" />
    </classpath>
</javac>

Ugh! This doesn't look too good but it is better than a classpath which runs
for 10 lines. Maybe there is some better way to do this. I would certainly
welcome any which doesn't require me to specify the whole classpath in one
place.

Cheers,
Akbar


----- Original Message -----
From: Conor MacNeill <co...@m64.com>
To: <an...@jakarta.apache.org>
Sent: Friday, July 07, 2000 8:30 PM
Subject: RE: Problem with Property Task


> Akbar,
>
> If you run your code with the -verbose flag you will see the following.
>
> Setting project property: x -> a
>    +Task: property
>  [Property] Override ignored for x
>    +Task: property
>  [Property] Override ignored for x
>    +Task: property
>  [Property] Override ignored for x
>  +Target: main
>    +Task: echo
>
> I think this behaviour comes from the situation where ant is run as a
nested
> task. In that case you want the outer instance to control the property.
> Property definitions in the inner task should not override the values
> defined in the outer instance of ant, if you know what I mean.
>
> Nevertheless, I find the current behaviour very counter-intuitive. It is a
> very common thing for people to build up classpath properties in this way.
>
> As for your other problems, can you try using C:\ instead of C:/. I would
> like to change ant to handle this properly.
>
> Conor
>
>
> --
> Conor MacNeill
> Home: conor@m64.com
> Work: conor@cortexebusiness.com.au
> Web:  www.cortexebusiness.com.au
>
>
> > -----Original Message-----
> > From: Akbar Ibrahim [mailto:akbar.ibrahim@wipro.com]
> > Sent: Friday, 7 July 2000 23:24
> > To: ant-dev@jakarta.apache.org
> > Subject: Problem with Property Task
> >
> >
> > Hi,
> >
> > I am using ant 3.1 (Release version) on WinNT4. In this version the
> > following
> >
> >     <property name="x" value="a"/>
> >     <property name="x" value="${x}a"/>
> >     <property name="x" value="${x}a"/>
> >     <property name="x" value="${x}a"/>
> >     <echo message="${x}"/>
> >
> > gives the output
> >
> > aaaa
> >
> > I just downloaded ant3.2 Beta 1 (Milestone Version). But in this version
I
> > get
> >
> > a
> >
> > The concatenation is not working. Am I missing something ?
> >
> > I am using this concat method to concat paths to the classpath property
> > which I later pass to the javac Task. Well the original reason why I
> > downloaded ant3.2Beta1 is that I could not get ant 3.1 to recognise
> > classpath properly.
> >
> > I was previously working in C:/ and the javac Task used to work
> > perfectly. I
> > am now working in D:/ and the javac Task is not able to find classes
from
> > the classpath (which has dirs and jars from C:/ - appending to it
> > using the
> > above concat method). Is this a problem with working in D:/ and using
> > classes from C:/ ? The classpath is getting reflected properly (in
ant3.1)
> > and the classes *are available* in that classpath.
> >
> > I thought this might be a problem with ant3.1 and dowloaded
> > ant3.2Beta1 and
> > found the concatenation problem. In any case I am not able to compile :(
> >
> > Any suggestions. I suppose I am missing something (have not been able to
> > follow the list for a long time so things might have changed without my
> > noticing).
> >
> > Cheers,
> > Akbar
> > PS : Sorry for such a rambling mail
> >
> >
>


RE: Problem with Property Task

Posted by Conor MacNeill <co...@m64.com>.
Akbar,

If you run your code with the -verbose flag you will see the following.

Setting project property: x -> a
   +Task: property
 [Property] Override ignored for x
   +Task: property
 [Property] Override ignored for x
   +Task: property
 [Property] Override ignored for x
 +Target: main
   +Task: echo

I think this behaviour comes from the situation where ant is run as a nested
task. In that case you want the outer instance to control the property.
Property definitions in the inner task should not override the values
defined in the outer instance of ant, if you know what I mean.

Nevertheless, I find the current behaviour very counter-intuitive. It is a
very common thing for people to build up classpath properties in this way.

As for your other problems, can you try using C:\ instead of C:/. I would
like to change ant to handle this properly.

Conor


--
Conor MacNeill
Home: conor@m64.com
Work: conor@cortexebusiness.com.au
Web:  www.cortexebusiness.com.au


> -----Original Message-----
> From: Akbar Ibrahim [mailto:akbar.ibrahim@wipro.com]
> Sent: Friday, 7 July 2000 23:24
> To: ant-dev@jakarta.apache.org
> Subject: Problem with Property Task
>
>
> Hi,
>
> I am using ant 3.1 (Release version) on WinNT4. In this version the
> following
>
>     <property name="x" value="a"/>
>     <property name="x" value="${x}a"/>
>     <property name="x" value="${x}a"/>
>     <property name="x" value="${x}a"/>
>     <echo message="${x}"/>
>
> gives the output
>
> aaaa
>
> I just downloaded ant3.2 Beta 1 (Milestone Version). But in this version I
> get
>
> a
>
> The concatenation is not working. Am I missing something ?
>
> I am using this concat method to concat paths to the classpath property
> which I later pass to the javac Task. Well the original reason why I
> downloaded ant3.2Beta1 is that I could not get ant 3.1 to recognise
> classpath properly.
>
> I was previously working in C:/ and the javac Task used to work
> perfectly. I
> am now working in D:/ and the javac Task is not able to find classes from
> the classpath (which has dirs and jars from C:/ - appending to it
> using the
> above concat method). Is this a problem with working in D:/ and using
> classes from C:/ ? The classpath is getting reflected properly (in ant3.1)
> and the classes *are available* in that classpath.
>
> I thought this might be a problem with ant3.1 and dowloaded
> ant3.2Beta1 and
> found the concatenation problem. In any case I am not able to compile :(
>
> Any suggestions. I suppose I am missing something (have not been able to
> follow the list for a long time so things might have changed without my
> noticing).
>
> Cheers,
> Akbar
> PS : Sorry for such a rambling mail
>
>


Re: Problem with Property Task

Posted by Peter Donald <do...@mad.scientist.com>.
At 06:54  7/7/00 +0530, you wrote:
>Hi,
>
>I am using ant 3.1 (Release version) on WinNT4. In this version the
>following
>
>    <property name="x" value="a"/>
>    <property name="x" value="${x}a"/>
>    <property name="x" value="${x}a"/>
>    <property name="x" value="${x}a"/>
>    <echo message="${x}"/>
>
>gives the output
>
>aaaa
>
>I just downloaded ant3.2 Beta 1 (Milestone Version). But in this version I
>get
>
>a
>
>The concatenation is not working. Am I missing something ?

well yes and no. Propertys are not meant to be redefined and thus having
multiple properties of same name in build file is a big non as it removes
declarative aspect and relies on procedural aspect which around here no one
likes. So my best suggestion would be to not rely on that feature because
the earlier build was in error and latest build is correct behaviour.

>I was previously working in C:/ and the javac Task used to work perfectly. I
>am now working in D:/ and the javac Task is not able to find classes from
>the classpath (which has dirs and jars from C:/ - appending to it using the
>above concat method). Is this a problem with working in D:/ and using
>classes from C:/ ? The classpath is getting reflected properly (in ant3.1)
>and the classes *are available* in that classpath.

hmmm ... well there could be multiple probelsm as you are using
concaternation which is not supposed to work. Try getting latest nightly
build and testing as the behaviour you are getting with paths doesn't sem
quite right. More info is needed to figure out what is wrong :P


Cheers,

Pete

*------------------------------------------------------*
| "Nearly all men can stand adversity, but if you want |
| to test a man's character, give him power."          |
|       -Abraham Lincoln                               |
*------------------------------------------------------*