You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2022/07/20 19:59:34 UTC

[maven-reporting-exec] 01/01: [MSHARED-1105] Replace Plexus Annotations with JSR 330 and upgrade relevant dependencies

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

michaelo pushed a commit to branch update-module
in repository https://gitbox.apache.org/repos/asf/maven-reporting-exec.git

commit 91dfb34ed92737b0101cf4668331130325e63a94
Author: Tamas Cservenak <ta...@cservenak.net>
AuthorDate: Sun Jul 10 18:39:23 2022 +0200

    [MSHARED-1105] Replace Plexus Annotations with JSR 330 and upgrade relevant dependencies
    
    * Drop m-shared-utils (was used only for StringUtils!!!)
    * Drop plexus container default and plexus annotations, migrate to JSR 330
    * Set plexus-classworld scope proper, IS USED in main
    * Upgrade Maven Project Info Reports Plugin to 3.4.0 in ITs
    
    This closes #14
---
 pom.xml                                            | 103 +++------------------
 .../exec/DefaultMavenPluginManagerHelper.java      |  20 +++-
 .../reporting/exec/DefaultMavenReportExecutor.java |  37 +++++---
 3 files changed, 55 insertions(+), 105 deletions(-)

diff --git a/pom.xml b/pom.xml
index 9a989e8..3141734 100644
--- a/pom.xml
+++ b/pom.xml
@@ -62,7 +62,7 @@
     <slf4jVersion>1.7.36</slf4jVersion>
     <project.build.outputTimestamp>2022-04-23T19:22:30Z</project.build.outputTimestamp>
     <sitePluginVersion>4.0.0-M2</sitePluginVersion>
-    <projectInfoReportsPluginVersion>3.3.0</projectInfoReportsPluginVersion>
+    <projectInfoReportsPluginVersion>3.4.0</projectInfoReportsPluginVersion>
   </properties>
 
   <dependencies>
@@ -103,20 +103,10 @@
       <artifactId>maven-settings-builder</artifactId>
       <version>${mavenVersion}</version>
     </dependency>
-    <dependency>
-      <groupId>org.apache.maven.shared</groupId>
-      <artifactId>maven-shared-utils</artifactId>
-      <version>3.3.4</version>
-    </dependency>
-    <dependency>
-      <groupId>org.codehaus.plexus</groupId>
-      <artifactId>plexus-component-annotations</artifactId>
-      <scope>provided</scope>
-    </dependency>
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-utils</artifactId>
-      <version>3.1.0</version><!-- do not upgrade to 3.2.0+ because it adds Xpp3Dom.getInputLocation(): see MSHARED-921 -->
+      <version>3.4.2</version>
     </dependency>
 
     <dependency>
@@ -130,13 +120,16 @@
       <artifactId>slf4j-api</artifactId>
       <version>${slf4jVersion}</version>
     </dependency>
+    <dependency>
+      <groupId>javax.inject</groupId>
+      <artifactId>javax.inject</artifactId>
+      <version>1</version>
+    </dependency>
 
-    <!-- Eclipse Aether for Maven 3.1+ -->
     <dependency>
       <groupId>org.eclipse.aether</groupId>
       <artifactId>aether-api</artifactId>
       <version>${aetherVersion}</version>
-      <optional>true</optional>
     </dependency>
     <dependency>
       <groupId>org.eclipse.aether</groupId>
@@ -144,6 +137,12 @@
       <version>${aetherVersion}</version>
     </dependency>
 
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-classworlds</artifactId>
+      <version>2.6.0</version>
+    </dependency>
+
     <!-- test -->
     <dependency>
       <groupId>org.apache.maven.plugin-testing</groupId>
@@ -188,13 +187,6 @@
       <scope>test</scope>
     </dependency>
 
-    <!-- Used actually in tests only, but if in test scope the transitive dep will be gone -->
-    <dependency>
-      <groupId>org.codehaus.plexus</groupId>
-      <artifactId>plexus-classworlds</artifactId>
-      <version>2.5.2</version>
-    </dependency>
-
     <dependency>
       <groupId>org.eclipse.aether</groupId>
       <artifactId>aether-connector-basic</artifactId>
