Maven Enforcer Plugin
If you implement Maven projects that are used and build by several other people it's mostly advisable to validate the reqired environment conditions on the build machine. How nice that Apache provides the Maven-Enforcer-Plugin that allows controlling constraints like the Maven/ JDK versions, the OS version or the existence or value sets of environmental variables.
The Maven-Enforcer-Plugin is called by default during the validate phase of Maven's build lifecycle and lets you define a set of rules that are to be checked.
Here is an example configuration to be placed in your pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<!-- Allow any Java >= 1.5, but not 1.6 or above -->
<requireJavaVersion>
<version>[1.5,1.6)</version>
</requireJavaVersion>
<!-- Allow any Maven >= 2.0.5 -->
<requireMavenVersion>
<version>[2.0.5,)</version>
</requireMavenVersion>
<!-- Check existence and value of system property -->
<requireProperty>
<property>appserver.name</property>
<message>System property 'appserver.name' is not set!</message>
<regex>glassfish|jboss</regex>
<regexMessage>jboss and glassfish are supported!</regexMessage>
</requireProperty>
</rules>
</configuration>
</execution>
</executions>
</plugin>
0 TrackBacks
Listed below are links to blogs that reference this entry: Maven Enforcer Plugin.
TrackBack URL for this entry: http://www.innoq.com/mt4/mt-tb.cgi/2437
Leave a comment