user1685632
user1685632

Reputation: 117

Maven overrides configuration in profiles plugin

I have a 3 maven profiles with plugins:

<profile>
   <id>first</id>
   <build>
     <plugins>
       <plugin>
           ...
        <configuration>
           <var>1</var>
        </configuration>
       </plugin>
     </plugins>
   </build>    
</profile>

<profile>
   <id>second</id>
   <build>
     <plugins>
       <plugin>
           ...
        <configuration>
           <var>2</var>
        </configuration>
       </plugin>
     </plugins>
   </build>    
</profile>

<profile>
   <id>third</id>
   <build>
     <plugins>
       <plugin>
           ...
        <configuration>
           <var>3</var>
        </configuration>
       </plugin>
     </plugins>
   </build>    
</profile>

When i start my build with mvn clean install -P first,second,third -X, I discovered that all this plugins was executed with configuration from from third profile. Is there any way to preserve my configuration for each of my plugins and not to be overriden by third configuration?

Upvotes: 1

Views: 223

Answers (1)

Jigar Joshi
Jigar Joshi

Reputation: 240956

As discussed in comments section, You would have to invoke 3 build activating each profile differently

for example

mvn clean install -Pfirst
mvn clean install -Psecond
mvn clean install -Pthird

and to disable compilation in second and third, you could configure maven-compiler-plugin for these profiles and use skipMain property to disable main's source compilation, also for tests

Upvotes: 1

Related Questions