ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jamie Jackson" <myspa...@gmail.com>
Subject Trying to do things the "Ant way"
Date Fri, 28 Jul 2006 15:17:48 GMT
I'm having a problem trying to grok the "ant way" to do things (i.e.,
without conditionals). I just got started with Ant a couple days ago, so
take that into consideration.

I'm trying to produce a well-factored script to handle code deployment to
remote servers.

Tasks:
*  deploy-integ
*  deploy-stage
*  deploy-prod
*  deploy-all (all of the above)

Here's the problem: Depending on the set of servers, some are available via
SSH, others are available via NFS, and I'd like the script to be
generalizable enough to specify the transfer type in the properties file,
along with the (potentially) varying paths among servers.

Here's a stab at the properties file:
-----------------------------------
svn.url=http://myhost/myrepos/myproj

integ.transfertype=nfs
stage.transfertype=ssh
prod.transfertype=ssh

# a nfs basepath would look like //webdev/websites
# an ssh basepath would look like username@hostname:/path/to/docroot
integ.basepath=//devserver/docroot
stage.basepath=username@hostname:/path/to/docroot
prod.basepath=username@hostname:/path/to/docroot

integ.proj.wwwroot=childwelfare
stage.proj.wwwroot=childwelfare
prod.proj.wwwroot=childwelfare
---------------------------------

Here are a couple of the salient tasks (see inline comments):

    <target name="deploy-integ">
        <deploy basepath="integ.basepath" proj.wwwroot="integ.proj.wwwroot"
transfertype="integ.transfertype" />
    </target>

    <macrodef name="deploy">
        <attribute name="args" />
        <attribute name="basepath" />
        <attribute name="proj.wwwroot" />
        <attribute name="transfertype" />
        <!-- I'd like to do it the "right way, and avoid "if", but don't
know how -->
        <!-- Not to mention that I can't even put the "if" in macrodef, so
it doesn't work anyway -->
        <if>
            <equals arg1="@{transfertype}" arg2="ssh" />
            <then>
                <property name="@{args}" value="-e ssh -Cacvz @{
local.buildDir}/* @{basepath}/@{proj.wwwroot}" />
            </then>
            <else>
                <property name="@{args}" value="-av @{local.buildDir}/
@{basepath}/@{proj.wwwroot}/" />
            </else>
        </if>
        <echo message="rsync ${args}" />
        <exec executable="rsync">
            <arg line="${args}" />
        </exec>
    </macrodef>

What's the right approach?

Thanks,
Jamie

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message