You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by ritchie <ga...@baml.com> on 2010/10/27 19:55:19 UTC
echo a property
I have a properties file (new.properties) which contains key value pairs as
"prod.eg=1" "dev.eg=2" . I am trying to access the property from a ant build
file echo.xml by loading the property file in the script.
<?xml version="1.0" encoding="UTF-8"?>
<project name= "echo" default="echoeg">
<property name="env" value="{env}"/>
<target name="echoeg" description="">
<property file="new.properties"/>
<echo message="${${env}.executiongroups}"/> -----> does not work
</target>
</project>
ant -f echo.xml -Denv prod
Could anyone tell me what is the correct syntax to access the property?
--
View this message in context: http://ant.1045680.n5.nabble.com/echo-a-property-tp3239198p3239198.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: echo a property
Posted by Gilbert Rebhan <gi...@maksimo.de>.
-------- Original Message --------
Subject: Re: echo a property
From: ritchie <ga...@baml.com>
To: user@ant.apache.org
Date: 27.10.2010 22:44
> <echo message="${${env}.eg}"/> -----> does not work
[..]
> I expect the echo to display 1. It does not happen. How else can i access
> that value?
see =
http://ant.apache.org/faq.html#propertyvalue-as-name-for-property
Regards, Gilbert
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: echo a property
Posted by "Scot P. Floess" <sf...@nc.rr.com>.
Did you mean to put a space after -Denv= prod?
I think you mean
ant -f echo.xml -Denv=prod
On Wed, 27 Oct 2010, ritchie wrote:
>
> I am sorry that was a typo when i posted it. That was not the problem.
>
> My properties file- new.properties contains.
>
> prod.eg=1
> dev.eg=2
>
> I am trying to access these properties in a echo.xml file
>
> <?xml version="1.0" encoding="UTF-8"?>
> <project name= "echo" default="echoeg">
> <property name="env" value="${env}"/>
> <target name="echoeg" description="">
> <property file="new.properties"/>
> <echo message="${${env}.eg}"/> -----> does not work
> </target>
> </project>
>> From command line i do this.
> ant -f echo.xml -Denv= prod
>
> I expect the echo to display 1. It does not happen. How else can i access
> that value?
>
--
Scot P. Floess
27 Lake Royale
Louisburg, NC 27549
252-478-8087 (Home)
919-890-8117 (Work)
Chief Architect FlossWare http://sourceforge.net/projects/flossware
http://flossware.sourceforge.net
https://github.com/organizations/FlossWare
Chief Architect JPlate http://sourceforge.net/projects/jplate
Chief Architect JavaPIM http://sourceforge.net/projects/javapim
Chief Architect Keros http://sourceforge.net/projects/keros
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: echo a property
Posted by Matt Benson <gu...@gmail.com>.
On Oct 27, 2010, at 4:25 PM, Gilbert Rebhan wrote:
> -------- Original Message --------
> Subject: Re: echo a property
> From: Matt Benson <gu...@gmail.com>
> To: Ant Users List <us...@ant.apache.org>
> Date: 27.10.2010 23:07
>
>> Are you talking about the props antlib? http://ant.apache.org/antlibs/props/index.html
> any way to make your props antlib work with ant 1.7.1 ?
>
None at all, the types of things the props antlib can do were specifically accommodated by Ant's rewritten property APIs in v1.8.0.
Sorry for the bad news,
Matt
> Regards, Gilbert
>
>
> ---------------------------------------------------------------------
> 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: echo a property
Posted by Gilbert Rebhan <gi...@maksimo.de>.
-------- Original Message --------
Subject: Re: echo a property
From: Matt Benson <gu...@gmail.com>
To: Ant Users List <us...@ant.apache.org>
Date: 27.10.2010 23:07
> Are you talking about the props antlib? http://ant.apache.org/antlibs/props/index.html
any way to make your props antlib work with ant 1.7.1 ?
Regards, Gilbert
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: echo a property
Posted by Gilbert Rebhan <gi...@maksimo.de>.
-------- Original Message --------
Subject: Re: echo a property
From: Matt Benson <gu...@gmail.com>
To: Ant Users List <us...@ant.apache.org>
Date: 27.10.2010 23:07
>
> On Oct 27, 2010, at 4:05 PM, Vimil Saju wrote:
>
>> You will need to enable nested property expansion.ant-contrib has a Property Helper class to expand nested properties. You will need to include this library in your ant class path and also specify something similar to follows
>> <propertyhelper> <nested/> </propertyhelper>
>
>
> Are you talking about the props antlib? http://ant.apache.org/antlibs/props/index.html
>
> -Matt
Wow, posting like machine gunning, one post nearly every minute, bam bam
bam :-)
Regards, Gilbert
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: echo a property
Posted by Matt Benson <gu...@gmail.com>.
On Oct 27, 2010, at 4:05 PM, Vimil Saju wrote:
> You will need to enable nested property expansion.ant-contrib has a Property Helper class to expand nested properties. You will need to include this library in your ant class path and also specify something similar to follows
> <propertyhelper> <nested/> </propertyhelper>
Are you talking about the props antlib? http://ant.apache.org/antlibs/props/index.html
-Matt
> --- On Wed, 10/27/10, ritchie <ga...@baml.com> wrote:
>
> From: ritchie <ga...@baml.com>
> Subject: Re: echo a property
> To: user@ant.apache.org
> Date: Wednesday, October 27, 2010, 1:44 PM
>
>
> I am sorry that was a typo when i posted it. That was not the problem.
>
> My properties file- new.properties contains.
>
> prod.eg=1
> dev.eg=2
>
> I am trying to access these properties in a echo.xml file
>
> <?xml version="1.0" encoding="UTF-8"?>
> <project name= "echo" default="echoeg">
> <property name="env" value="${env}"/>
> <target name="echoeg" description="">
> <property file="new.properties"/>
> <echo message="${${env}.eg}"/> -----> does not work
> </target>
> </project>
> From command line i do this.
> ant -f echo.xml -Denv= prod
>
> I expect the echo to display 1. It does not happen. How else can i access
> that value?
> --
> View this message in context: http://ant.1045680.n5.nabble.com/echo-a-property-tp3239198p3239475.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: echo a property
Posted by "Scot P. Floess" <sf...@nc.rr.com>.
Ah yeah, property expansion issues :( I was thinking in terms of
macrodefs... oh well...
Pt well taken...
On Wed, 27 Oct 2010, Vimil Saju wrote:
> You will need to enable nested property expansion.ant-contrib has a Property Helper class to expand nested properties. You will need to include this library in your ant class path and also specify something similar to follows�
> <propertyhelper> � � � �<nested/> </propertyhelper>
> --- On Wed, 10/27/10, ritchie <ga...@baml.com> wrote:
>
> From: ritchie <ga...@baml.com>
> Subject: Re: echo a property
> To: user@ant.apache.org
> Date: Wednesday, October 27, 2010, 1:44 PM
>
>
> I am sorry that was� a typo when i posted it. That was not the problem.
>
> My properties file- new.properties contains.
>
> prod.eg=1
> dev.eg=2
>
> I am trying to access these properties in a echo.xml file
>
> <?xml version="1.0" encoding="UTF-8"?>
> <project name= "echo" default="echoeg">
> <property name="env" value="${env}"/>
> <target name="echoeg" description="">
> <property file="new.properties"/>
> <echo message="${${env}.eg}"/> -----> does not work
> </target>
> </project>�
>> From command line i do this.
> ant -f echo.xml -Denv= prod
>
> I expect the echo to display 1. It does not happen. How else can i access
> that value?
>
--
Scot P. Floess
27 Lake Royale
Louisburg, NC 27549
252-478-8087 (Home)
919-890-8117 (Work)
Chief Architect FlossWare http://sourceforge.net/projects/flossware
http://flossware.sourceforge.net
https://github.com/organizations/FlossWare
Chief Architect JPlate http://sourceforge.net/projects/jplate
Chief Architect JavaPIM http://sourceforge.net/projects/javapim
Chief Architect Keros http://sourceforge.net/projects/keros
Re: echo a property
Posted by Vimil Saju <vi...@yahoo.com>.
You will need to enable nested property expansion.ant-contrib has a Property Helper class to expand nested properties. You will need to include this library in your ant class path and also specify something similar to follows
<propertyhelper> <nested/> </propertyhelper>
--- On Wed, 10/27/10, ritchie <ga...@baml.com> wrote:
From: ritchie <ga...@baml.com>
Subject: Re: echo a property
To: user@ant.apache.org
Date: Wednesday, October 27, 2010, 1:44 PM
I am sorry that was a typo when i posted it. That was not the problem.
My properties file- new.properties contains.
prod.eg=1
dev.eg=2
I am trying to access these properties in a echo.xml file
<?xml version="1.0" encoding="UTF-8"?>
<project name= "echo" default="echoeg">
<property name="env" value="${env}"/>
<target name="echoeg" description="">
<property file="new.properties"/>
<echo message="${${env}.eg}"/> -----> does not work
</target>
</project>
>From command line i do this.
ant -f echo.xml -Denv= prod
I expect the echo to display 1. It does not happen. How else can i access
that value?
--
View this message in context: http://ant.1045680.n5.nabble.com/echo-a-property-tp3239198p3239475.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: echo a property
Posted by ritchie <ga...@baml.com>.
I am sorry that was a typo when i posted it. That was not the problem.
My properties file- new.properties contains.
prod.eg=1
dev.eg=2
I am trying to access these properties in a echo.xml file
<?xml version="1.0" encoding="UTF-8"?>
<project name= "echo" default="echoeg">
<property name="env" value="${env}"/>
<target name="echoeg" description="">
<property file="new.properties"/>
<echo message="${${env}.eg}"/> -----> does not work
</target>
</project>
>From command line i do this.
ant -f echo.xml -Denv= prod
I expect the echo to display 1. It does not happen. How else can i access
that value?
--
View this message in context: http://ant.1045680.n5.nabble.com/echo-a-property-tp3239198p3239475.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: echo a property
Posted by "Scot P. Floess" <sf...@nc.rr.com>.
I think you want this:
<property name="env" value="${env}"/>
You ommitted the $ sign...
On Wed, 27 Oct 2010, ritchie wrote:
>
> I have a properties file (new.properties) which contains key value pairs as
> "prod.eg=1" "dev.eg=2" . I am trying to access the property from a ant build
> file echo.xml by loading the property file in the script.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <project name= "echo" default="echoeg">
> <property name="env" value="{env}"/>
> <target name="echoeg" description="">
> <property file="new.properties"/>
> <echo message="${${env}.executiongroups}"/> -----> does not work
> </target>
> </project>
>
> ant -f echo.xml -Denv prod
>
> Could anyone tell me what is the correct syntax to access the property?
>
--
Scot P. Floess
27 Lake Royale
Louisburg, NC 27549
252-478-8087 (Home)
919-890-8117 (Work)
Chief Architect FlossWare http://sourceforge.net/projects/flossware
http://flossware.sourceforge.net
https://github.com/organizations/FlossWare
Chief Architect JPlate http://sourceforge.net/projects/jplate
Chief Architect JavaPIM http://sourceforge.net/projects/javapim
Chief Architect Keros http://sourceforge.net/projects/keros
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: echo a property
Posted by ritchie <ga...@baml.com>.
I strongly believe in upgrading the ANT version but i am not decision maker
in my place of work. I just write the scripts and there are separate teams
which does the actual deployment.
--
View this message in context: http://ant.1045680.n5.nabble.com/echo-a-property-tp3239198p3243721.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: echo a property
Posted by Gilbert Rebhan <gi...@maksimo.de>.
-------- Original Message --------
Subject: Re: echo a property
From: Vimil Saju <vi...@yahoo.com>
To: Ant Users List <us...@ant.apache.org>
Date: 31.10.2010 00:29
> I was wondering why you can't upgrade to ant 1.8.1?
will upgrading to ant 1.8.1 solve his problem ?
Maybe, he may use the props antlib =
http://ant.apache.org/antlibs/props/index.html with ant1.8.1
But right now - still stuck on ant 1.7.1 - he has to use the solution
proposed in the ant faq, see =
http://ant.apache.org/faq.html#propertyvalue-as-name-for-property
Regards, Gilbert
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: echo a property
Posted by Vimil Saju <vi...@yahoo.com>.
I was wondering why you can't upgrade to ant 1.8.1?
--- On Sat, 10/30/10, ritchie <ga...@baml.com> wrote:
From: ritchie <ga...@baml.com>
Subject: Re: echo a property
To: user@ant.apache.org
Date: Saturday, October 30, 2010, 1:05 PM
Dominique Devienne-2 wrote:
>
> On Thu, Oct 28, 2010 at 9:15 AM, ritchie <ga...@baml.com>
> wrote:
>> I created a java class to read that property from the properties file
>> and
>> then passed it on to another java class which does the deployment. I am
>> not
>> sure whether this is a limitation in ant.
>
> You can call it a limitation of sort, sure.
>
> But there's an easy work-around. Instead of having a single property file
> with
>
> foo.eg=1
> bar.eg=2
> baz.eg=3
>
> have 3 property files foo.properties, bar.properties, etc.. containing
> the un-suffixed eg (and co.) properties, and in the build file simply
> <property file="${env}.properties" />.
>
> This is the "Ant way" (tm) of doing this that doesn't require jumping
> thry any hoops. --DD
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
>
The idea is to minimize the number of properties files also, that is why we
have set the property for different environment in a single properties file.
--
View this message in context: http://ant.1045680.n5.nabble.com/echo-a-property-tp3239198p3243621.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: echo a property
Posted by ritchie <ga...@baml.com>.
Dominique Devienne-2 wrote:
>
> On Thu, Oct 28, 2010 at 9:15 AM, ritchie <ga...@baml.com>
> wrote:
>> I created a java class to read that property from the properties file
>> and
>> then passed it on to another java class which does the deployment. I am
>> not
>> sure whether this is a limitation in ant.
>
> You can call it a limitation of sort, sure.
>
> But there's an easy work-around. Instead of having a single property file
> with
>
> foo.eg=1
> bar.eg=2
> baz.eg=3
>
> have 3 property files foo.properties, bar.properties, etc.. containing
> the un-suffixed eg (and co.) properties, and in the build file simply
> <property file="${env}.properties" />.
>
> This is the "Ant way" (tm) of doing this that doesn't require jumping
> thry any hoops. --DD
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
>
The idea is to minimize the number of properties files also, that is why we
have set the property for different environment in a single properties file.
--
View this message in context: http://ant.1045680.n5.nabble.com/echo-a-property-tp3239198p3243621.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: echo a property
Posted by Dominique Devienne <dd...@gmail.com>.
On Thu, Oct 28, 2010 at 9:15 AM, ritchie <ga...@baml.com> wrote:
> I created a java class to read that property from the properties file and
> then passed it on to another java class which does the deployment. I am not
> sure whether this is a limitation in ant.
You can call it a limitation of sort, sure.
But there's an easy work-around. Instead of having a single property file with
foo.eg=1
bar.eg=2
baz.eg=3
have 3 property files foo.properties, bar.properties, etc.. containing
the un-suffixed eg (and co.) properties, and in the build file simply
<property file="${env}.properties" />.
This is the "Ant way" (tm) of doing this that doesn't require jumping
thry any hoops. --DD
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: echo a property
Posted by ritchie <ga...@baml.com>.
I created a java class to read that property from the properties file and
then passed it on to another java class which does the deployment. I am not
sure whether this is a limitation in ant.
--
View this message in context: http://ant.1045680.n5.nabble.com/echo-a-property-tp3239198p3240608.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