@@ -225,46 +217,12 @@
 
   <build>
     <plugins>
-      <plugin><!-- shade Xpp3DomUtils that does not require Xpp3Dom.getInputLocation(): see MSHARED-921 -->
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-shade-plugin</artifactId>
-        <executions>
-          <execution>
-            <phase>package</phase>
-            <goals>
-              <goal>shade</goal>
-            </goals>
-            <configuration>
-              <artifactSet>
-                <includes>
-                  <include>org.codehaus.plexus:plexus-utils</include>
-                </includes>
-              </artifactSet>
-              <filters>
-                <filter>
-                  <artifact>org.codehaus.plexus:plexus-utils</artifact>
-                  <includes>
-                    <include>org/codehaus/plexus/util/xml/Xpp3DomUtils.class</include>
-                  </includes>
-                </filter>
-              </filters>
-              <relocations>
-                <relocation>
-                  <pattern>org.codehaus.plexus.util.xml.Xpp3DomUtils</pattern>
-                  <shadedPattern>org.apache.maven.reporting.exec.xml.Xpp3DomUtils</shadedPattern>
-                </relocation>
-              </relocations>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-surefire-plugin</artifactId>
         <configuration>
           <systemPropertyVariables>
             <localRepository>${settings.localRepository}</localRepository>
-            <mavenHome>${env.M2_HOME}</mavenHome>
           </systemPropertyVariables>
           <!--
           <forkMode>none</forkMode>
@@ -272,39 +230,8 @@
         </configuration>
       </plugin>
       <plugin>
-        <groupId>org.codehaus.plexus</groupId>
-        <artifactId>plexus-component-metadata</artifactId>
-        <executions>
-          <execution>
-            <goals>
-              <goal>generate-metadata</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-enforcer-plugin</artifactId>
-        <executions>
-          <execution>
-            <goals>
-              <goal>enforce</goal>
-            </goals>
-            <id>ensure-no-container-api</id>
-            <configuration>
-              <rules>
-                <bannedDependencies>
-                  <excludes>
-                    <exclude>org.codehaus.plexus:plexus-component-api</exclude>
-                    <exclude>org.codehaus.plexus:plexus-container-default</exclude>
-                  </excludes>
-                  <message>The new containers are not supported. You probably added a dependency that is missing the exclusions.</message>
-                </bannedDependencies>
-              </rules>
-              <fail>true</fail>
-            </configuration>
-          </execution>
-        </executions>
+        <groupId>org.eclipse.sisu</groupId>
+        <artifactId>sisu-maven-plugin</artifactId>
       </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
diff --git a/src/main/java/org/apache/maven/reporting/exec/DefaultMavenPluginManagerHelper.java b/src/main/java/org/apache/maven/reporting/exec/DefaultMavenPluginManagerHelper.java
index e24ae3b..8c68b00 100644
--- a/src/main/java/org/apache/maven/reporting/exec/DefaultMavenPluginManagerHelper.java
+++ b/src/main/java/org/apache/maven/reporting/exec/DefaultMavenPluginManagerHelper.java
@@ -19,6 +19,10 @@ package org.apache.maven.reporting.exec;
  * under the License.
  */
 
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
 import java.util.List;
 
 import org.apache.maven.execution.MavenSession;
@@ -29,22 +33,28 @@ import org.apache.maven.plugin.PluginContainerException;
 import org.apache.maven.plugin.PluginDescriptorParsingException;
 import org.apache.maven.plugin.PluginResolutionException;
 import org.apache.maven.plugin.descriptor.PluginDescriptor;
-import org.codehaus.plexus.component.annotations.Component;
-import org.codehaus.plexus.component.annotations.Requirement;
 import org.eclipse.aether.RepositorySystemSession;
 import org.eclipse.aether.graph.DependencyFilter;
 import org.eclipse.aether.repository.RemoteRepository;
 import org.eclipse.aether.util.filter.ExclusionsDependencyFilter;
 
+import static java.util.Objects.requireNonNull;
+
 /**
  * <p>DefaultMavenPluginManagerHelper class.</p>
  */
