ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From SimonRichards...@hbosts.com
Subject RE: $${${}}
Date Tue, 14 Jan 2003 17:00:26 GMT
Maybe you could define your dev and production properties 2 different property files :
in dev.properties
=================
application.build_label=dev
application.dev.property1=hello

in production.properties
========================
application.build_label=production
application.production.property1=foo

example build script:
=====================
NOTE: expects a command line arg ..

<project name="test" basedir="." default="set_properties">
<target name="init">
        <touch file="${build_label}"/>
        <condition property="property_file" value="dev.properties">
                <available file="dev"/>
        </condition>
        <condition property="property_file" value="production.properties">
                <available file="production"/>
        </condition>
</target>
<target name="fail_on_error"
        unless="property_file">
        <fail message="you have not identified the build_label correctly"/>
</target>
<target name="set_properties"
        depends="init,fail_on_error">
        <property file="${property_file}"/>
        <echo message="application.build_label = ${application.build_label}"/>
        <echo message="application.dev.property1 = ${application.dev.property1}"/>
        <echo message="application.production.property1 = ${application.production.property1}"/>
        <delete file="${build_label}"/>
</target>
</project>


Call your build script passing as an argument the build_label (dev|production) - 

ant -buildfile test.xml -Dbuild_label=dev

set_properties:
     [echo] application.build_label = dev
     [echo] application.dev.property1 = hello
     [echo] application.production.property1 = ${application.production.property1}
   [delete] Deleting: /hfx/home/develop/ssbuild/ssab2/buildfiles/dev

ant -buildfile test.xml -Dbuild_label=production

set_properties:
     [echo] application.build_label = production
     [echo] application.dev.property1 = ${application.dev.property1}
     [echo] application.production.property1 = foo
   [delete] Deleting: /hfx/home/develop/ssbuild/ssab2/buildfiles/production

HTH

Simon

> -----Original Message-----
> From: Bernd Matzke [mailto:Bernd.Matzke@forcont.de]
> Sent: 14 January 2003 16:27
> To: 'Ant Users List'
> Subject: RE: $${${}}
> 
> 
> hello,
> maybe one of these solutions may help. use an id for the 
> properties and
> create an help-property for the filter-value:
> 
> <project name="bsp004" default="main" basedir=".">
> 
>   <property name="application.environment" value="dev"/>
>   <property name="application.dev.property1" value="hello"    
>    id="dev"/>
>   <property name="application.production.property1" value="foo"
> id="production"/>
> 
>   <target name="main" >
>     <property name="filter" refid="${application.environment}"/>
>     <echo>${filter}</echo>
>   </target>
> 
> </project>
> 
> 
> If you won't use a different id instead of the name, you can 
> use the same
> name and id for an property. but you will need a secondhelper 
> property:
> 
> <project name="bsp005" default="main" basedir=".">
> 
>   <property name="application.environment" value="production"/>
>   <property name="application.dev.property1" value="hello"
> id="application.dev.property1"/>
>   <property name="application.production.property1" value="foo"
> id="application.production.property1"/>
> 
>   <target name="main" >
>     <property name="help"
> value="application.${application.environment}.property1"/>
>     <property name="filter" refid="${help}"/>
> 
>     <echo>${filter}</echo>
> 
>   </target>
> 
> </project>
> 
> -----Original Message-----
> From: loic.lefevre@bnpparibas.com [mailto:loic.lefevre@bnpparibas.com]
> Sent: Monday, January 13, 2003 6:57 PM
> To: ant-user@jakarta.apache.org
> Subject: $${${}}
> 
> 
> Hello all,
> I would like to know if their is a way to do this with Ant:
> 
> build.properties file:
> application.environment=dev
> application.dev.property1=hello
> application.production.property1=foo
> 
> build.xml file:
> ...
>        <filter token="message" value="${application.
> ${application.environment}.property1}"/>
> ...
> 
> Thus the property would change according to the environment target.
> Is it possible?
> 
> Thanks in advance,
> Loïc Lefèvre
> 
> 
> 
> 
> This message and any attachments (the "message") is
> intended solely for the addressees and is confidential. 
> If you receive this message in error, please delete it and 
> immediately notify the sender. Any use not in accord with 
> its purpose, any dissemination or disclosure, either whole 
> or partial, is prohibited except formal approval. The internet
> can not guarantee the integrity of this message. 
> BNP PARIBAS (and its subsidiaries) shall (will) not 
> therefore be liable for the message if modified. 
> 
>                 ---------------------------------------------
> 
> Ce message et toutes les pieces jointes (ci-apres le 
> "message") sont etablis a l'intention exclusive de ses 
> destinataires et sont confidentiels. Si vous recevez ce 
> message par erreur, merci de le detruire et d'en avertir 
> immediatement l'expediteur. Toute utilisation de ce 
> message non conforme a sa destination, toute diffusion 
> ou toute publication, totale ou partielle, est interdite, sauf 
> autorisation expresse. L'internet ne permettant pas 
> d'assurer l'integrite de ce message, BNP PARIBAS (et ses
> filiales) decline(nt) toute responsabilite au titre de ce 
> message, dans l'hypothese ou il aurait ete modifie.
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:ant-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: 
> <mailto:ant-user-help@jakarta.apache.org>
> 

-- 

------------------------------------------------------------------------------
For more information on HBOS Treasury Services, please visit http://www.HBOSTS.com

Or for details of our online FX & Deposit services, please go to http://www.HBOSdeal.com

HBOS Treasury Services plc is part of the HBOS Group, which also includes Halifax plc and
Bank of Scotland.
Registered Office: 33 Old Broad Street, London EC2N 1HZ. Registered No. 2692890. Registered
in England.
Regulated by the Financial Services Authority.

The information contained in this message is confidential and is intended for the addressee
only. If you have received this message in error or there are any problems please notify the
originator immediately. The unauthorised use, disclosure, copying or alteration of this message
is strictly forbidden. This mail and any attachments have been scanned for viruses prior to
leaving the HBOS Treasury Services plc network. HBOS Treasury Services plc will not be liable
for direct, special, indirect or consequential damages arising from alteration of the contents
of this message by a third party or as a result of any virus being passed on.

HBOS Treasury Services plc reserves the right to monitor and record e-mail messages sent to
and from this address for the purposes of investigating or detecting any unauthorised use
of its system and ensuring its effective operation.

==============================================================================


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


Mime
View raw message