ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Morten Mortensen <morten.morten...@tietoenator.com>
Subject RE: Q: Double-expansion - reading environment variables "dynamica lly" ?
Date Wed, 23 Jul 2003 19:40:23 GMT

Hi Eric & All,

Yes, there is no reason to be impatient.

To the best of my knowledge, "propertycopy" can not handle it - not by
itself.
The "propertycopy" task works *iff* the "from"-attribute-value is the name
of a property. In my case, it is not.

What I really want is not simply "property-expansion", but "expansion of
properties within a string" - I over-simplified the question, I think.

My input is read externally (actually by a custom task). An example of the
input is the string "file://localhost/${env.XXX_HOME}/aaa/bbb/ccc". This
ends up as the value of a property.

To use the "propertycopy" task, it is necessary to search for the delimiters
'${' and '}' (the delimiters can in principle be anything; the input-file
can be in Ant-property-syntax, but logically, it is not), pick the string
"env.XXX_HOME" and use this value as the "from"-attribute-value. Or doing it
"in reverse" by replacing the sub-string up until and including the
start-delimiter with the empty string and the same starting with the
end-delimiter... - leaving the "env.XXX_HOME" or whatever alone for
"propertycopy" to handle.

The "propertycopy" task has a more powerfull super-variant, which is capable
of more (replacing "iff" with "if").

Am I missing something here?

     -----

Which part of the API performs "property-expansion"?

-Does there exist a method taking a string like
"file://localhost/${env.XXX_HOME}/aaa/bbb/ccc" as input and returning the
expanded string - should have the exact same effect at litterally writing -

<property
  name="myProperty"
  value="file://localhost/${env.XXX_HOME}/aaa/bbb/ccc"
/>

     ?

"org.apache.tools.ant.Project.replaceProperties()" is the right thing?

Does there exist an explanation of the concept of "Properties",
"SystemProperties" and "UserProperties" relative to the API somewhere - and
where are environment-variables included? -Should just inspect the
source-code? Is the differentiation deprecated stuff?

(the last part of the "propertycopy"-impl is fun - it differentiates between
setting a "property" and a "user-property")

     -----

Regards,
  Morten Sabroe Mortensen
  TietoEnator A/S, Ved Lunden 12, 8230 Åbyhøj, Danmark
  mailto:Morten.Mortensen@tietoenator.com
  http://www.tietoenator.com


-----Original Message-----
From: Erik Hatcher [mailto:jakarta-ant@ehatchersolutions.com]
Sent: 7. juli 2003 13:24
To: Ant Developers List
Subject: Re: Q: Double-expansion - reading environment variables
"dynamically" ?


<propertycopy> from the ant-contrib project at Sourceforge is what you
want.

        Erik

p.s. No need to get impatient after less than a day of posting to the
user list, especially on a weekend.  Not to mention that this has been
answered numerous times on the list and the answer is surely in the
archives and most likely at the jGuru Ant FAQ, and also in the Java
Development With Ant book.

On Sunday, July 6, 2003, at 10:56  AM, Morten Mortensen wrote:
>
> Hi developers,
>
> I seem to have zero luck on the users-list... I am getting pretty
> impatient...
>
> To repeat: Given a defined property assigned the name of an
> environment-variable, how do I read the value of the
> environment-variable?
>
> Can it be done? How?
>
>      ?
>
> Regards,
> Morten Sabroe Mortensen
>
>
> -----Original Message-----
> From: Morten Mortensen
> To: 'user@ant.apache.org'
> Sent: 06-07-03 05:30
> Subject: Q: Double-expansion - reading environment variables
> "dynamically"?
>
>
> Given a defined property "x" assigned the name of an
> environment-variable, how do I read the value of the
> environment-variable?
>
>
> I can read the environment-variable "XXX_HOME" by introducing the
> environment as "env" and using "${env.XXX_HOME}" in my Ant-file.
>
> But what if "XXX_HOME" is specified as the value of a property?
>
>
> Constructed example:
>
>   <target
>     name="test"
>>
>     <property environment="env"/>
>
>     <!-- Property wired here for the example; is to be read by other
> means: -->
>     <property name="x" value="XXX_HOME"/>
>
>     <!-- Gee, does some kind of double-expansion work?: -->
>     <property name="v" value="${env.${x}}"/>
>
>     <!-- Would like to see the value identical to "${env.XXX_HOME}"
> here: -->
>     <echo>Result: ${v}</echo>
>   </target>
>
>
> If anyone knows how to do this, please tell me how.
>
>     ?
>
> Morten Sabroe Mortensen
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>


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

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


Mime
View raw message