Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ant: best way to setup system-dependent properties?

Tags:

ant

I have a number of file/executable locations that are likely to be different depending on which computer I am running them on, and I would like to abstract these out through ant properties somehow. What's the best way to do this? Is there a system-wide ant setup script that gets called? Or can I make such a script?

like image 491
Jason S Avatar asked Dec 03 '09 19:12

Jason S


2 Answers

In addition to Vladimir's solution you might have a default properties file for each of the OS or other you might deploy your build system on. Use the ${os.name} (and other Java system properties) to set up a path. For example

<property file="build-${os.name}.properties">

These files can be maintained and checked in into your version control system as well.

like image 119
Andreas Kraft Avatar answered Oct 20 '22 03:10

Andreas Kraft


I use the more or less standard build.properties and build-local.properties files.

The first contains default values, common to all environments, the second only the exceptions. The first one is checked into subversion while the other is not.

EDIT : copy/pasting Akr's excellent idea

In addition you might have a default properties file for each of the OS or other you might deploy your build system on. These files can be checked in into your version control system as well.

The Ant script would then include all the files as follow (remember: in Ant the first definition wins):

<property file="build-local.properties"/>
<property file="build.properties"/>
<property file="build-${os.name}.properties">
like image 32
Vladimir Avatar answered Oct 20 '22 01:10

Vladimir