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

elharo pushed a commit to branch guice
in repository https://gitbox.apache.org/repos/asf/maven-pdf-plugin.git

commit 3179db3cfa3f044d2fd482409ce66b962b60be9e
Author: Elliotte Rusty Harold <elh...@ibiblio.org>
AuthorDate: Wed Dec 11 08:41:15 2024 -0500

    Guice
---
 .../apache/maven/plugins/pdf/PdfAggregateMojo.java | 22 ++++-
 .../java/org/apache/maven/plugins/pdf/PdfMojo.java | 93 ++++++++++++----------
 2 files changed, 72 insertions(+), 43 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/pdf/PdfAggregateMojo.java 
b/src/main/java/org/apache/maven/plugins/pdf/PdfAggregateMojo.java
index 2f969dd..e7d6502 100644
--- a/src/main/java/org/apache/maven/plugins/pdf/PdfAggregateMojo.java
+++ b/src/main/java/org/apache/maven/plugins/pdf/PdfAggregateMojo.java
@@ -18,6 +18,9 @@
  */
 package org.apache.maven.plugins.pdf;
 
+import javax.inject.Inject;
+import javax.inject.Named;
+
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayDeque;
@@ -29,26 +32,30 @@ import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 
+import org.apache.maven.doxia.Doxia;
+import org.apache.maven.doxia.docrenderer.pdf.PdfRenderer;
 import org.apache.maven.doxia.document.DocumentModel;
 import org.apache.maven.doxia.document.DocumentTOC;
 import org.apache.maven.doxia.document.DocumentTOCItem;
+import org.apache.maven.doxia.siterenderer.Renderer;
+import org.apache.maven.doxia.tools.SiteTool;
 import org.apache.maven.model.Reporting;
 import org.apache.maven.plugins.annotations.Execute;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.plugins.annotations.ResolutionScope;
 import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.i18n.I18N;
 import org.codehaus.plexus.util.FileUtils;
 
 /**
- * Forks {@code pdf} goal then aggregates PDF content from all modules in the 
reactor.
+ * Forks {@code pdf} goal, then aggregates PDF content from all modules in the 
reactor.
  *
  * @author anthony-beurive
  * @since 1.5
  */
 @Mojo(name = "aggregate", aggregator = true, requiresDependencyResolution = 
ResolutionScope.TEST, threadSafe = true)
 @Execute(goal = "pdf")
-// TODO should extend AbstractPdfMojo, but requires extensive refactoring
 public class PdfAggregateMojo extends PdfMojo {
     /**
      * The reactor projects.
@@ -68,6 +75,17 @@ public class PdfAggregateMojo extends PdfMojo {
     @Parameter(defaultValue = "${project.build.directory}/pdf-aggregate", 
required = true)
     private File aggregatedWorkingDirectory;
 
+    @Inject
+    public PdfAggregateMojo(
+            @Named("fo") PdfRenderer foRenderer,
+            I18N i18n,
+            @Named("itext") PdfRenderer itextRenderer,
+            Renderer siteRenderer,
+            SiteTool siteTool,
+            Doxia doxia) {
+        super(foRenderer, i18n, itextRenderer, siteRenderer, siteTool, doxia);
+    }
+
     protected File getOutputDirectory() {
         return aggregatedOutputDirectory;
     }
diff --git a/src/main/java/org/apache/maven/plugins/pdf/PdfMojo.java 
b/src/main/java/org/apache/maven/plugins/pdf/PdfMojo.java
index ac099f4..8678f48 100644
--- a/src/main/java/org/apache/maven/plugins/pdf/PdfMojo.java
+++ b/src/main/java/org/apache/maven/plugins/pdf/PdfMojo.java
@@ -18,6 +18,9 @@
  */
 package org.apache.maven.plugins.pdf;
 
+import javax.inject.Inject;
+import javax.inject.Named;
+
 import java.io.File;
 import java.io.IOException;
 import java.io.Reader;
@@ -61,7 +64,6 @@ import org.apache.maven.execution.MavenSession;
 import org.apache.maven.model.ReportPlugin;
 import org.apache.maven.model.Reporting;
 import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.plugins.annotations.ResolutionScope;
@@ -99,25 +101,6 @@ public class PdfMojo extends AbstractPdfMojo implements 
Contextualizable {
      * The vm line separator
      */
     private static final String EOL = System.getProperty("line.separator");
-
-    /**
-     * FO Document Renderer.
-     */
-    @Component(hint = "fo")
-    private PdfRenderer foRenderer;
-
-    /**
-     * Internationalization.
-     */
-    @Component
-    private I18N i18n;
-
-    /**
-     * IText Document Renderer.
-     */
-    @Component(hint = "itext")
-    private PdfRenderer itextRenderer;
-
     /**
      * A comma separated list of locales supported by Maven.
      * The first valid token will be the default Locale for this instance of 
the Java Virtual Machine.
@@ -125,26 +108,6 @@ public class PdfMojo extends AbstractPdfMojo implements 
Contextualizable {
     @Parameter(property = "locales")
     private String locales;
 
-    /**
-     * Site renderer.
-     */
-    @Component
-    private Renderer siteRenderer;
-
-    /**
-     * SiteTool.
-     */
-    @Component
-    private SiteTool siteTool;
-
-    /**
-     * Doxia.
-     *
-     * @since 1.1
-     */
-    @Component
-    private Doxia doxia;
-
     /**
      * The Maven Project Object.
      */
@@ -233,7 +196,7 @@ public class PdfMojo extends AbstractPdfMojo implements 
Contextualizable {
     private String pluginVersion;
 
     /**
-     * If <code>true</false>, generate all Maven reports defined in 
<code>${project.reporting}</code> and append
+     * If <code>true</code>, generate all Maven reports defined in 
<code>${project.reporting}</code> and append
      * them as a new entry in the TOC (Table Of Contents).
      * <b>Note</b>: Including the report generation could fail the PDF 
generation or increase the build time.
      *
@@ -319,6 +282,54 @@ public class PdfMojo extends AbstractPdfMojo implements 
Contextualizable {
      */
     private PlexusContainer container;
 
+    /**
+     * FO Document Renderer.
+     */
+    private final PdfRenderer foRenderer;
+
+    /**
+     * Internationalization.
+     */
+    private final I18N i18n;
+
+    /**
+     * IText Document Renderer.
+     */
+    private final PdfRenderer itextRenderer;
+
+    /**
+     * Site renderer.
+     */
+    private final Renderer siteRenderer;
+
+    /**
+     * SiteTool.
+     */
+    private final SiteTool siteTool;
+
+    /**
+     * Doxia.
+     *
+     * @since 1.1
+     */
+    private final Doxia doxia;
+
+    @Inject
+    public PdfMojo(
+            @Named("fo") PdfRenderer foRenderer,
+            I18N i18n,
+            @Named("itext") PdfRenderer itextRenderer,
+            Renderer siteRenderer,
+            SiteTool siteTool,
+            Doxia doxia) {
+        this.foRenderer = foRenderer;
+        this.i18n = i18n;
+        this.itextRenderer = itextRenderer;
+        this.siteRenderer = siteRenderer;
+        this.siteTool = siteTool;
+        this.doxia = doxia;
+    }
+
     /** {@inheritDoc} */
     public void execute() throws MojoExecutionException {
         init();

Reply via email to