You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2021/04/05 12:39:14 UTC

[maven-wrapper-plugin] branch master updated: [MWRAPPER-8] Let plugin fail on Maven 3

This is an automated email from the ASF dual-hosted git repository.

rfscholte pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-wrapper-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new a8adf99  [MWRAPPER-8] Let plugin fail on Maven 3
a8adf99 is described below

commit a8adf99ba4f975ef62a91435c3295f5478a4d5b7
Author: rfscholte <rf...@apache.org>
AuthorDate: Mon Apr 5 14:38:56 2021 +0200

    [MWRAPPER-8] Let plugin fail on Maven 3
---
 pom.xml                                            |  3 ++-
 src/it/projects/default/invoker.properties         |  2 +-
 src/it/projects/excludeDebug/invoker.properties    |  2 +-
 src/it/projects/extension/invoker.properties       |  2 +-
 .../{mavenversion => maven3}/invoker.properties    |  5 ++--
 src/it/projects/maven3/pom.xml                     | 29 ++++++++++++++++++++++
 src/it/projects/maven3/verify.groovy               | 21 ++++++++++++++++
 src/it/projects/mavenversion/invoker.properties    |  2 +-
 src/it/projects/type_bin/invoker.properties        |  2 +-
 src/it/projects/type_source/invoker.properties     |  2 +-
 src/it/projects/wrapperversion/test.properties     |  2 +-
 .../apache/maven/plugins/wrapper/WrapperMojo.java  | 18 ++++++++++----
 src/site/markdown/index.md.vm                      |  2 +-
 13 files changed, 76 insertions(+), 16 deletions(-)

diff --git a/pom.xml b/pom.xml
index dd88645..fdba171 100644
--- a/pom.xml
+++ b/pom.xml
@@ -132,8 +132,9 @@ under the License.
                 <goal>wrapper</goal>
               </goals>
               <projectsDirectory>src/it/projects</projectsDirectory>
+              <debug>false</debug>
               <pomExcludes>
-                <!-- remove once Maven 3.7.0 is released -->
+                <!-- remove once Maven 4 is released -->
                 <pomExclude>wrapperversion/pom.xml</pomExclude>
               </pomExcludes>
             </configuration>
diff --git a/src/it/projects/default/invoker.properties b/src/it/projects/default/invoker.properties
index d880d6e..3125747 100644
--- a/src/it/projects/default/invoker.properties
+++ b/src/it/projects/default/invoker.properties
@@ -14,5 +14,5 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-invoker.maven.version = 3.7.0+
+invoker.maven.version = 4+
 invoker.goals = org.apache.maven.plugins:maven-wrapper-plugin:${project.version}:wrapper
\ No newline at end of file
diff --git a/src/it/projects/excludeDebug/invoker.properties b/src/it/projects/excludeDebug/invoker.properties
index d880d6e..3125747 100644
--- a/src/it/projects/excludeDebug/invoker.properties
+++ b/src/it/projects/excludeDebug/invoker.properties
@@ -14,5 +14,5 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-invoker.maven.version = 3.7.0+
+invoker.maven.version = 4+
 invoker.goals = org.apache.maven.plugins:maven-wrapper-plugin:${project.version}:wrapper
\ No newline at end of file
diff --git a/src/it/projects/extension/invoker.properties b/src/it/projects/extension/invoker.properties
index 7b22bf3..659152d 100644
--- a/src/it/projects/extension/invoker.properties
+++ b/src/it/projects/extension/invoker.properties
@@ -15,4 +15,4 @@
 # specific language governing permissions and limitations
 # under the License.
 
-invoker.maven.version = 3.7.0+
+invoker.maven.version = 4+
diff --git a/src/it/projects/mavenversion/invoker.properties b/src/it/projects/maven3/invoker.properties
similarity index 91%
copy from src/it/projects/mavenversion/invoker.properties
copy to src/it/projects/maven3/invoker.properties
index d880d6e..8518b19 100644
--- a/src/it/projects/mavenversion/invoker.properties
+++ b/src/it/projects/maven3/invoker.properties
@@ -14,5 +14,6 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-invoker.maven.version = 3.7.0+
-invoker.goals = org.apache.maven.plugins:maven-wrapper-plugin:${project.version}:wrapper
\ No newline at end of file
+invoker.maven.version = 4-
+invoker.goals = org.apache.maven.plugins:maven-wrapper-plugin:${project.version}:wrapper
+invoker.buildResult = failure
\ No newline at end of file
diff --git a/src/it/projects/maven3/pom.xml b/src/it/projects/maven3/pom.xml
new file mode 100644
index 0000000..3a33965
--- /dev/null
+++ b/src/it/projects/maven3/pom.xml
@@ -0,0 +1,29 @@
+<?xml version='1.0' encoding='UTF-8'?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.plugins.it.wrapper</groupId>
+  <artifactId>maven3</artifactId>
+  <version>1.0.0-SNAPSHOT</version>
+  <packaging>pom</packaging>
+</project>
\ No newline at end of file
diff --git a/src/it/projects/maven3/verify.groovy b/src/it/projects/maven3/verify.groovy
new file mode 100644
index 0000000..55b1aeb
--- /dev/null
+++ b/src/it/projects/maven3/verify.groovy
@@ -0,0 +1,21 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+assert new File(basedir, 'build.log').any { it =~ /wrapperVersion not supported for Maven 3\..+, it must be at least 4\./  }
\ No newline at end of file
diff --git a/src/it/projects/mavenversion/invoker.properties b/src/it/projects/mavenversion/invoker.properties
index d880d6e..3125747 100644
--- a/src/it/projects/mavenversion/invoker.properties
+++ b/src/it/projects/mavenversion/invoker.properties
@@ -14,5 +14,5 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-invoker.maven.version = 3.7.0+
+invoker.maven.version = 4+
 invoker.goals = org.apache.maven.plugins:maven-wrapper-plugin:${project.version}:wrapper
