ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John Sisson" <john.sis...@net-linx.com>
Subject RE: "Variable" Macros Properties
Date Wed, 12 Apr 2006 21:06:34 GMT
I have had success using antcall and params - this allows the properties
to reset each time
==
    <target name="synchronize escrow files"
            depends="setup configuration"
            description="extract the view to the escrow location">
      <!-- clean up the extraction target -->
      <mkdir dir="${dir.escrow.checkout}" />
      <!-- use the standard extractor for the source -->
      <echo message=" extracting SOURCE to ${dir.escrow.checkout} ..."
/>
      <antcall target="synchronize files">
        <param name="dir.checkout" value="${dir.escrow.checkout}" />
        <param name="stview"       value="${escrow.src.view}" />
        <param name="stconfig"     value="${escrow.src.config}" />
        <param name="starg.quiet"  value="${escrow.st.quiet}" />
      </antcall>
    </target>
==

==
    <!-- the whole source set -->
    <target name="synchronize files"
            depends="setup checkout
                   , setup project
                   , setup config
                   , synchronize this
                   , synchronize that"
            description="ensure all files are consistent with StarTeam">
        <echo message="synchronize source complete from '${stproject}'"
/>
    </target>
==

==
    <!-- STARTEAM operations -->
    <!-- dynamic setup for working checkout location -->
    <target name="setup checkout">
      <echo message="StarTeam checkout to ${dir.checkout}" />
      <mkdir dir="${dir.checkout}" />
    </target>

    <!-- dynamic setup for access to working view -->
    <target name="setup project">
      <echo message="StartTeam access to view ${stview}" />
      <property name="stproject" value="${staccess}/${stview}/"/>
    </target>

    <!-- dynamic setup for configuration label -->
    <target name="setup real config"
              if="stconfig">
      <property name="starg.config" value="-cfgl '${stconfig}' " />
    </target>
    <target name="setup fake config"
            unless="stconfig">
      <property name="starg.config" value="" />
    </target>

    <!-- dynamic setup for configuration label -->
    <target name="setup config"
            depends="setup real config
                   , setup fake config">
      <echo message="StartTeam configuration arg ${starg.config}" />
    </target>
==


-----Original Message-----
From: Fletcher, Michael (Calgary) [mailto:MFletche@petro-canada.ca] 
Sent: Wednesday, April 12, 2006 1:35 PM
To: Ant Users List
Subject: "Variable" Macros Properties

I would like to be able to take a macro parameter such as "devel" and
use this information to compute the actual path where the data is stored
(ex \\pca001\mypath).  Unfortunately I cannot use properties for these
values because they are immutable once set and I may use each macro more
than once.


How would I take a macro parameter and compute a path in a way that the
macro can be run more than once?


I am using Ant and some Ant macros to encapsulate deploying code in my
organization.  In the build.xml for each system I use a single ant task
such as this to deploy the application onto the server.

	<deployCorporateWebApp
			assemblypath="PetroCanada.Finance.Tales.Website"
			target-tier="pcaw2"
			target-level="devel"
			target-name="talefin"
			webconfig="Deploy\Config\website-devel.config"
/>

This is a simplified example of the macro definition.

	<macrodef name="deployCorporateWebApp">
		<attribute name="target-tier" default="pcaw2" />
		<!-- etc -->

		<sequential>
		
			<!-- Setup the target.basepath property -->
			<condition property="target.basepath"
value="\\pcaw2d1\wwwroot$">
				<equals arg1="@{target-tier}"
arg2="pcaw2" />
			</condition>
			
			<condition property="target.basepath"
value="\\pcaw2s1\wwwroot$">
				<equals arg1="@{target-tier}"
arg2="pcaw2" />
			</condition>
						
			<fail unless="target.basepath"
				message="Unknown target-level." />
			
			<!-- Compute the rest of the properties. -->
			<property name="target.path" 
				value =
"${target.basepath}\@{target-name}" />
								
			<!-- Simplified example of the actualy code -->	
			<delete dir="${target.path}" />
			<copy todir="{target.basepath}"/>
		</sequential>
	</macrodef>

This does not work because properties are immutable once set.


Michael Fletcher
Corporate and Executive Systems
(403) 296-4215
 
--------------------------------------------------------

This email communication is intended as a private communication for the
sole use of the primary addressee and those individuals listed for
copies in the original message. The information contained in this email
is private and confidential and If you are not an intended recipient you
are hereby notified that copying, forwarding or other dissemination or
distribution of this communication by any means is prohibited.  If you
are not specifically authorized to receive this email and if you believe
that you received it in error please notify the original sender
immediately.  We honour similar requests relating to the privacy of
email communications.
 
Cette communication par courrier electronique est une communication
privee a l'usage exclusif du destinataire principal ainsi que des
personnes dont les noms figurent en copie.  Les renseignements contenus
dans ce courriel sont confidentiels et si vous n'etes pas le
destinataire prevu, vous etes avise, par les presentes que toute
reproduction, transfert ou autre forme de diffusion de cette
communication par quelque moyen que ce soit est interdite.  Si vous
n'etes pas specifiquement autorise a recevoir ce courriel ou si vous
croyez l'avoir recu par erreur, veuillez en aviser l'expediteur original
immediatement.  Nous respectons les demandes similaires qui touchent la
confidentialite des communications par courrier electronique.

---------------------------------------------------------------------
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


Mime
View raw message