How to list all activated profiles in mvn in a multimodule project
-
14-07-2021 - |
سؤال
mvn help:active-profiles only list the profiles activate within the project + system settings you call it in.
It does not list the profiles that have been enabled/activated from i.e. the parent pom.
Any any way to actually see the full list of activated profiles by other means than trial-and-error to look at what properties are enabled or not ?
المحلول
I double-checked this and indeed, inherited profiles aren't listed when mvn help:active-profiles
is being called. This is with maven-help-plugin
version 2.1.1.
There is even a bug-report about this: MPH-79.
As a workaround, you can use older version:
mvn org.apache.maven.plugins:maven-help-plugin:2.0.2:active-profiles ...
نصائح أخرى
Another option is mvn help:all-profiles
, which also list inherited profiles.
Displays a list of available profiles under the current project. Note: it will list all profiles for a project. If a profile comes up with a status inactive then there might be a need to set profile activation switches/property.
More details in Maven's help plugin page
Do you always want to see the active profile in your build log? Then you could add the following plugin config to the <build> section.
In this example I added the plugin to the phase 'compile'. It could easily be added to a different phase.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-help-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>show-profiles</id>
<phase>compile</phase>
<goals>
<goal>active-profiles</goal>
</goals>
</execution>
</executions>
</plugin>
this works in maven 3.x
mvn help:active-profiles
mvn help:effective-profiles
Works to list the active profiles