Use maven-enforcer-plugin instead of prerequisites in archetypes

Christoph Dreis christoph.dreis at freenet.de
Wed Apr 12 17:47:06 UTC 2017


Hey,

as of Maven 3.5 using <prerequisites>..</prerequisites> for a non
maven-plugin project, will output a warning in the console.

The suggested solution is to use the maven-enforcer-plugin for that. The
attached patch shows this on the Java archetype. There are other occurrences
in the project which should be changed as well, but I omitted those for
clarity reasons in this mail. If you want me to add them though, I'd be
happy to do that if you tell me where to upload the complete patch as a
non-member.

Would be happy if this is sponsored.

Cheers,
Christoph

========== PATCH ===========
diff --git
a/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/archetype-r
esources/pom.xml
b/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/archetype-r
esources/pom.xml
---
a/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/archetype-r
esources/pom.xml
+++
b/jmh-archetypes/jmh-java-benchmark-archetype/src/main/resources/archetype-r
esources/pom.xml
@@ -45,10 +45,6 @@
        Edit as needed.
     -->

-    <prerequisites>
-        <maven>3.0</maven>
-    </prerequisites>
-
     <dependencies>
         <dependency>
             <groupId>org.openjdk.jmh</groupId>
@@ -96,6 +92,26 @@
             </plugin>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-enforcer-plugin</artifactId>
+                <version>1.4.1</version>
+                <executions>
+                    <execution>
+                        <id>enforce-maven</id>
+                        <goals>
+                            <goal>enforce</goal>
+                        </goals>
+                        <configuration>
+                            <rules>
+                                <requireMavenVersion>
+                                    <version>3.0</version>
+                                </requireMavenVersion>
+                            </rules>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-shade-plugin</artifactId>
                 <version>2.2</version>
                 <executions>




More information about the jmh-dev mailing list