Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify active profiles in Maven3

Our application consists of various active profiles (say A1, A2, A3, A5 ...) which were separately defined in a profiles.xml file. Maven 3 expects all the profile information to be stored as part of the pom.xml file itself.

How should I specify the list of active profiles within a pom.xml file, so that I can avoid specifying them in the command line (e.g. mvn -PA1,A2,A3,A5)

like image 818
user339108 Avatar asked Jan 22 '11 05:01

user339108


People also ask

How do I select a profile in Eclipse?

Here's how it works : Rather than right-clicking on a project, going to the Properties > Maven page, then manually (mis)typing a list of active or disabled profile, you just use the Ctrl+Alt+P shortcut to open the new Maven Profile selection interface.


2 Answers

Should this do it:

<profiles>
  <profile>
    <id>profile-1</id>
    <activation>
      <activeByDefault>true</activeByDefault>
    </activation>
    ...
  </profile>
</profiles>

From here.

like image 102
javamonkey79 Avatar answered Oct 08 '22 19:10

javamonkey79


Addidional to the answer of @javamonkey79 you can use the settings.xml. There are parts of profiles and activations. Look at the following example:

 <profiles>
  <profile>
   <id>hudson-simulate</id>
   <properties>
    <gituser>username</gituser>
    <gitpassword>secret</gitpassword>
   </properties>
  </profile>
  <profile>
   <id>other-profile</id>
   <properties>
    <proerty1>username</property1>
   </properties>
  </profile>
 </profiles>

 <activeProfiles>
  <activeProfile>hudson-simulate</activeProfile>
  <activeProfile>other-profile</activeProfile>
 </activeProfiles>
like image 23
Huluvu424242 Avatar answered Oct 08 '22 19:10

Huluvu424242