jQuery in Action, 2nd edition*
The moose likes Ant, Maven and Other Build Tools and the fly likes Using ANT to deploy Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Using ANT to deploy" Watch "Using ANT to deploy" New topic
Author

Using ANT to deploy

Ruturaj Waghmode
Greenhorn

Joined: Dec 22, 2008
Posts: 2
Hi,
I'm trying to automate our deploy process using ANT (since we using it for our build & ideally want to keep everything in ANT).
For Deployment, I intend to store environment info in properties file, which ANT can fetch values from for each environment.
However, found out that once a property value has been set in ANT, you can't change it i.e. can't use an ANT property as a variable.

Any tips or alternatives to solve this would be appreciated.

Cheers.
---------
Sample of what I'm trying to achieve. In real life, my sequence would be, read env1 properties, deploy, read env2 properties, deploy & so on.

<project name="RutuTest" default="build">
<target name="build">

<property name="temp" value="1" />
<echo message="temp = ${temp}" />
<property name="temp" value="2" />
<echo message="temp = ${temp}" />

</target>
</project>
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15957
    
  19

There's several ways to to this, but here's 2 I like to use:

1. Specify the build environment on the command line:

ant -Dbuild.type=test



Note that I also have global and local property files here to allow additional specialized builds. As always, whoever sets a property first, wins.

Another way is essentially a variant of this. Make "build-development", "build-test", and "build-production" goals (or however you like) in the build.xml file. Set the properties in these goals, then use Antcall to recurse on Ant as though you'd set them on the command line. This can be good if you have lots of properties to set (but not enough to warrant an extra properties file). And, people don't have to know what the exact values to put on the original Ant command line are, since it doesn't need "-D" settings.


Customer surveys are for companies who didn't pay proper attention to begin with.
Ruturaj Waghmode
Greenhorn

Joined: Dec 22, 2008
Posts: 2
Thanks. I'll try your option# 2 which looks feasible.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using ANT to deploy
 
Similar Threads
creating directory
Ant, windows xp, and a funky infinite loop
Help, I kept getting compilation error "package javax.ejb does not exist"
conditional build failure in Ant
package javax.ejb does not exist