Reputation: 27832
I would like to find out the values of all Maven properties as they apply to some Maven project.
mvn help:system
lists OS environment variables and JVM system properties, but no Maven properties.
mvn help:evaluate
only works in an interactive mode, that means I have to type a single Maven property, (e.g. ${project.build.outputDirectory}
) to get the value of that property.
I'm looking for a way get a full list of all Maven properties and their values.
Upvotes: 65
Views: 45799
Reputation: 360
I ended up using the below, which lists not just the properties defined in the pom.xml
, but also the ones defined programmatically by other plugins:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.4.0</version>
<executions>
<execution>
<id>list-properties</id>
<!-- Binds to the "validate" phase by default. -->
<goals>
<goal>bsh-property</goal>
</goals>
<configuration>
<source>
for (Map.Entry entry : project.getProperties().entrySet()) {
log.info(entry.getKey() + " = " + entry.getValue());
}
</source>
</configuration>
</execution>
</executions>
</plugin>
I imagine it's similar to the echoproperties
solution, but it is "more powerful" than the mvn help:evaluate
solution.
Upvotes: 2
Reputation: 1030
the maven-help-plugin does what you want, just call it with -Dexpression=project.properties
this will print the properties tag of the effective pom.
mvn help:evaluate -Dexpression=project.properties
Bonus Points when you just want the properties output and not the maven output
mvn help:evaluate -Dexpression=project.properties -q -DforceStdout
or with the explicit version because -DforceStdout
works since version 3.1.0
mvn org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.properties -q -DforceStdout
Upvotes: 39
Reputation: 741
Not sure if helps, but I found this when trying to do the same thing:
mvn com.github.ekryd.echo-maven-plugin:echo-maven-plugin:echo -Decho.message='${project.build.testOutputDirectory}'
From here.
Adding the following to ${user.home}/.m2/settings.xml
:
<pluginGroups>
<pluginGroup>com.github.ekryd.echo-maven-plugin</pluginGroup>
</pluginGroups>
the command can be shortened to:
mvn echo:echo -Decho.message='${project.build.testOutputDirectory}'
Upvotes: 7
Reputation: 1
Actually project.build.outputDirectory is there but you need to execute in 'compile' phase, and NOT in 'validate'. I guess what properties are available also depends on the current phase for the executing goal of a particular plug-in, in this case 'maven-antrun-plugin'.
<!-- Ant Run Plugin for debugging pom.xml and calling ant tasks -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>${ant.plugin.version}</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echoproperties/>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
Upvotes: 0
Reputation: 27832
As a workaround, add this to the <plugins> ... </plugins>
section inside your project's pom.xml
:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echoproperties />
</tasks>
</configuration>
</execution>
</executions>
</plugin>
Now execute mvn validate
.
On the console, prefixed with [echoproperties]
, there will be the full list of system properties, including those set by Maven such as project.build.outputDirectory
, basedir
, and settings.localRepository
.
Upvotes: 73
Reputation: 1
Had the same issue. Changed the timeout and maxheap in findbugs configuration through maven.
The below fixed it for me :
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<maxHeap>2048</maxHeap>
<timeout>1800000</timeout>
</configuration>
</plugin>
Upvotes: -4
Reputation: 105053
I don't know how to get them "officially", but here is a workaround. Add maven-antrun-plugin
to your project and run mvn test -X
. The plugin will show all properties passed to it from Maven. The list looks complete to me.
Upvotes: 1