Building with ant: dynamic build capabilities?

With multiple developers working on the same Tomcat application, my point is that the application needs to be installed to a different path based on the current client and version control view / client.

So if Bob builds, the application should be installed in Bob's test environment, perhaps / bob 1 or something. Bob can have multiple version control clients / views / workspaces that he works with so he can have / bob 1, / bob2, / bob3, etc.

The installation location is specified in the build.properties file. Is there a way to avoid checking this file and changing it for each specific user and version control?

Can "ant install" accept arguments or be configured to account for environment variables for the install target?

+1


source to share


4 answers


I usually use the default answer, which is already set:

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

      



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

+5


source


You can override ant properties from the command line.

ant -Dinstall.location=/bob1 install

      



See Running Ant for details .

+2


source


This answer is quite late, but I just wanted to put it up for whoever might need it. The answer belongs to the second part of your question. "Can ant install" accept arguments or set up environment credentials for the install target? "

  • Define the environment you want in your build file:

    <property environment="env" />
    
          

  • reference the env variable and use it to specify the path. This is done in my classpath definition inside my build file. It talks about a jar named api.jar from the weblogic lib directory. You can access any other path until an associated environment is created for it. For example, you can access program files, documents, Java site, etc. if you sent environment variables for them. Here the environment variable defined for the weblogic install directory is BEA_HOME

    <fileset dir="${env.BEA_HOME}/wlserver_10.0/server/lib">
        <include name="api.jar" />
    </fileset>
    
          

+1


source


Defining properties with the -D option on the command line is fine, although it can be tedious if there are often many of them. To resist the urge to wrap the ant call in a bash script, it is common practice to import properties files.

In your main build file, you put:

<property file="default.properties" />

      

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

You must set the default ignore flag for the default.samples templates to prevent accidental exclusion (svn: ignore with subversion).

0


source







All Articles