Maven: Overview for the values of Maven properties

2020-02-18 08:02发布

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.

5条回答
ら.Afraid
2楼-- · 2020-02-18 08:24

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>
查看更多
倾城 Initia
3楼-- · 2020-02-18 08:28

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.

查看更多
Luminary・发光体
4楼-- · 2020-02-18 08:33

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

查看更多
劳资没心,怎么记你
5楼-- · 2020-02-18 08:36

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.

查看更多
手持菜刀,她持情操
6楼-- · 2020-02-18 08:44

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>
查看更多
登录 后发表回答