Change pom property just for a specific profile
I need to change a pom property inside a defined profile from command line.
I just need to do it for one profile and not modify the others. Is there a plugin which I can use to do this?
Below a snippet of one of the profiles (active by default):
<profile> <id>3.7.x</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <support.version>3.7.1</support.version> </properties> </profile>
mvn clean install -Dsupport.version=your_value
Would effectively change the value of the support.version property defined in the 3.7.x profile, active by default.
If you want to change the value of the same property in another profile, that profile should also be activated, otherwise your change would simply be ignored.
You would hence run:
mvn clean install -Dsupport.version=your_value -Pprofile_name
That would change the support.version value for the profile_name profile.
However, beware that activating a profile from command line will deactivate a profile active by default in your POM (3.7.x in your case), but not a profile active by default as part of your settings.xml (which however will be shared by all of the Maven builds on that machine).
From Maven official documentation about profiles
This profile will automatically be active for all builds unless another profile in the same POM is activated using one of the previously described methods. All profiles that are active by default are automatically deactivated when a profile in the POM is activated on the command line or through its activation config.