How do I activate a profile?
Author: Deron Eriksson
Description: This tutorial describes how to activate a profile.
Tutorial created using: Windows Vista || JDK 1.6.0_04 || Eclipse Web Tools Platform 2.0.1 (Eclipse 3.3.1)


With mavenSW, a profile can be set to active by including its id as an activeProfile in the activeProfiles section of your settings.xml file.

Here is an example fragment from settings.xml. It contains two profiles, "a.profile" and "b.profile". I set "a.profile" to be an active profile.

Fragment from settings.xml

...
	<profiles>
...
		<profile>
			<id>a.profile</id>
			<properties>
				<a.property>this is a property</a.property>
			</properties>
		</profile>
		<profile>
			<id>b.profile</id>
			<properties>
				<b.property>this is another property</b.property>
			</properties>
		</profile>
...
	</profiles>
...
	<activeProfiles>
		<activeProfile>a.profile</activeProfile>
	</activeProfiles>
...

If we display the active profiles for the "mytest" project via the "help:active-profiles" goal, we see that "a.profile" is an active profile, as expected.

Console output from 'mvn help:active-profiles'

[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'help'.
[INFO] ------------------------------------------------------------------------
[INFO] Building mytest
[INFO]    task-segment: [help:active-profiles] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [help:active-profiles]
[INFO] 
Active Profiles for Project 'com.maventest:mytest:jar:1.0-SNAPSHOT': 

The following profiles are active:

 - a.profile (source: settings.xml)



[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Sun Feb 10 11:43:25 PST 2008
[INFO] Final Memory: 2M/5M
[INFO] ------------------------------------------------------------------------