You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Laurence Mills-Gahl <el...@gmail.com> on 2011/01/24 18:24:03 UTC

Fwd: Re: Output of perl exec behaving oddly (solved)

Just in case anybody else runs across this...

Setting the inheritall="yes" on the foreach task did the trick. Setting
the build directory at the top of the target now persists through all of
the invocations in the foreach task.



-------- Original Message --------
Subject: 	Re: Output of perl exec behaving oddly
Date: 	Mon, 24 Jan 2011 10:41:19 -0500
From: 	Laurence Mills-Gahl <el...@gmail.com>
To: 	user@ant.apache.org



I wasn't looking at the ${BUILDTIME} property because I was assuming
that wouldn't change during the run, but it is (I noticed the output
directory created ended with 20110124103046 (the timestamp) and the
second invocation of compile_patients_on_alert was trying to write a
file to 20110124103052. So your initial comment on immutability of
properties was helpful because I was assuming  ${BUILDTIME} would not
change (and it did... yikes!)

Hmmmm... I'm going to have to look at the foreach task to see if it
creates an entirely new ant invocation with each iteration... that would
be the easy way to allow properties to change and it would explain why
the timestamp (that is only set in the top of the project) appears to
change when it shouldn't... hmmm. That would also explain the apparent
inconsistency in that if the execs were spawned quickly enough (when I
was trying spawn="yes" ) they might get into the same timestamped
directory, but then eventually, one wouldn't).

Hmmm... time to dig in to the foreach environment a bit.

Thanks for looking at this.

Larry

On 1/24/11 8:25 AM, Michael Ludwig wrote:
> Laurence Mills-Gahl schrieb am 24.01.2011 um 00:56 (-0500):
>> On 1/23/11 10:12 PM, Michael Ludwig wrote:
>>> Laurence Mills-Gahl schrieb am 23.01.2011 um 21:27 (-0500):
>>>> I have a list of centerid's and a "foreach" loop
>>> Red flag goes up …
>> What is the red flag?
> Ah, that was just a manner of speaking.
>
> I was on the wrong track, sorry. :-)[...]


Re: Possible to dynamically reference a property?

Posted by da...@cartridgeorder.com.
Cool.  I went the macrodef route and everything worked

        <macrodef name="propertycopy">
                <attribute name="name"/>
                <attribute name="from"/>
                <sequential>
                        <property name="@{name}" value="${@{from}}"/>
                </sequential>
        </macrodef>
        <property name="baseurl.prop" value="selenium.vlv.${buildtarget}.baseurl"/>
        <propertycopy name="baseurl" from="${baseurl.prop}"/>


 - Dave




>  -------Original Message-------
>  From: Dominique Devienne <dd...@gmail.com>
>  To: Ant Users List <us...@ant.apache.org>, dave.alvarado@cartridgeorder.com
>  Subject: Re: Possible to dynamically reference a property?
>  Sent: Jan 25 '11 16:16
>  
>  On Tue, Jan 25, 2011 at 4:10 PM,  <da...@cartridgeorder.com> wrote:
>  > ON the doc it mentions "external" to ANt ... [...]
>  > So doesn't that mean it would NOT be part of the normal distrib? - Dave
>  
>  You might be right. Sorry, can't help more on this particular topic,
>  as I mentioned I've never done it myself.
>  
>  The easiest is to define the macro to emulate the AntContrib task.
>  That's pure Ant, no dependencies. Or use the <property
>  file="${env}.properties" /> idiom I mentioned. --DD
>  
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>  For additional commands, e-mail: user-help@ant.apache.org
>  
>  

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


Re: Possible to dynamically reference a property?

Posted by Dominique Devienne <dd...@gmail.com>.
On Tue, Jan 25, 2011 at 4:10 PM,  <da...@cartridgeorder.com> wrote:
> ON the doc it mentions "external" to ANt ... [...]
> So doesn't that mean it would NOT be part of the normal distrib? - Dave

You might be right. Sorry, can't help more on this particular topic,
as I mentioned I've never done it myself.

The easiest is to define the macro to emulate the AntContrib task.
That's pure Ant, no dependencies. Or use the <property
file="${env}.properties" /> idiom I mentioned. --DD

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


Re: Possible to dynamically reference a property?

Posted by Matt Benson <gu...@gmail.com>.
On Jan 25, 2011, at 4:27 PM, Dominique Devienne wrote:

> On Tue, Jan 25, 2011 at 4:10 PM,  <da...@cartridgeorder.com> wrote:
>> So doesn't that mean it would NOT be part of the normal distrib? - Dave
> 
> A Google search turned up this post, but he builds it from source,
> http://wdarby.blogspot.com/2010/06/using-antlib-props-in-ant-18.html
> 
> I suppose 'props' can be considered an AntLib (not even sure), but
> there doesn't seem to be an official release since it's not in
> http://www.apache.org/dist/ant/antlibs/
> 

props is an Antlib, it has never seen a formal release, and the blog posting you referenced seems in order.  :)

Matt (primary/only? author of the props Antlib)

> Hope this helps. --DD
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 


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


Re: Possible to dynamically reference a property?

Posted by Dominique Devienne <dd...@gmail.com>.
On Tue, Jan 25, 2011 at 4:10 PM,  <da...@cartridgeorder.com> wrote:
> So doesn't that mean it would NOT be part of the normal distrib? - Dave

A Google search turned up this post, but he builds it from source,
http://wdarby.blogspot.com/2010/06/using-antlib-props-in-ant-18.html

I suppose 'props' can be considered an AntLib (not even sure), but
there doesn't seem to be an official release since it's not in
http://www.apache.org/dist/ant/antlibs/

Hope this helps. --DD

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


Re: Possible to dynamically reference a property?

