I have the following XML in my maven POM.xml:
<profiles> <profile> <id>default</id> <activation> <activeByDefault>true</activeByDefault> <property> <name>default</name> <value>!disabled</value> </property> </activation> <modules> <module>m1</module> <module>m2</module> <module>m3</module> </modules> </profile> <profile> <id>x</id> <modules> <module>m1</module> </modules> </profile> </profiles>
What I'm trying to achieve is this:
When I run mvn install
, I want it to build m1, m2 and m3 projects.
When I run mvn install -Px
, I want it to only build m1.
My current problem is that with the code above, option 2 builds all m1, m2 and m3.
Profiles modify the POM at build time, and are used to give parameters different target environments (for example, the path of the database server in the development, testing, and production environments).
What you should do is check the profile behavior by doing the following : set activeByDefault to true in the profile configuration, run mvn help:active-profiles (to make sure it is effectively activated even without -Pdev1 ), run mvn install .
Found the solution guys, define 'x' profile first and the 'default' and it works fine (insane Maven!!). Here's the final result:
<profiles> <!-- DO NOT CHANGE THE *ORDER* IN WHICH THESE PROFILES ARE DEFINED! --> <profile> <id>x</id> <modules> <module>m1</module> </modules> </profile> <profile> <id>default</id> <activation> <activeByDefault>true</activeByDefault> </activation> <modules> <module>m1</module> <module>m2</module> <module>m3</module> </modules> </profile> </profiles>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With