\ No newline at end of file
diff --git a/src/it/projects/type_bin/invoker.properties b/src/it/projects/type_bin/invoker.properties
index d880d6e..3125747 100644
--- a/src/it/projects/type_bin/invoker.properties
+++ b/src/it/projects/type_bin/invoker.properties
@@ -14,5 +14,5 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-invoker.maven.version = 3.7.0+
+invoker.maven.version = 4+
 invoker.goals = org.apache.maven.plugins:maven-wrapper-plugin:${project.version}:wrapper
\ No newline at end of file
diff --git a/src/it/projects/type_source/invoker.properties b/src/it/projects/type_source/invoker.properties
index d880d6e..3125747 100644
--- a/src/it/projects/type_source/invoker.properties
+++ b/src/it/projects/type_source/invoker.properties
@@ -14,5 +14,5 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-invoker.maven.version = 3.7.0+
+invoker.maven.version = 4+
 invoker.goals = org.apache.maven.plugins:maven-wrapper-plugin:${project.version}:wrapper
\ No newline at end of file
diff --git a/src/it/projects/wrapperversion/test.properties b/src/it/projects/wrapperversion/test.properties
index e84426f..6738325 100644
--- a/src/it/projects/wrapperversion/test.properties
+++ b/src/it/projects/wrapperversion/test.properties
@@ -15,4 +15,4 @@
 # specific language governing permissions and limitations
 # under the License.
 
-wrapperVersion=3.7.0
\ No newline at end of file
+wrapperVersion=4.0.0
\ No newline at end of file
diff --git a/src/main/java/org/apache/maven/plugins/wrapper/WrapperMojo.java b/src/main/java/org/apache/maven/plugins/wrapper/WrapperMojo.java
index bf16a6c..2d3f3df 100644
--- a/src/main/java/org/apache/maven/plugins/wrapper/WrapperMojo.java
+++ b/src/main/java/org/apache/maven/plugins/wrapper/WrapperMojo.java
@@ -36,6 +36,7 @@ import org.apache.maven.artifact.Artifact;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.DefaultProjectBuildingRequest;
@@ -65,7 +66,7 @@ public class WrapperMojo extends AbstractMojo
     private String mavenVersion;
 
     /**
-     * The version of the wrapper, default value is the Runtime version of Maven, should be at least 3.7.0
+     * The version of the wrapper, default value is the Runtime version of Maven, should be at least 4
      */
     @Parameter( property = "wrapperVersion" )
     private String wrapperVersion;
@@ -115,12 +116,19 @@ public class WrapperMojo extends AbstractMojo
     private Map<String, UnArchiver> unarchivers;
     
     @Override
-    public void execute() throws MojoExecutionException
+    public void execute() throws MojoExecutionException, MojoFailureException
     {
+        String wrapperVersion = getVersion( this.wrapperVersion );
+        if ( wrapperVersion.startsWith( "3." ) )
+        {
+            throw new MojoFailureException( "wrapperVersion not supported for Maven " + wrapperVersion + ","
+                + " it must be at least 4." );
+        }
+        
         Artifact artifact;
         try
         {
-            artifact = download();
+            artifact = downloadWrapper( wrapperVersion );
         }
         catch ( ArtifactResolverException e )
         {
@@ -150,7 +158,7 @@ public class WrapperMojo extends AbstractMojo
         }
     }
     
-    private Artifact download()
+    private Artifact downloadWrapper( String wrapperVersion )
         throws ArtifactResolverException
     {
         ProjectBuildingRequest buildingRequest =
@@ -159,7 +167,7 @@ public class WrapperMojo extends AbstractMojo
         DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate();
         coordinate.setGroupId( WRAPPER_GROUP_ID );
         coordinate.setArtifactId( WRAPPER_ARTIFACT_ID );
-        coordinate.setVersion( getVersion( this.wrapperVersion ) ); 
+        coordinate.setVersion( wrapperVersion ); 
         coordinate.setClassifier( distributionType );
         coordinate.setExtension( WRAPPER_EXTENSION );
 
diff --git a/src/site/markdown/index.md.vm b/src/site/markdown/index.md.vm
index 52ac184..5751639 100644
--- a/src/site/markdown/index.md.vm
+++ b/src/site/markdown/index.md.vm
@@ -19,7 +19,7 @@ under the License.
 -->
 
 The Apache Maven Wrapper Plugin helps with downloading and unpacking the wrapper distribution 
- as introduced in Apache Maven 3.7.0
+ as introduced in Apache Maven 4
 
 Goals Overview
 --------------