You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Rakesh Patel <Ra...@sharepeople.com> on 2005/10/24 13:59:43 UTC

Specifying build properties

Hi,

Is there a way to specify which build file to use within a target?

I use my local machine for building the war for the development
environment and the production one. The properties are picked up from
build.properties but I have to change this file each time depending on
where I am going to deploy to.

I would like separate tasks, one for each environment, and within the
target specify which property file to use (eg dev.properties,
prod.properties).

Thanks

Rakesh




American Express Investments and American Express Independent Financial Advisers are marketing names for American Express Financial Services Europe Limited, a separate corporation within the American Express group of companies.  American Express Financial Services Europe Limited is authorised and regulated by, and is entered into the register (No. 190853 www.fsa.gov.uk/register/) of, the Financial Services Authority and a member of the London Stock Exchange. Registered in England No. 3614902. Registered address: 230 Blackfriars Road, London SE1 8NW. Vat No. 740 4143 68. 

The information in this email and any attachments is confidential and intended solely for the attention and use of the named addressee(s). It may be subject to legal, professional or other privilege and further distribution of it is strictly prohibited without our authority.  If you are not the intended recipient, you are not authorised to and must not disclose, copy, distribute, or retain this message or any part of it, and should notify us immediately.


Re: Specifying build properties

Posted by Steve Loughran <st...@apache.org>.
Rakesh Patel wrote:
> Hi,
> 
> Is there a way to specify which build file to use within a target?
> 
> I use my local machine for building the war for the development
> environment and the production one. The properties are picked up from
> build.properties but I have to change this file each time depending on
> where I am going to deploy to.
> 
> I would like separate tasks, one for each environment, and within the
> target specify which property file to use (eg dev.properties,
> prod.properties).
> 


Add a property into the mix to hold the name of the props

<target name="load-server-props">
  <fail unless="server.name">No server</fail>
  <properties file="conf/${server.name}.properties "/>
</target>

<target name="war" depends="load-server-props">
  <war ...>
</target>

At the same time, I want to warn you about the perils of having 
different WAR files for different destinations, as you can be sure that 
the wrong version will eventually get onto the wrong box. There are 
better approaches from the most advanced, SmartFrog : 
http://people.apache.org/~stevel/slides/oscon.pdf , to a simpler 
technique I've used in the past: having a properties file for each 
system in the WAR file, and having the webapp load these dynamically 
based on their hostname.

-steve

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org