You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by cs...@apache.org on 2022/07/12 14:18:32 UTC

[maven-rar-plugin] 01/01: [MRAR-87] Upgrade to Maven 3.2.5 and drop legacy

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

cstamas pushed a commit to branch mrar-87
in repository https://gitbox.apache.org/repos/asf/maven-rar-plugin.git

commit adf575023372561724b2b920a17f70b30c89d872
Author: Tamas Cservenak <ta...@cservenak.net>
AuthorDate: Tue Jul 12 16:18:04 2022 +0200

    [MRAR-87] Upgrade to Maven 3.2.5 and drop legacy
---
 pom.xml                                            |  45 ++++++---
 .../META-INF/plexus/components.xml                 |  86 -----------------
 .../plugins/rar/internal/pluginInfo.properties     |  21 +++++
 .../maven/plugins/rar/internal/PluginInfo.java     |  83 ++++++++++++++++
 .../plugins/rar/internal/RarArtifactHandler.java   |  41 ++++++++
 .../rar/internal/RarLifecycleMappingProvider.java  | 104 +++++++++++++++++++++
 6 files changed, 282 insertions(+), 98 deletions(-)

diff --git a/pom.xml b/pom.xml
index 61711e2..c59b927 100644
--- a/pom.xml
+++ b/pom.xml
@@ -25,8 +25,8 @@ under the License.
   <parent>
     <artifactId>maven-plugins</artifactId>
     <groupId>org.apache.maven.plugins</groupId>
-    <version>34</version>
-    <relativePath>../../pom/maven/maven-plugins/pom.xml</relativePath>
+    <version>36</version>
+    <relativePath />
   </parent>
 
   <artifactId>maven-rar-plugin</artifactId>
@@ -72,8 +72,8 @@ under the License.
   </contributors>
   
   <properties>
-    <mavenVersion>3.0</mavenVersion>
     <javaVersion>7</javaVersion>
+    <mavenVersion>3.2.5</mavenVersion>
     <project.build.outputTimestamp>2020-04-07T21:04:00Z</project.build.outputTimestamp>
   </properties>  
 
@@ -82,16 +82,36 @@ under the License.
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-plugin-api</artifactId>
       <version>${mavenVersion}</version>
+      <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-core</artifactId>
       <version>${mavenVersion}</version>
+      <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-artifact</artifactId>
       <version>${mavenVersion}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-model</artifactId>
+      <version>${mavenVersion}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-settings</artifactId>
+      <version>${mavenVersion}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>javax.inject</groupId>
+      <artifactId>javax.inject</artifactId>
+      <version>1</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.plugin-tools</groupId>
@@ -101,17 +121,12 @@ under the License.
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-interpolation</artifactId>
-      <version>1.25</version>
+      <version>1.26</version>
     </dependency>
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-utils</artifactId>
-      <version>3.3.0</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven.shared</groupId>
-      <artifactId>maven-shared-utils</artifactId>
-      <version>3.3.3</version>
+      <version>3.3.1</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.shared</groupId>
@@ -126,7 +141,7 @@ under the License.
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-archiver</artifactId>
-      <version>3.5.1</version>
+      <version>3.5.2</version>
     </dependency>
     <dependency>
       <groupId>junit</groupId>
@@ -143,7 +158,7 @@ under the License.
     <dependency>
       <groupId>org.apache.maven.plugin-testing</groupId>
       <artifactId>maven-plugin-testing-harness</artifactId>
-      <version>2.1</version>
+      <version>3.3.0</version>
       <scope>test</scope>
     </dependency>
   </dependencies>
@@ -171,6 +186,12 @@ under the License.
         </plugin>
       </plugins>
     </pluginManagement>
+    <plugins>
+      <plugin>
+        <groupId>org.eclipse.sisu</groupId>
+        <artifactId>sisu-maven-plugin</artifactId>
+      </plugin>
+    </plugins>
   </build>
 
   <profiles>
