Mawia
Mawia

Reputation: 4310

Arranging Profiles and Plugins in pom.xml

I have these things in my pom.xml

These profiles are for separate build environment.

I need to make these plugins as common to both profiles.

Where should I place these common plugins?

Upvotes: 0

Views: 103

Answers (2)

ben75
ben75

Reputation: 28746

You can simply put them in the default build section. Since the plugins are common to both profiles: this the best way to do it.

Remark that if the configuration of plugins is slightly different for the different profiles you can use properties in the plugin configuration and define the values of those properties in the profile.

    <build>
       <plugins>
          <plugin>
              <groupId>someGroup</groupId>
              <artifactId>plugin1</artifactId>
              ...
          </plugin>
          <plugin>
              <groupId>someGroup</groupId>
              <artifactId>plugin2</artifactId>
              ...
          </plugin>
          <plugin>
              <groupId>someGroup</groupId>
              <artifactId>plugin3</artifactId>
              ...
          </plugin>
       </plugins>
     </build>

EDIT

Note that this solution will enable the plugins even when no profiles are activated. Not sure this what you need. (you maybe have a third build environment: for instance the developper computer where no profile are defined). In this case the solution of a third profile is the way to go.

 mvn clean install -Pprofile1,profile-common

or

 mvn clean install -Pprofile2, profile-common

and your common plugins defined in profile-common

Upvotes: 1

Akhilesh Singh
Akhilesh Singh

Reputation: 2596

You can have multiple profiles active at any given point of time. As such you can create a common profile( profile3) and keep the plugins there. The plugins/config which are dependent on specific profiles, can be kept in specific profile1 and profile2.

-P profile-1,profile-3

Upvotes: 0

Related Questions