-@Component( role = MavenPluginManagerHelper.class )
+@Singleton
+@Named
 public class DefaultMavenPluginManagerHelper
     implements MavenPluginManagerHelper
 {
-    @Requirement
-    protected MavenPluginManager mavenPluginManager;
+    private final MavenPluginManager mavenPluginManager;
+
+    @Inject
+    public DefaultMavenPluginManagerHelper( MavenPluginManager mavenPluginManager )
+    {
+        this.mavenPluginManager = requireNonNull( mavenPluginManager );
+    }
 
     private DependencyFilter createExclusionsDependencyFilter( List<String> artifactIdsList )
     {
diff --git a/src/main/java/org/apache/maven/reporting/exec/DefaultMavenReportExecutor.java b/src/main/java/org/apache/maven/reporting/exec/DefaultMavenReportExecutor.java
index 3f57bc1..faa1abc 100644
--- a/src/main/java/org/apache/maven/reporting/exec/DefaultMavenReportExecutor.java
+++ b/src/main/java/org/apache/maven/reporting/exec/DefaultMavenReportExecutor.java
@@ -19,6 +19,10 @@ package org.apache.maven.reporting.exec;
  * under the License.
  */
 
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -46,15 +50,15 @@ import org.apache.maven.plugin.version.PluginVersionResolver;
 import org.apache.maven.plugin.version.PluginVersionResult;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.reporting.MavenReport;
-import org.apache.maven.shared.utils.StringUtils;
-import org.codehaus.plexus.component.annotations.Component;
-import org.codehaus.plexus.component.annotations.Requirement;
 import org.codehaus.plexus.configuration.PlexusConfiguration;
+import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.xml.Xpp3Dom;
 import org.codehaus.plexus.util.xml.Xpp3DomUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static java.util.Objects.requireNonNull;
+
 /**
  * <p>
  * This component will build some {@link MavenReportExecution} from {@link MavenReportExecutorRequest}. If a
@@ -95,23 +99,20 @@ import org.slf4j.LoggerFactory;
  *
  * @author Olivier Lamy
  */
-@Component( role = MavenReportExecutor.class )
+@Singleton
+@Named
 public class DefaultMavenReportExecutor
     implements MavenReportExecutor
 {
     private static final Logger LOGGER = LoggerFactory.getLogger( DefaultMavenReportExecutor.class );
 
-    @Requirement
-    protected MavenPluginManager mavenPluginManager;
+    private final MavenPluginManager mavenPluginManager;
 
-    @Requirement
-    protected MavenPluginManagerHelper mavenPluginManagerHelper;
+    private final MavenPluginManagerHelper mavenPluginManagerHelper;
 
-    @Requirement
-    protected LifecycleExecutor lifecycleExecutor;
+    private final LifecycleExecutor lifecycleExecutor;
 
-    @Requirement
-    protected PluginVersionResolver pluginVersionResolver;
+    private final PluginVersionResolver pluginVersionResolver;
 
     private static final List<String> IMPORTS = Arrays.asList( "org.apache.maven.reporting.MavenReport",
                                                                "org.apache.maven.reporting.MavenMultiPageReport",
@@ -129,6 +130,18 @@ public class DefaultMavenReportExecutor
     private static final List<String> EXCLUDES = Arrays.asList( "doxia-site-renderer", "doxia-sink-api",
                                                                 "maven-reporting-api" );
 
+    @Inject
+    public DefaultMavenReportExecutor( MavenPluginManager mavenPluginManager,
+                                       MavenPluginManagerHelper mavenPluginManagerHelper,
+                                       LifecycleExecutor lifecycleExecutor,
+                                       PluginVersionResolver pluginVersionResolver )
+    {
+        this.mavenPluginManager = requireNonNull( mavenPluginManager );
+        this.mavenPluginManagerHelper = requireNonNull( mavenPluginManagerHelper );
+        this.lifecycleExecutor = requireNonNull( lifecycleExecutor );
+        this.pluginVersionResolver = requireNonNull( pluginVersionResolver );
+    }
+
     @Override
     public List<MavenReportExecution> buildMavenReports( MavenReportExecutorRequest mavenReportExecutorRequest )
         throws MojoExecutionException