Posted by da...@cartridgeorder.com.
ON the doc it mentions "external" to ANt ...

With the 'props' antlib (external, but also from Ant) you could do the dereferencing with ${${anotherprop} - not just in the property task - instead everywhere in your buildfile (after registering the required property helper).

<propertyhelper>
  <props:nested />
</propertyhelper>
<property name="foo" value="foo.value" />
<property name="var" value="foo" />
<echo> ${${var}} = foo.value </echo>


So doesn't that mean it would NOT be part of the normal distrib? - Dave


>  -------Original Message-------
>  From: Dominique Devienne <dd...@gmail.com>
>  To: Ant Users List <us...@ant.apache.org>, dave.alvarado@cartridgeorder.com
>  Subject: Re: Possible to dynamically reference a property?
>  Sent: Jan 25 '11 16:08
>  
>  On Tue, Jan 25, 2011 at 3:58 PM,  <da...@cartridgeorder.com> wrote:
>  > Thanks, Dominique.  The nested properties (props) task seems like it will do the job.  However, do you know where to download this thing?  The links don't seem to have anything
>  >
>  > http://ant.apache.org/manual/properties.html
>  > http://ant.apache.org/faq.html#propertyvalue-as-name-for-property
>  
>  props is not a task, but a PropertyHelper extension. I suspect it's
>  part of the normal Ant distrib, so no need to download anything, but
>  I've never used it myself. You could try adding the declaration the
>  FAQ shows to enable it in your own build file and see if it works.
>  --DD
>  

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


Re: Possible to dynamically reference a property?

Posted by Dominique Devienne <dd...@gmail.com>.
On Tue, Jan 25, 2011 at 3:58 PM,  <da...@cartridgeorder.com> wrote:
> Thanks, Dominique.  The nested properties (props) task seems like it will do the job.  However, do you know where to download this thing?  The links don't seem to have anything
>
> http://ant.apache.org/manual/properties.html
> http://ant.apache.org/faq.html#propertyvalue-as-name-for-property

props is not a task, but a PropertyHelper extension. I suspect it's
part of the normal Ant distrib, so no need to download anything, but
I've never used it myself. You could try adding the declaration the
FAQ shows to enable it in your own build file and see if it works.
--DD

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


Re: Possible to dynamically reference a property?

Posted by da...@cartridgeorder.com.
Thanks, Dominique.  The nested properties (props) task seems like it will do the job.  However, do you know where to download this thing?  The links don't seem to have anything

http://ant.apache.org/manual/properties.html
http://ant.apache.org/faq.html#propertyvalue-as-name-for-property

 - Dave


>  -------Original Message-------
>  From: Dominique Devienne <dd...@gmail.com>
>  To: Ant Users List <us...@ant.apache.org>, dave.alvarado@cartridgeorder.com
>  Subject: Re: Possible to dynamically reference a property?
>  Sent: Jan 25 '11 15:39
>  
>  On Tue, Jan 25, 2011 at 3:32 PM,  <da...@cartridgeorder.com> wrote:
>  > Then I pass in this command line argument to my script "-Denv=...".  So, in my ant script, how do I dynamically access a property using the ${env} param?  For example, if "-Denv=dev" is passed in to the command line, what is a generic way of accessing the property, "dev.baseurl"?
>  
>  See http://ant.apache.org/faq.html#propertyvalue-as-name-for-property
>  
>  Thanks, --DD
>  
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>  For additional commands, e-mail: user-help@ant.apache.org
>  
>  

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


Re: Possible to dynamically reference a property?

Posted by Dominique Devienne <dd...@gmail.com>.
On Tue, Jan 25, 2011 at 3:39 PM, Dominique Devienne <dd...@gmail.com> wrote:
> On Tue, Jan 25, 2011 at 3:32 PM,  <da...@cartridgeorder.com> wrote:
>> Then I pass in this command line argument to my script "-Denv=...".  So, in my ant script, how do I dynamically access a property using the ${env} param?  For example, if "-Denv=dev" is passed in to the command line, what is a generic way of accessing the property, "dev.baseurl"?
>
> See http://ant.apache.org/faq.html#propertyvalue-as-name-for-property

Note that an alternative is to split your property file into several,
one per "prefix". Then you only have to <property
file="${env}.properties" /> and simply refer to the prefix-less
properties 'baseurl'. Put common (or default) properties into another
file yet, and load both in order, keeping in mind that the first
property defined "wins".

There's also <propertyset> which can work with prefixes and remove
them, but I don't think it applies here. --DD

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


Re: Possible to dynamically reference a property?

Posted by Dominique Devienne <dd...@gmail.com>.
On Tue, Jan 25, 2011 at 3:32 PM,  <da...@cartridgeorder.com> wrote:
> Then I pass in this command line argument to my script "-Denv=...".  So, in my ant script, how do I dynamically access a property using the ${env} param?  For example, if "-Denv=dev" is passed in to the command line, what is a generic way of accessing the property, "dev.baseurl"?

See http://ant.apache.org/faq.html#propertyvalue-as-name-for-property

Thanks, --DD

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


Possible to dynamically reference a property?

Posted by da...@cartridgeorder.com.
Hi,

I'm using Ant 1.8.  I load a properties file that loads define these properties ...

dev.baseurl=http://devurl
qa.baseurl=http://qaurl
approval.baseurl=http://approvalurl
staging.baseurl=http://stagingurl
prod.baseurl=http://produrl

Then I pass in this command line argument to my script "-Denv=...".  So, in my ant script, how do I dynamically access a property using the ${env} param?  For example, if "-Denv=dev" is passed in to the command line, what is a generic way of accessing the property, "dev.baseurl"?

Thanks, - Dave

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