views:

658

answers:

3

With multiple developers working on the same Tomcat application, I'd like to tell the application to install to a different path, based on the current user and revision control client/view.

So, if Bob is building, the app should be installed in Bob's test environment, maybe /bob1 or something like that. Bob might have several revision control clients/views/workspaces he works with so he could have /bob1, /bob2, /bob3, etc.

The install location is specified in the build.properties file. Is there a way to avoid checking that file out and changing it for each specific user and revision control view?

Can "ant install" take arguments or be configured to consider environment variables for the install target?

+1  A: 

You can override ant properties from the command line.

ant -Dinstall.location=/bob1 install

See Running Ant for more information.

flicken
A: 

Defining properties with the -D option at the command line is fine, though it can get tedious if there are many of them frequently. In order to resist the urge to wrap the ant invocation in a bash script, there is the common practise to import property files.

In the main build file you put:

<property file="default.properties" />

Then you have a file named default.properties.sample with a sample configuration. This is being checked into version control. The developers check out default.properties.sample, copy it to default.properties and edit it according to their needs.

You should set an ignore default flag for default.samples in order to prevent it from being checked in accidentally (svn:ignore with subversion).

SAL9000
+4  A: 

I typically use a variation on the default properties answer already given:

<property file="local.properties" />
<property file="default.properties" />

I read the local properties file first and the default one second. Users don't edit the default one (then accidentally check it in), they just define the properties they want to override in the local.properties.

Jeffrey Fredrick
+1: I use a very similar construct, but usually add "${user.home}/.ant/${ant.project}-local.properties" so that I (or other developers) can keep track of multiple sets of these customizations without having to go looking for them.
Ken Gentle