You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Kiran Kodlady <ki...@gmail.com> on 2007/05/27 16:13:02 UTC

Bundling a particular set of files(Environment) inside War project

Hey.. 

I have encountered a problem while bundling a particular configuration files
inside War project:
Let me explain in detail on this :

> 
> War project structure is like below : 
> 
>  xyz_War--->config-->  IST-----------------> A bunch of xmls related to
> IST phase 
> 
>                            --> UAT----------------->A bunch of xmls
> related to UAT phase 
> 
>                             --> PRD----------------->A bunch of xmls
> related to PRD phase 
> 
>             -->src-->main-->java 
>             -->target 
>             -->webapp-->WEB-INF-->web.xml   
> 
> Explanation : xyz_War consists of folders like config, src,webapp,target. 
>                    config folder consists of different sub folders related
> to each testing phase of application(IST,UAT,PRD). These folders contain
> same set of files with different contents altogether. 
> 
> For a particular build i need to bundle only one set of files among IST,
> UAT or PRD. 
> 
> Hope u got my question. I need to pass this parameter(IST,UAT or PRD)
> during runtime of build creation. 

Thanks,

Kiran Kodlady
-- 
View this message in context: http://www.nabble.com/Bundling-a-particular-set-of-files%28Environment%29-inside-War-project-tf3823795s177.html#a10825109
Sent from the Maven - Users mailing list archive at Nabble.com.


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


RE: Bundling a particular set of files(Environment) inside War project

Posted by Arnaud Jeansen <ar...@calyon.com>.
Hi,

I had the same requirement and used profiles to achieve this. Depending
on the given parameter, a different extra resource directory is added :
In the WEB-INF/classes, you get the resources from the "resources"
directory plus the resources from the "resources_ENV" directory.


Snippets from my pom, you will have to change a few things to make it
handle you config/<ENV> structure. I would advise to change it to a
src/main/resources_<ENV> though :

	<!-- 
		Adding profiles to handle target environments : LOC,
DEV, INT and PROD
	-->
	<profiles>

		<profile>
			<id>env-loc</id>
			<properties>
				<env>LOC</env>
			</properties>
		</profile>

		<profile>
			<id>env-dev</id>
			<properties>
				<env>DEV</env>
			</properties>
		</profile>
		[...]
	</profiles>

	[...]
	
	<build>
		<plugins>
			<!-- 
				We separate our web resources in two
directories :
				* One is the standard and contains file
that are not dependent on the env.
				* The other is dependent on the
environment, and the right directory is loaded, 
				according to the 'env' variable, that is
manipulated by maven profiles
	
http://maven.apache.org/plugins/maven-war-plugin/examples/adding-filteri
ng-webresources.html
			-->
			<plugin>
	
<groupId>org.apache.maven.plugins</groupId>
	
<artifactId>maven-war-plugin</artifactId>
				<configuration>
					<webResources>
						<resource>
							<!-- path is
relative to the pom.xml directory, 
								i.e.
from the parent POM 
								Change
according to your module name
							-->
							<directory>
	
foowar/src/main/webapp_${env}
							</directory>
						</resource>
					</webResources>
				</configuration>
			</plugin>
		</plugins>
	</build>
[...]

You can then build a war for your DEV environment with a "mvn install
-Penv-dev" for exemple.


Hope this helps,
Arnaud Jeansen


-----Original Message-----
From: Maria Odea Ching [mailto:oching@exist.com] 
Sent: lundi 28 mai 2007 06:22
To: Maven Users List
Subject: Re: Bundling a particular set of files(Environment) inside War
project


I think what you can do here is put each configuration in a separate 
profile, then you can activate which profile you will use when you build

the project. You can configure the war plugin for each profile and set 
the warSourceIncludes and warSourceExcludes parameters to specify which 
of the config files you want included/excluded in that profile.

HTH,
Deng

Kiran Kodlady wrote:
> Hey..
>
> I have encountered a problem while bundling a particular configuration

> files inside War project: Let me explain in detail on this :
>
>   
>> War project structure is like below :
>>
>>  xyz_War--->config-->  IST-----------------> A bunch of xmls related 
>> to IST phase
>>
>>                            --> UAT----------------->A bunch of xmls 
>> related to UAT phase
>>
>>                             --> PRD----------------->A bunch of xmls 
>> related to PRD phase
>>
>>             -->src-->main-->java 
>>             -->target 
>>             -->webapp-->WEB-INF-->web.xml   
>>
>> Explanation : xyz_War consists of folders like config,
src,webapp,target. 
>>                    config folder consists of different sub folders 
>> related to each testing phase of application(IST,UAT,PRD). These 
>> folders contain same set of files with different contents altogether.
>>
>> For a particular build i need to bundle only one set of files among 
>> IST, UAT or PRD.
>>
>> Hope u got my question. I need to pass this parameter(IST,UAT or PRD)

>> during runtime of build creation.
>>     
>
> Thanks,
>
> Kiran Kodlady
>   


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

Re: Bundling a particular set of files(Environment) inside War project

Posted by Maria Odea Ching <oc...@exist.com>.
I think what you can do here is put each configuration in a separate 
profile, then you can activate which profile you will use when you build 
the project. You can configure the war plugin for each profile and set 
the warSourceIncludes and warSourceExcludes parameters to specify which 
of the config files you want included/excluded in that profile.

HTH,
Deng

Kiran Kodlady wrote:
> Hey.. 
>
> I have encountered a problem while bundling a particular configuration files
> inside War project:
> Let me explain in detail on this :
>
>   
>> War project structure is like below : 
>>
>>  xyz_War--->config-->  IST-----------------> A bunch of xmls related to
>> IST phase 
>>
>>                            --> UAT----------------->A bunch of xmls
>> related to UAT phase 
>>
>>                             --> PRD----------------->A bunch of xmls
>> related to PRD phase 
>>
>>             -->src-->main-->java 
>>             -->target 
>>             -->webapp-->WEB-INF-->web.xml   
>>
>> Explanation : xyz_War consists of folders like config, src,webapp,target. 
>>                    config folder consists of different sub folders related
>> to each testing phase of application(IST,UAT,PRD). These folders contain
>> same set of files with different contents altogether. 
>>
>> For a particular build i need to bundle only one set of files among IST,
>> UAT or PRD. 
>>
>> Hope u got my question. I need to pass this parameter(IST,UAT or PRD)
>> during runtime of build creation. 
>>     
>
> Thanks,
>
> Kiran Kodlady
>   


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