You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Tony Steele <to...@bbc.co.uk> on 2005/11/03 13:52:50 UTC

RE: [m2] Updating *.properties files according to environment - How I do It

This is the solution I use:

The configuration has a profile per environment (live, uat dev etc) and
filters any resource file using an environment property file in the
/conf directory (e.g. <artifactId>-live.properties ).  When you do a
build you just use -P ( e.g. -P live) to build for the particular
config. In Maven 1 I had to do my own plugin to do all this.

If any body has a better or more concise way of doing this please post
it?

In my global pom.xml (parent to all project poms) 

	<build>
		<plugins>
			<!-- Sets up projects to use build property
filtering -->
			<plugin>
	
<groupId>org.apache.maven.plugins</groupId>
	
<artifactId>maven-resources-plugin</artifactId>
				<configuration>
					<filtering>true</filtering>
	
<filterPropertiesFile>${resource.filter.file}</filterPropertiesFile>
				</configuration>
			</plugin>
		</plugins>
	</build>
	<profiles>
		<!-- default (global) profile used by all projects. -->
		<!-- ********************************************** -->
		<profile>
			<id>default</id>
			<!-- Default stuff -->
		</profile>		
		<!-- Live build profile - used to filter files using
live properties. -->
		<!--
**************************************************************** -->
		<profile>
			<id>live</id>
			<properties>
	
<resource.filter.file>${basedir}/conf/${project.artifactId}-live.propert
ies</resource.filter.file>
			</properties>
		</profile>
		<!-- UAT build profile - used to filter files using UAT
properties. -->
		<!--
************************************************************** -->
		<profile>
			<id>uat</id>
			<properties>
	
<resource.filter.file>${basedir}/conf/${project.artifactId}-uat.properti
es</resource.filter.file>
			</properties>
		</profile>
		<!-- Dev build profile - used to filter files using Dev
properties. -->
		<!--
************************************************************** -->
		<profile>
			<id>dev</id>
			<properties>
	
<resource.filter.file>${basedir}/conf/${project.artifactId}-dev.properti
es</resource.filter.file>
			</properties>
		</profile>
	</profiles>
	<activeProfiles>
		<!-- This profile will always be used -->
		<activeProfile>default</activeProfile>
	</activeProfiles>


-----Original Message-----
From: Samuel Le Berrigaud [mailto:samuel.lb@gmail.com] 
Sent: 03 November 2005 11:38
To: Maven Users List
Subject: [m2] Updating *.properties files according to environment


Hi,

here is what I would like to do. I have some properties files for which
values depends on the environement (development, test, live...) or per
developer.

Here is a basic example:

jdbc.driverClassName=@DATABASE_DRIVER@
jdbc.url=@DATABASE_URL@
jdbc.username=@DATABASE_USERNAME@ jdbc.password=@DATABASE_PASSWORD@


What I would like is that, according to the environment, the variables
of these files could be populated with right value (may be stored in
pom.xml or settins.xml), and as far as possible keep a constant
directory structure...

I have seen the "profile" managment that m2 provides, but it look like
that for what I do, I would have to have different directories for the
different environments (profiles)...

Is that possible using m2 ?

Please tell me if I'm not clear enough...

Thank you,

--
Samuel Le Berrigaud

http://www.bbc.co.uk/

This e-mail (and any attachments) is confidential and may contain
personal views which are not the views of the BBC unless specifically
stated.
If you have received it in error, please delete it from your system. 
Do not use, copy or disclose the information in any way nor act in
reliance on it and notify the sender immediately. Please note that the
BBC monitors e-mails sent or received. 
Further communication will signify your consent to this.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org