Or if you want to keep everything in the build.xml (you must have a finite
number of deployEnv values):

<target name="copy"
        depends="set-properties" />
  <copy file="template.xml"
        tofile="${hostname}_${realm}.xml" />
</target>

<target name="set-properties"
        depends="select-deployEnv, fail4-bad-deployEnv,
                 set-properties1, set-properties2" />

<target name="select-deployEnv">
  <condition property="bad-deployEnv">
    <not>
      <or>
        <equals arg1="${deployEnv}" arg2="expected-value1" />
        <equals arg1="${deployEnv}" arg2="expected-value2" />
      </or>
    </not>
  </condition>

  <condition property="use-deployEnv1">
    <equals arg1="${deployEnv}" arg2="expected-value1" />
  </condition>
  <condition property="use-deployEnv2">
    <equals arg1="${deployEnv}" arg2="expected-value2" />
  </condition>
</target>

<target name="fail4-bad-deployEnv"
        if="bad-deployEnv">
  <fail message="Unknown deployEnv: ${deployEnv}" />
</target>

<target name="set-properties1"
        if="use-deployEnv1">
  <property name="hostname" value="host1" />
  <property name="realm"    value="realm1" />
</target>

<target name="set-properties2"
        if="use-deployEnv1">
  <property name="hostname" value="host2" />
  <property name="realm"    value="realm2" />
</target>

it sure it more complicated, but it should work. Alexey's solutions is
better. You might just want to make sure the file actually exist though,
since <property file="" /> will silent not fail when it cannot find the
file. The only thing the solution above as is that everything is in
build.xml, but that's not a requirement for most people. --DD

-----Original Message-----
From: Alexey Solofnenko [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, June 12, 2002 4:52 PM
To: 'Ant Users List'
Subject: RE: how to copy/move a file to dynamically generated file name

I think the recommended way is to create separate property files, then:

<property file="${deployEnv}.property" prefix="env"/>
<copy file="template.xml" tofile="${env.hostname}_${env.realm}.xml"/>

- Alexey.

-----Original Message-----
From: Chabbewal, Navjeet [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 12, 2002 2:42 PM
To: Ant Users List
Subject: RE: how to copy/move a file to dynamically generated file name


Alexey,

I forgot to mention one thing, the environment name used in properties
file (dev in this case) is passed in to ant as -D property deployEnv. So
I tried ${${deployEnv}.hostname}_${${deployEnv}.realm}.xml but that does
not seem to work.

--Navjeet


> -----Original Message-----
> From: Alexey Solofnenko [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 12, 2002 5:30 PM
> To: 'Ant Users List'
> Subject: RE: how to copy/move a file to dynamically generated 
> file name
> 
> 
> You mean <copy file="template.xml" 
> tofile="${dev.hostname}_${dev.realm}.xml"
> />
> 
> - Alexey Solofnenko.
> 
> -----Original Message-----
> From: Dominique Devienne [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 12, 2002 2:28 PM
> To: 'Ant Users List'
> Subject: RE: how to copy/move a file to dynamically generated 
> file name
> 
> 
> As simple as <copy file="template.xml" tofile="BOMBAY_DEV.xml" />.
> Read the manual would help with this kind of questions ;-) --DD
> 
> -----Original Message-----
> From: Chabbewal, Navjeet [mailto:[EMAIL PROTECTED]] 
> Sent: Wednesday, June 12, 2002 4:20 PM
> To: [EMAIL PROTECTED]
> Subject: how to copy/move a file to dynamically generated file name
> 
> How can use copy/move to copy/move a file say template.xml to
> BOMBAY_DEV.xml, a dynamically generated filename,
> where BOMBAY and DEV are two properties defines in env.properties file
> (say two properties dev.hostname and dev.realm) ?
> 
> Thanks.
> 
> Navjeet S. Chabbewal
> Dimension Data
>  
> 
> 
> 
> --
> To unsubscribe, e-mail:   
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to