diff --git a/src/main/filtered-resources/META-INF/plexus/components.xml b/src/main/filtered-resources/META-INF/plexus/components.xml
deleted file mode 100644
index 18f1bc0..0000000
--- a/src/main/filtered-resources/META-INF/plexus/components.xml
+++ /dev/null
@@ -1,86 +0,0 @@
-<?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.
--->
-
-<component-set>
-  <components>
-    <!--
-     | RAR
-     |-->
-    <component>
-      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
-      <role-hint>rar</role-hint>
-      <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
-      <configuration>
-        <type>rar</type>
-        <includesDependencies>true</includesDependencies>
-        <language>java</language>
-        <addedToClasspath>false</addedToClasspath>
-      </configuration>
-    </component>
-
-    <!--
-      | Defining the phases with their appropriate plugins
-      ! and versions which will be executed during the 'default'
-      ! life cycle.
-    -->
-    <component>
-      <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
-      <role-hint>rar</role-hint>
-      <implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
-      <configuration>
-        <lifecycles>
-          <lifecycle>
-            <id>default</id>
-            <!-- START SNIPPET: rar-lifecycle -->
-            <phases>
-              <process-resources>
-                org.apache.maven.plugins:maven-resources-plugin:3.0.2:resources
-              </process-resources>
-              <compile>
-                org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile
-              </compile>
-              <process-test-resources>
-                org.apache.maven.plugins:maven-resources-plugin:3.0.2:testResources
-              </process-test-resources>
-              <test-compile>
-                org.apache.maven.plugins:maven-compiler-plugin:3.5.1:testCompile
-              </test-compile>
-              <test>
-                org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test
-              </test>
-              <package>
-                org.apache.maven.plugins:maven-rar-plugin:${project.version}:rar
-              </package>
-              <install>
-                org.apache.maven.plugins:maven-install-plugin:2.5.2:install
-              </install>
-              <deploy>
-                org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy
-              </deploy>
-            </phases>
-            <!-- END SNIPPET: rar-lifecycle -->
-          </lifecycle>
-        </lifecycles>
-      </configuration>
-    </component>
-
-  </components>
-</component-set>
diff --git a/src/main/filtered-resources/org/apache/maven/plugins/rar/internal/pluginInfo.properties b/src/main/filtered-resources/org/apache/maven/plugins/rar/internal/pluginInfo.properties
new file mode 100644
index 0000000..070e3af
--- /dev/null
+++ b/src/main/filtered-resources/org/apache/maven/plugins/rar/internal/pluginInfo.properties
@@ -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.
+
+# to make it work even in tests
+groupId=${project.groupId}
+artifactId=${project.artifactId}
+version=${project.version}
diff --git a/src/main/java/org/apache/maven/plugins/rar/internal/PluginInfo.java b/src/main/java/org/apache/maven/plugins/rar/internal/PluginInfo.java
new file mode 100644
index 0000000..f8a51d9
--- /dev/null
+++ b/src/main/java/org/apache/maven/plugins/rar/internal/PluginInfo.java
@@ -0,0 +1,83 @@
+package org.apache.maven.plugins.rar.internal;
+
+/*
+ * 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.
+ */
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+/**
+ * Plugin info helper.
+ */
+public final class PluginInfo
+{
+    private final String groupId;
+
+    private final String artifactId;
+
+    private final String version;
+
+    public PluginInfo( String groupId, String artifactId, String version )
+    {
+        this.groupId = groupId;
+        this.artifactId = artifactId;
+        this.version = version;
+    }
+
+    public String getGroupId()
+    {
+        return groupId;
+    }
+
+    public String getArtifactId()
+    {
+        return artifactId;
+    }
+
+    public String getVersion()
+    {
+        return version;
+    }
+
+    public static PluginInfo get()
+    {
+        return PLUGIN_INFO;
+    }
+
+    private static final PluginInfo PLUGIN_INFO;
+
+    static
+    {
+        Properties properties = new Properties();
+        try ( InputStream inputStream = PluginInfo.class.getResourceAsStream( "pluginInfo.properties" ) )
+        {
+            properties.load( inputStream );
+        }
+        catch ( IOException e )
+        {
+            // what here?
+        }
+        PLUGIN_INFO = new PluginInfo(
+                properties.getProperty( "groupId", "unknown" ),
+                properties.getProperty( "artifactId", "unknown" ),
+                properties.getProperty( "version", "unknown" )
+        );
+    }
+}
diff --git a/src/main/java/org/apache/maven/plugins/rar/internal/RarArtifactHandler.java b/src/main/java/org/apache/maven/plugins/rar/internal/RarArtifactHandler.java
new file mode 100644
index 0000000..405cc76
--- /dev/null
+++ b/src/main/java/org/apache/maven/plugins/rar/internal/RarArtifactHandler.java
@@ -0,0 +1,41 @@
+package org.apache.maven.plugins.rar.internal;
+
+/*
+ * 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.
+ */
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
+
+/**
+ * RAR Artifact Handler.
+ */
+@Singleton
+@Named( "rar" )
+public class RarArtifactHandler extends DefaultArtifactHandler
+{
+    public RarArtifactHandler()
+    {
+        super( "rar" );
+        setIncludesDependencies( true );
+        setLanguage( "java" );
+        setAddedToClasspath( false );
+    }
+}
diff --git a/src/main/java/org/apache/maven/plugins/rar/internal/RarLifecycleMappingProvider.java b/src/main/java/org/apache/maven/plugins/rar/internal/RarLifecycleMappingProvider.java
new file mode 100644
index 0000000..3a22937
--- /dev/null
+++ b/src/main/java/org/apache/maven/plugins/rar/internal/RarLifecycleMappingProvider.java
@@ -0,0 +1,104 @@
+package org.apache.maven.plugins.rar.internal;
+
+/*
+ * 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.
+ */
+
+import javax.inject.Named;
+import javax.inject.Provider;
+import javax.inject.Singleton;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.lifecycle.mapping.Lifecycle;
+import org.apache.maven.lifecycle.mapping.LifecycleMapping;
+
+/**
+ * {@code rar} packaging plugins bindings provider for {@code default} lifecycle.
+ */
+@Named( "rar" )
+@Singleton
+public final class RarLifecycleMappingProvider
+        implements Provider<LifecycleMapping>
+{
+    private static final String[] BINDINGS =
+            {
+                    "process-resources", "org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources",
+                    "compile", "org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile",
+                    "process-test-resources", "org.apache.maven.plugins:maven-resources-plugin:3.2.0:testResources",
+                    "test-compile", "org.apache.maven.plugins:maven-compiler-plugin:3.8.1:testCompile",
+                    "test", "org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test",
+                    "package", "org.apache.maven.plugins:maven-rar-plugin:" + PluginInfo.get().getVersion() + ":rar",
+                    "install", "org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install",
+                    "deploy", "org.apache.maven.plugins:maven-deploy-plugin:3.0.0-M1:deploy"
+            };
+
+    private final Lifecycle defaultLifecycle;
+
+    private final LifecycleMapping lifecycleMapping;
+
+    public RarLifecycleMappingProvider()
+    {
+        HashMap<String, String> bindings = new HashMap<>();
+        for ( int i = 0; i < BINDINGS.length; i = i + 2 )
+        {
+            bindings.put( BINDINGS[i], BINDINGS[i + 1] );
+        }
+        this.defaultLifecycle = new Lifecycle();
+        this.defaultLifecycle.setId( "default" );
+        this.defaultLifecycle.setPhases( bindings );
+
+        this.lifecycleMapping = new LifecycleMapping()
+        {
+            @Override
+            public Map<String, Lifecycle> getLifecycles()
+            {
+                return Collections.singletonMap( "default", defaultLifecycle );
+            }
+
+            @Override
+            public List<String> getOptionalMojos( String lifecycle )
+            {
+                return null;
+            }
+
+            @Override
+            public Map<String, String> getPhases( String lifecycle )
+            {
+                if ( "default".equals( lifecycle ) )
+                {
+                    return defaultLifecycle.getPhases();
+                }
+                else
+                {
+                    return null;
+                }
+            }
+        };
+
+    }
+
+    @Override
+    public LifecycleMapping get()
+    {
+        return lifecycleMapping;
+    }
+}