57

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.

Abdull
  • 26,371
  • 26
  • 130
  • 172
  • 1
    Maybe [this](http://stackoverflow.com/q/4532687/367285) related question and answer is helpful. – FrVaBe Sep 12 '12 at 07:24
  • Does this answer your question? [Where is the list of predefined Maven properties](https://stackoverflow.com/questions/4409560/where-is-the-list-of-predefined-maven-properties) – cb4 Jun 02 '22 at 03:39

6 Answers6

65

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.

mkobit
  • 43,979
  • 12
  • 156
  • 150
Abdull
  • 26,371
  • 26
  • 130
  • 172
22

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
Pino
  • 7,468
  • 6
  • 50
  • 69
Lusk116
  • 791
  • 1
  • 6
  • 17
  • 3
    This should be the accepted answer IMO. It doesn't require any edits to pom files and can be used to view any property e.g. `-Dexpression=spring.version` – byxor Apr 14 '22 at 16:12
  • If you are using an old maven version (for example 3.3.9) specify plugin version 3.1.0 to avoid the error described in https://stackoverflow.com/questions/55736016/how-to-fix-java-lang-classnotfoundexception-org-apache-maven-model-io-xpp3-mav – Pino May 15 '23 at 17:04
6

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}'
Sébastien Le Callonnec
  • 26,254
  • 8
  • 67
  • 80
fhiegel
  • 631
  • 6
  • 12
1

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.

yegor256
  • 102,010
  • 123
  • 446
  • 597
  • 1
    So I followed your suggestion, but it didn't work; added maven-antrun-plugin in the pom.xml as pointed out in [its documentation](http://docs.codehaus.org/display/MAVENUSER/Antrun+Plugin), then i executed `mvn test -X`. I couldn't find any Maven-specific properties. Yegor, does your list include the Maven property `project.build.outputDirectory`? – Abdull Sep 11 '12 at 21:06
0

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>
-2

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>