If someone runs my pom.xml
they get a nasty error because an environment variable is not defined. I would like to trap this and show a more straightforward error so that the problem can be easily fixed by defined the environment variable.
I know probably not a good idea to have an environment variable in the pom, but this time I really need to. Any clues?
The variable is JAVA_6_HOME, the path to JDK6 since my default one is JDK7
Maven-enforcer-plugin can do it:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.3.1</version>
<executions>
<execution>
<id>enforce-property</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireEnvironmentVariable>
<variableName>JAVA_6_HOME</variableName>
<message>JAVA_6_HOME system variable must be set!</message>
</requireEnvironmentVariable>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With