The two main approaches for enforcing maven 3 seem to be:

  • maven-enforcer-plugin, and
  • pom.xml <prerequisites> element.

The best approach to uses seems to depend on a few different factors. This question is to help people decide which approach makes the most sense for them.

Question: What types of project structures are best suited to maven-enforcer-plugin and what types of project structure are best suited to pom prerequisites.


Maven Enforcer Plugin Example

<build>
  <plugins>
    <plugin>
      <inherited>true</inherited>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-enforcer-plugin</artifactId>
      <version>1.3</version>
        <executions>
          <execution>
            <id>enforce-maven-3</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <requireMavenVersion>
                  <version>3.0.5</version>
                </requireMavenVersion>                
              </rules>
              <fail>true</fail>
            </configuration>
          </execution>
       </executions>
     </plugin>
  </plugins>
</build>

Maven POM Prerequisites Example

<project>
   ...
   <prerequisites>
       <maven>3.0.5</maven>
   </prerequisites>
   ...
</project>
Edit
Report