You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sj...@apache.org on 2026/10/10 08:43:47 UTC

(maven-reporting-impl) branch master updated: Inject map of sinkFactory instead of container lookup

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

slawekjaranowski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-reporting-impl.git


The following commit(s) were added to refs/heads/master by this push:
     new 2f63878  Inject map of sinkFactory instead of container lookup
2f63878 is described below

commit 2f63878284207ea8331f1071a0fd40c56e2fbeac
Author: Slawomir Jaranowski <s....@gmail.com>
AuthorDate: Fri Oct 9 17:19:24 2026 +0200

    Inject map of sinkFactory instead of container lookup
    
    We can drop one more dependency.
    
    # Conflicts:
    #       src/main/java/org/apache/maven/reporting/AbstractMavenReport.java
---
 pom.xml                                             |  4 ++--
 .../apache/maven/reporting/AbstractMavenReport.java | 21 ++++++++++++---------
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/pom.xml b/pom.xml
index 4ea9474..e19f0c2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -169,8 +169,8 @@
       <version>${resolverVersion}</version>
     </dependency>
     <dependency>
-      <groupId>org.eclipse.sisu</groupId>
-      <artifactId>org.eclipse.sisu.plexus</artifactId>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-utils</artifactId>
     </dependency>
 
     <!-- test -->
diff --git a/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java b/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java
index b7aa9a0..2c1e056 100644
--- a/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java
+++ b/src/main/java/org/apache/maven/reporting/AbstractMavenReport.java
@@ -57,8 +57,6 @@ import org.apache.maven.plugin.MojoExecution;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.PlexusContainer;
-import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 import org.codehaus.plexus.util.PathTool;
 import org.eclipse.aether.RepositorySystemSession;
 import org.eclipse.aether.repository.RemoteRepository;
@@ -170,6 +168,13 @@ public abstract class AbstractMavenReport extends AbstractMojo implements MavenM
     /** The current sink to use */
     private Sink sink;
 
+    /**
+     * All available sink factories, keyed by their name (e.g. "fml", "xdoc", "xml", "html", "pdf", ...).
+     * This is used to look up the sink factory to use for the configured output format.
+     */
+    @Inject
+    private Map<String, SinkFactory> sinkFactoryMap;
+
     /** The sink factory to use */
     private SinkFactory sinkFactory;
 
@@ -182,9 +187,6 @@ public abstract class AbstractMavenReport extends AbstractMojo implements MavenM
     @Parameter(property = "output.format")
     protected String outputFormat;
 
-    @Inject
-    private PlexusContainer container;
-
     /**
      * SiteTool.
      */
@@ -233,11 +235,12 @@ public abstract class AbstractMavenReport extends AbstractMojo implements MavenM
             getLog().info("Rendering report as " + outputFormat + " markup to " + relativeOutput.resolve(filename));
 
             try {
-                sinkFactory = container.lookup(SinkFactory.class, outputFormat);
+                sinkFactory = sinkFactoryMap.get(outputFormat);
+                if (sinkFactory == null) {
+                    throw new MojoExecutionException(
+                            "Cannot find SinkFactory for Doxia output format: " + outputFormat);
+                }
                 sink = sinkFactory.createSink(new File(getOutputDirectory()), filename);
-            } catch (ComponentLookupException cle) {
-                throw new MojoExecutionException(
-                        "Cannot find SinkFactory for Doxia output format: " + outputFormat, cle);
             } catch (IOException ioe) {
                 throw new MojoExecutionException("Cannot create sink to " + new File(outputDirectory, filename), ioe);
             }