How to print the actual MAVEN_OPTIONS that are used?

Is there a way to get maven to output the value of environment variables and maven at build time? This would be very useful for debugging things when they are wrong.

+7
maven environment-variables
source share
3 answers

You can use the Maven Help Plugin and help:system target, so your pom will be:

 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>testMavenOpt</groupId> <artifactId>testMavenOpt</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <name>testMavenOpt</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-help-plugin</artifactId> <version>2.1</version> </plugin> </plugins> </build> </project> 

and you should run mvn help:system

+8
source share

This will require some changes to the pom.

 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.1</version> <executions> <execution> <phase>validate</phase> <goals> <goal>run</goal> </goals> <configuration> <tasks> <echo>[MAVEN_OPTIONS]${env.MAVEN_OPTIONS}</echo> </tasks> </configuration> </execution> </executions> </plugin> 

Of course, the easiest way to run

 echo $MAVEN_OPT 
+2
source share

Run maven with the -X or --debug options

Command line example:

 mvn clean compile --debug 

You will see the environment information on the console.

0
source share

All Articles