I am using Maven 3.6.0 and OpenJDK8 on Ubuntu 18.04 (also tested with Alpine Linux).
I have a pom.xml
in the root of my project that includes my submodules :
...
<modules>
<module>mysubmodule</module>
</modules>
...
In the mysubmodule
folder, the pom.xml
has a profile that I want to activate based on a property passed to the mvn
executable:
...
<profile>
<id>my-profile</id>
<activation>
<property>
<name>activateMyProfile</name>
</property>
</activation>
...
</profile>
...
I then execute mvn to start the build, but the profile is never activated:
mvn -DactivateMyProfile release:prepare
from the root of my project, the profile is never activated and never runs mvn release:prepare
from the root of my project, the profile is never run. I also tried the inverse:
...
<profile>
<id>my-profile</id>
<activation>
<property>
<name>!doNotActivateMyProfile</name>
</property>
</activation>
...
</profile>
...
mvn -DdoNotActivateMyProfile release:prepare
from the root of my project, the profile is still executed mvn release:prepare
from the root of my project, the profile is also executed It looks like mvn
is not able to see the properties being passed through the command line. What is the correct way to activate a profile in a submodule using a property?
As I am using the maven release plugin, parameters must be passed using the -Darguments
argument.
For example, instead of using mvn -DactivateMyProfile release:prepare
, the correct invocation is: mvn -Darguments=-DactivateMyProfile release:prepare
If there are multiple arguments, use mvn -Darguments="-DactivateMyProfile -DsomeOtherArg -DanotherArg=something" release:prepare
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.