From 69c1ba77eafbccba24c0926e7283a12fdd0706cc Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Tue, 19 Nov 2024 12:31:05 +0000 Subject: [PATCH] Migrate from Plexus to Sisu Guice (#341) * Migrate from Plexus to Sisu Guice * no inject on abstract classes= --- pom.xml | 8 ++++ .../javadoc/AbstractFixJavadocMojo.java | 6 ++- .../plugins/javadoc/AbstractJavadocMojo.java | 31 ++++++++------ .../javadoc/AggregatorJavadocJarMojo.java | 37 +++++++++++++++++ .../AggregatorJavadocNoForkReport.java | 34 ++++++++++++++- .../javadoc/AggregatorJavadocReport.java | 29 +++++++++++++ .../javadoc/AggregatorTestJavadocJarMojo.java | 37 +++++++++++++++++ .../AggregatorTestJavadocNoForkReport.java | 31 +++++++++++++- .../javadoc/AggregatorTestJavadocReport.java | 29 +++++++++++++ .../maven/plugins/javadoc/FixJavadocMojo.java | 9 +++- .../maven/plugins/javadoc/JavadocJarMojo.java | 37 +++++++++++++++-- .../plugins/javadoc/JavadocNoForkReport.java | 33 ++++++++++++++- .../maven/plugins/javadoc/JavadocReport.java | 28 +++++++++++++ .../maven/plugins/javadoc/JavadocUtil.java | 2 +- .../plugins/javadoc/ResourcesBundleMojo.java | 35 ++++++++++++++-- .../plugins/javadoc/TestFixJavadocMojo.java | 9 ++++ .../plugins/javadoc/TestJavadocJarMojo.java | 41 ++++++++++++++++++- .../javadoc/TestJavadocNoForkReport.java | 32 ++++++++++++++- .../plugins/javadoc/TestJavadocReport.java | 30 +++++++++++++- .../javadoc/TestResourcesBundleMojo.java | 33 +++++++++++++++ .../javadoc/AbstractJavadocMojoTest.java | 2 +- .../plugins/javadoc/FixJavadocMojoTest.java | 8 ++-- 22 files changed, 504 insertions(+), 37 deletions(-) diff --git a/pom.xml b/pom.xml index ea1c614bc..4effa2793 100644 --- a/pom.xml +++ b/pom.xml @@ -231,6 +231,14 @@ under the License. 3.4.0 + + + org.eclipse.sisu + org.eclipse.sisu.plexus + 0.9.0.M3 + test + + org.apache.maven.doxia diff --git a/src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java index 06331fd9a..1a7f7e7a2 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractFixJavadocMojo.java @@ -77,7 +77,6 @@ import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; import org.apache.maven.settings.Settings; @@ -219,9 +218,12 @@ public abstract class AbstractFixJavadocMojo extends AbstractMojo { /** * Input handler, needed for command line handling. */ - @Component private InputHandler inputHandler; + public AbstractFixJavadocMojo(InputHandler inputHandler) { + this.inputHandler = inputHandler; + } + // ---------------------------------------------------------------------- // Mojo parameters // ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java index 98e70a8c1..1eafcbe9e 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java @@ -74,7 +74,6 @@ import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.javadoc.options.BootclasspathArtifact; import org.apache.maven.plugins.javadoc.options.DocletArtifact; @@ -205,7 +204,7 @@ public abstract class AbstractJavadocMojo extends AbstractMojo { protected static final String FILES_FILE_NAME = "files"; /** - * Default css file name, used as file name in the output directory for the temporary custom stylesheet file + * Default CSS file name, used as file name in the output directory for the temporary custom stylesheet file * loaded from classloader resources. */ private static final String DEFAULT_CSS_NAME = "stylesheet.css"; @@ -260,9 +259,6 @@ public abstract class AbstractJavadocMojo extends AbstractMojo { */ private static final JavaVersion SINCE_JAVADOC_1_8 = JavaVersion.parse("1.8"); - /** - * - */ private static final JavaVersion JAVA_VERSION = JavaVersion.JAVA_SPECIFICATION_VERSION; // ---------------------------------------------------------------------- @@ -272,7 +268,6 @@ public abstract class AbstractJavadocMojo extends AbstractMojo { /** * SiteTool. */ - @Component protected SiteTool siteTool; /** @@ -280,19 +275,15 @@ public abstract class AbstractJavadocMojo extends AbstractMojo { * * @since 2.5 */ - @Component private ArchiverManager archiverManager; - @Component private ResourceResolver resourceResolver; - @Component private RepositorySystem repoSystem; @Parameter(defaultValue = "${repositorySystemSession}", readonly = true, required = true) private RepositorySystemSession repoSession; - @Component private ArtifactHandlerManager artifactHandlerManager; /** @@ -300,13 +291,27 @@ public abstract class AbstractJavadocMojo extends AbstractMojo { * * @since 3.0 */ - @Component private ProjectBuilder mavenProjectBuilder; - /** */ - @Component private ToolchainManager toolchainManager; + public AbstractJavadocMojo( + SiteTool siteTool, + ArchiverManager archiverManager, + ResourceResolver resourceResolver, + RepositorySystem repoSystem, + ArtifactHandlerManager artifactHandlerManager, + ProjectBuilder mavenProjectBuilder, + ToolchainManager toolchainManager) { + this.siteTool = siteTool; + this.archiverManager = archiverManager; + this.resourceResolver = resourceResolver; + this.repoSystem = repoSystem; + this.artifactHandlerManager = artifactHandlerManager; + this.mavenProjectBuilder = mavenProjectBuilder; + this.toolchainManager = toolchainManager; + } + final LocationManager locationManager = new LocationManager(); // ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/maven/plugins/javadoc/AggregatorJavadocJarMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/AggregatorJavadocJarMojo.java index 5680c8a43..36acbe862 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/AggregatorJavadocJarMojo.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/AggregatorJavadocJarMojo.java @@ -18,10 +18,21 @@ */ package org.apache.maven.plugins.javadoc; +import javax.inject.Inject; + +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.doxia.tools.SiteTool; import org.apache.maven.plugins.annotations.Execute; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.plugins.javadoc.resolver.ResourceResolver; +import org.apache.maven.project.MavenProjectHelper; +import org.apache.maven.project.ProjectBuilder; +import org.apache.maven.toolchain.ToolchainManager; +import org.codehaus.plexus.archiver.jar.JarArchiver; +import org.codehaus.plexus.archiver.manager.ArchiverManager; +import org.eclipse.aether.RepositorySystem; /** *

Bundles the Javadoc documentation for main Java code in an aggregator project into a jar @@ -39,6 +50,32 @@ requiresDependencyResolution = ResolutionScope.COMPILE) @Execute(phase = LifecyclePhase.COMPILE) public class AggregatorJavadocJarMojo extends JavadocJarMojo { + + // CHECKSTYLE_OFF: ParameterNumber + @Inject + public AggregatorJavadocJarMojo( + MavenProjectHelper projectHelper, + JarArchiver jarArchiver, + SiteTool siteTool, + ArchiverManager archiverManager, + ResourceResolver resourceResolver, + RepositorySystem repoSystem, + ArtifactHandlerManager artifactHandlerManager, + ProjectBuilder mavenProjectBuilder, + ToolchainManager toolchainManager) { + super( + projectHelper, + jarArchiver, + siteTool, + archiverManager, + resourceResolver, + repoSystem, + artifactHandlerManager, + mavenProjectBuilder, + toolchainManager); + } + // CHECKSTYLE_ON: ParameterNumber + @Override protected boolean isAggregator() { return true; diff --git a/src/main/java/org/apache/maven/plugins/javadoc/AggregatorJavadocNoForkReport.java b/src/main/java/org/apache/maven/plugins/javadoc/AggregatorJavadocNoForkReport.java index 2a4be07e6..f062baa8f 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/AggregatorJavadocNoForkReport.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/AggregatorJavadocNoForkReport.java @@ -18,10 +18,19 @@ */ package org.apache.maven.plugins.javadoc; +import javax.inject.Inject; + +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.doxia.tools.SiteTool; import org.apache.maven.plugins.annotations.Execute; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.plugins.javadoc.resolver.ResourceResolver; +import org.apache.maven.project.ProjectBuilder; +import org.apache.maven.toolchain.ToolchainManager; +import org.codehaus.plexus.archiver.manager.ArchiverManager; +import org.eclipse.aether.RepositorySystem; /** * Generates documentation for the Java code in an aggregator project using the standard @@ -31,4 +40,27 @@ */ @Mojo(name = "aggregate-no-fork", requiresDependencyResolution = ResolutionScope.COMPILE) @Execute(phase = LifecyclePhase.NONE) -public class AggregatorJavadocNoForkReport extends AggregatorJavadocReport {} +public class AggregatorJavadocNoForkReport extends AggregatorJavadocReport { + + // CHECKSTYLE_OFF: ParameterNumber + @Inject + public AggregatorJavadocNoForkReport( + SiteTool siteTool, + ArchiverManager archiverManager, + ResourceResolver resourceResolver, + RepositorySystem repoSystem, + ArtifactHandlerManager artifactHandlerManager, + ProjectBuilder mavenProjectBuilder, + ToolchainManager toolchainManager) { + super( + siteTool, + archiverManager, + resourceResolver, + repoSystem, + artifactHandlerManager, + mavenProjectBuilder, + toolchainManager); + } + // CHECKSTYLE_ON: ParameterNumber + +} diff --git a/src/main/java/org/apache/maven/plugins/javadoc/AggregatorJavadocReport.java b/src/main/java/org/apache/maven/plugins/javadoc/AggregatorJavadocReport.java index 642c3ae18..4bd99e8d8 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/AggregatorJavadocReport.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/AggregatorJavadocReport.java @@ -18,10 +18,19 @@ */ package org.apache.maven.plugins.javadoc; +import javax.inject.Inject; + +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.doxia.tools.SiteTool; import org.apache.maven.plugins.annotations.Execute; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.plugins.javadoc.resolver.ResourceResolver; +import org.apache.maven.project.ProjectBuilder; +import org.apache.maven.toolchain.ToolchainManager; +import org.codehaus.plexus.archiver.manager.ArchiverManager; +import org.eclipse.aether.RepositorySystem; /** *

Generates documentation for the Java code in an aggregator project using the standard @@ -35,6 +44,26 @@ @Mojo(name = "aggregate", aggregator = true, requiresDependencyResolution = ResolutionScope.COMPILE) @Execute(phase = LifecyclePhase.COMPILE) public class AggregatorJavadocReport extends JavadocReport { + + @Inject + public AggregatorJavadocReport( + SiteTool siteTool, + ArchiverManager archiverManager, + ResourceResolver resourceResolver, + RepositorySystem repoSystem, + ArtifactHandlerManager artifactHandlerManager, + ProjectBuilder mavenProjectBuilder, + ToolchainManager toolchainManager) { + super( + siteTool, + archiverManager, + resourceResolver, + repoSystem, + artifactHandlerManager, + mavenProjectBuilder, + toolchainManager); + } + @Override protected boolean isAggregator() { return true; diff --git a/src/main/java/org/apache/maven/plugins/javadoc/AggregatorTestJavadocJarMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/AggregatorTestJavadocJarMojo.java index dba34342d..f1a21ce15 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/AggregatorTestJavadocJarMojo.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/AggregatorTestJavadocJarMojo.java @@ -18,10 +18,21 @@ */ package org.apache.maven.plugins.javadoc; +import javax.inject.Inject; + +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.doxia.tools.SiteTool; import org.apache.maven.plugins.annotations.Execute; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.plugins.javadoc.resolver.ResourceResolver; +import org.apache.maven.project.MavenProjectHelper; +import org.apache.maven.project.ProjectBuilder; +import org.apache.maven.toolchain.ToolchainManager; +import org.codehaus.plexus.archiver.jar.JarArchiver; +import org.codehaus.plexus.archiver.manager.ArchiverManager; +import org.eclipse.aether.RepositorySystem; /** *

Bundles the Javadoc documentation for Java Test code in an aggregator project into a jar @@ -39,6 +50,32 @@ requiresDependencyResolution = ResolutionScope.TEST) @Execute(phase = LifecyclePhase.TEST_COMPILE) public class AggregatorTestJavadocJarMojo extends TestJavadocJarMojo { + + // CHECKSTYLE_OFF: ParameterNumber + @Inject + public AggregatorTestJavadocJarMojo( + MavenProjectHelper projectHelper, + JarArchiver jarArchiver, + SiteTool siteTool, + ArchiverManager archiverManager, + ResourceResolver resourceResolver, + RepositorySystem repoSystem, + ArtifactHandlerManager artifactHandlerManager, + ProjectBuilder mavenProjectBuilder, + ToolchainManager toolchainManager) { + super( + projectHelper, + jarArchiver, + siteTool, + archiverManager, + resourceResolver, + repoSystem, + artifactHandlerManager, + mavenProjectBuilder, + toolchainManager); + } + // CHECKSTYLE_ON: ParameterNumber + @Override protected boolean isAggregator() { return true; diff --git a/src/main/java/org/apache/maven/plugins/javadoc/AggregatorTestJavadocNoForkReport.java b/src/main/java/org/apache/maven/plugins/javadoc/AggregatorTestJavadocNoForkReport.java index 1cd104ca6..0ac6aca1c 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/AggregatorTestJavadocNoForkReport.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/AggregatorTestJavadocNoForkReport.java @@ -18,10 +18,19 @@ */ package org.apache.maven.plugins.javadoc; +import javax.inject.Inject; + +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.doxia.tools.SiteTool; import org.apache.maven.plugins.annotations.Execute; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.plugins.javadoc.resolver.ResourceResolver; +import org.apache.maven.project.ProjectBuilder; +import org.apache.maven.toolchain.ToolchainManager; +import org.codehaus.plexus.archiver.manager.ArchiverManager; +import org.eclipse.aether.RepositorySystem; /** * Generates documentation for the Java Test code in an aggregator project using the standard @@ -32,4 +41,24 @@ */ @Mojo(name = "test-aggregate-no-fork", requiresDependencyResolution = ResolutionScope.TEST) @Execute(phase = LifecyclePhase.NONE) -public class AggregatorTestJavadocNoForkReport extends AggregatorTestJavadocReport {} +public class AggregatorTestJavadocNoForkReport extends AggregatorTestJavadocReport { + + @Inject + public AggregatorTestJavadocNoForkReport( + SiteTool siteTool, + ArchiverManager archiverManager, + ResourceResolver resourceResolver, + RepositorySystem repoSystem, + ArtifactHandlerManager artifactHandlerManager, + ProjectBuilder mavenProjectBuilder, + ToolchainManager toolchainManager) { + super( + siteTool, + archiverManager, + resourceResolver, + repoSystem, + artifactHandlerManager, + mavenProjectBuilder, + toolchainManager); + } +} diff --git a/src/main/java/org/apache/maven/plugins/javadoc/AggregatorTestJavadocReport.java b/src/main/java/org/apache/maven/plugins/javadoc/AggregatorTestJavadocReport.java index 3829d46af..06db5a725 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/AggregatorTestJavadocReport.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/AggregatorTestJavadocReport.java @@ -18,10 +18,19 @@ */ package org.apache.maven.plugins.javadoc; +import javax.inject.Inject; + +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.doxia.tools.SiteTool; import org.apache.maven.plugins.annotations.Execute; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.plugins.javadoc.resolver.ResourceResolver; +import org.apache.maven.project.ProjectBuilder; +import org.apache.maven.toolchain.ToolchainManager; +import org.codehaus.plexus.archiver.manager.ArchiverManager; +import org.eclipse.aether.RepositorySystem; /** *

Generates documentation for the Java Test code in an aggregator project using the standard @@ -35,6 +44,26 @@ @Mojo(name = "test-aggregate", aggregator = true, requiresDependencyResolution = ResolutionScope.TEST) @Execute(phase = LifecyclePhase.TEST_COMPILE) public class AggregatorTestJavadocReport extends TestJavadocReport { + + @Inject + public AggregatorTestJavadocReport( + SiteTool siteTool, + ArchiverManager archiverManager, + ResourceResolver resourceResolver, + RepositorySystem repoSystem, + ArtifactHandlerManager artifactHandlerManager, + ProjectBuilder mavenProjectBuilder, + ToolchainManager toolchainManager) { + super( + siteTool, + archiverManager, + resourceResolver, + repoSystem, + artifactHandlerManager, + mavenProjectBuilder, + toolchainManager); + } + @Override protected boolean isAggregator() { return true; diff --git a/src/main/java/org/apache/maven/plugins/javadoc/FixJavadocMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/FixJavadocMojo.java index 0deafadd9..99511c1aa 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/FixJavadocMojo.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/FixJavadocMojo.java @@ -18,10 +18,13 @@ */ package org.apache.maven.plugins.javadoc; +import javax.inject.Inject; + import org.apache.maven.plugins.annotations.Execute; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; +import org.codehaus.plexus.components.interactivity.InputHandler; /** * Fix Javadoc documentation and tags for the Java code for the project. @@ -33,5 +36,9 @@ @Mojo(name = "fix", requiresDependencyResolution = ResolutionScope.COMPILE, threadSafe = true) @Execute(phase = LifecyclePhase.COMPILE) public class FixJavadocMojo extends AbstractFixJavadocMojo { - // nop + + @Inject + public FixJavadocMojo(InputHandler inputHandler) { + super(inputHandler); + } } diff --git a/src/main/java/org/apache/maven/plugins/javadoc/JavadocJarMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/JavadocJarMojo.java index 02a1ff99e..3d840ac0c 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/JavadocJarMojo.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/JavadocJarMojo.java @@ -18,6 +18,8 @@ */ package org.apache.maven.plugins.javadoc; +import javax.inject.Inject; + import java.io.File; import java.io.IOException; import java.util.List; @@ -26,20 +28,24 @@ import org.apache.maven.archiver.MavenArchiver; import org.apache.maven.artifact.DependencyResolutionRequiredException; import org.apache.maven.artifact.handler.ArtifactHandler; +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.doxia.tools.SiteTool; import org.apache.maven.model.Resource; import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.LifecyclePhase; 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.plugins.javadoc.resolver.ResourceResolver; import org.apache.maven.project.MavenProjectHelper; +import org.apache.maven.project.ProjectBuilder; import org.apache.maven.reporting.MavenReportException; -import org.codehaus.plexus.archiver.Archiver; +import org.apache.maven.toolchain.ToolchainManager; import org.codehaus.plexus.archiver.ArchiverException; import org.codehaus.plexus.archiver.jar.JarArchiver; import org.codehaus.plexus.archiver.jar.ManifestException; +import org.codehaus.plexus.archiver.manager.ArchiverManager; +import org.eclipse.aether.RepositorySystem; /** * Bundles the Javadoc documentation for main Java code in an NON aggregator project into @@ -79,7 +85,6 @@ public class JavadocJarMojo extends AbstractJavadocMojo { /** * Used for attaching the artifact in the project. */ - @Component private MavenProjectHelper projectHelper; /** @@ -87,9 +92,33 @@ public class JavadocJarMojo extends AbstractJavadocMojo { * * @since 2.5 */ - @Component(role = Archiver.class, hint = "jar") private JarArchiver jarArchiver; + // CHECKSTYLE_OFF: ParameterNumber + @Inject + public JavadocJarMojo( + MavenProjectHelper projectHelper, + JarArchiver jarArchiver, + SiteTool siteTool, + ArchiverManager archiverManager, + ResourceResolver resourceResolver, + RepositorySystem repoSystem, + ArtifactHandlerManager artifactHandlerManager, + ProjectBuilder mavenProjectBuilder, + ToolchainManager toolchainManager) { + super( + siteTool, + archiverManager, + resourceResolver, + repoSystem, + artifactHandlerManager, + mavenProjectBuilder, + toolchainManager); + this.projectHelper = projectHelper; + this.jarArchiver = jarArchiver; + } + // CHECKSTYLE_ON: ParameterNumber + // ---------------------------------------------------------------------- // Mojo Parameters // ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/maven/plugins/javadoc/JavadocNoForkReport.java b/src/main/java/org/apache/maven/plugins/javadoc/JavadocNoForkReport.java index 4410e12f2..b7b145fb8 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/JavadocNoForkReport.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/JavadocNoForkReport.java @@ -18,13 +18,22 @@ */ package org.apache.maven.plugins.javadoc; +import javax.inject.Inject; + +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.doxia.tools.SiteTool; import org.apache.maven.plugins.annotations.Execute; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.plugins.javadoc.resolver.ResourceResolver; +import org.apache.maven.project.ProjectBuilder; +import org.apache.maven.toolchain.ToolchainManager; +import org.codehaus.plexus.archiver.manager.ArchiverManager; +import org.eclipse.aether.RepositorySystem; /** - * Generates documentation for the Java code in an NON aggregator project using the standard + * Generates documentation for the Java code in a NON aggregator project using the standard * Javadoc Tool. Note that this * goal does require generation of sources before site generation, e.g. by invoking {@code mvn clean deploy site}. * @@ -35,4 +44,24 @@ */ @Mojo(name = "javadoc-no-fork", requiresDependencyResolution = ResolutionScope.COMPILE, threadSafe = true) @Execute(phase = LifecyclePhase.NONE) -public class JavadocNoForkReport extends JavadocReport {} +public class JavadocNoForkReport extends JavadocReport { + + @Inject + public JavadocNoForkReport( + SiteTool siteTool, + ArchiverManager archiverManager, + ResourceResolver resourceResolver, + RepositorySystem repoSystem, + ArtifactHandlerManager artifactHandlerManager, + ProjectBuilder mavenProjectBuilder, + ToolchainManager toolchainManager) { + super( + siteTool, + archiverManager, + resourceResolver, + repoSystem, + artifactHandlerManager, + mavenProjectBuilder, + toolchainManager); + } +} diff --git a/src/main/java/org/apache/maven/plugins/javadoc/JavadocReport.java b/src/main/java/org/apache/maven/plugins/javadoc/JavadocReport.java index 5c0ca5b10..616b7859b 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/JavadocReport.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/JavadocReport.java @@ -18,6 +18,8 @@ */ package org.apache.maven.plugins.javadoc; +import javax.inject.Inject; + import java.io.File; import java.nio.file.Path; import java.util.Collection; @@ -26,6 +28,7 @@ import java.util.ResourceBundle; import java.util.stream.Collectors; +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.doxia.sink.SinkFactory; import org.apache.maven.doxia.siterenderer.DocumentRenderingContext; @@ -38,8 +41,13 @@ 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.plugins.javadoc.resolver.ResourceResolver; +import org.apache.maven.project.ProjectBuilder; import org.apache.maven.reporting.MavenMultiPageReport; import org.apache.maven.reporting.MavenReportException; +import org.apache.maven.toolchain.ToolchainManager; +import org.codehaus.plexus.archiver.manager.ArchiverManager; +import org.eclipse.aether.RepositorySystem; /** * Generates documentation for the Java code in a NON aggregator project using the standard @@ -78,6 +86,25 @@ public class JavadocReport extends AbstractJavadocMojo implements MavenMultiPage @Parameter(property = "description") private String description; + @Inject + public JavadocReport( + SiteTool siteTool, + ArchiverManager archiverManager, + ResourceResolver resourceResolver, + RepositorySystem repoSystem, + ArtifactHandlerManager artifactHandlerManager, + ProjectBuilder mavenProjectBuilder, + ToolchainManager toolchainManager) { + super( + siteTool, + archiverManager, + resourceResolver, + repoSystem, + artifactHandlerManager, + mavenProjectBuilder, + toolchainManager); + } + // ---------------------------------------------------------------------- // Report public methods // ---------------------------------------------------------------------- @@ -103,6 +130,7 @@ public String getDescription(Locale locale) { } /** {@inheritDoc} */ + @Override public void generate(Sink sink, Locale locale) throws MavenReportException { generate(sink, null, locale); } diff --git a/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java b/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java index 7c723c24e..c8178dd61 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java @@ -1045,7 +1045,7 @@ private static String getMavenHome(Log log) { File m2Home = new File(mavenHome); if (!m2Home.exists()) { if (log != null && log.isErrorEnabled()) { - log.error("Cannot find Maven application directory. Either specify 'maven.home' system property."); + log.error("Cannot find Maven application directory. Specify 'maven.home' system property."); } } diff --git a/src/main/java/org/apache/maven/plugins/javadoc/ResourcesBundleMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/ResourcesBundleMojo.java index 6697e6591..cf1d1ce45 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/ResourcesBundleMojo.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/ResourcesBundleMojo.java @@ -18,22 +18,29 @@ */ package org.apache.maven.plugins.javadoc; +import javax.inject.Inject; + import java.io.File; import java.io.IOException; +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.doxia.tools.SiteTool; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.LifecyclePhase; 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.plugins.javadoc.resolver.ResourceResolver; import org.apache.maven.project.MavenProjectHelper; +import org.apache.maven.project.ProjectBuilder; +import org.apache.maven.toolchain.ToolchainManager; import org.codehaus.plexus.archiver.Archiver; import org.codehaus.plexus.archiver.ArchiverException; import org.codehaus.plexus.archiver.manager.ArchiverManager; import org.codehaus.plexus.archiver.manager.NoSuchArchiverException; import org.codehaus.plexus.archiver.util.DefaultFileSet; +import org.eclipse.aether.RepositorySystem; /** * Bundle {@link AbstractJavadocMojo#javadocDirectory}, along with javadoc configuration options such @@ -72,15 +79,37 @@ public class ResourcesBundleMojo extends AbstractJavadocMojo { * Helper component to provide an easy mechanism for attaching an artifact to the project for * installation/deployment. */ - @Component private MavenProjectHelper projectHelper; /** * Archiver manager, used to manage jar builder. */ - @Component private ArchiverManager archiverManager; + // CHECKSTYLE_OFF: ParameterNumber + @Inject + public ResourcesBundleMojo( + MavenProjectHelper projectHelper, + SiteTool siteTool, + ArchiverManager archiverManager, + ResourceResolver resourceResolver, + RepositorySystem repoSystem, + ArtifactHandlerManager artifactHandlerManager, + ProjectBuilder mavenProjectBuilder, + ToolchainManager toolchainManager) { + super( + siteTool, + archiverManager, + resourceResolver, + repoSystem, + artifactHandlerManager, + mavenProjectBuilder, + toolchainManager); + this.archiverManager = archiverManager; + this.projectHelper = projectHelper; + } + // CHECKSTYLE_ON: ParameterNumber + /** * Assemble a new {@link org.apache.maven.plugins.javadoc.options.JavadocOptions JavadocOptions} instance that * contains the configuration options in this diff --git a/src/main/java/org/apache/maven/plugins/javadoc/TestFixJavadocMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/TestFixJavadocMojo.java index 4ff18ec3e..2eea88000 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/TestFixJavadocMojo.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/TestFixJavadocMojo.java @@ -18,6 +18,8 @@ */ package org.apache.maven.plugins.javadoc; +import javax.inject.Inject; + import java.util.Collections; import java.util.LinkedList; import java.util.List; @@ -30,6 +32,7 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.components.interactivity.InputHandler; /** * Fix Javadoc documentation and tags for the Test Java code for the project. @@ -41,6 +44,12 @@ @Mojo(name = "test-fix", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true) @Execute(phase = LifecyclePhase.TEST_COMPILE) public class TestFixJavadocMojo extends AbstractFixJavadocMojo { + + @Inject + public TestFixJavadocMojo(InputHandler inputHandler) { + super(inputHandler); + } + /** {@inheritDoc} */ @Override protected List getProjectSourceRoots(MavenProject p) { diff --git a/src/main/java/org/apache/maven/plugins/javadoc/TestJavadocJarMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/TestJavadocJarMojo.java index 9fa1c9eaa..67cb170be 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/TestJavadocJarMojo.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/TestJavadocJarMojo.java @@ -18,6 +18,8 @@ */ package org.apache.maven.plugins.javadoc; +import javax.inject.Inject; + import java.io.File; import java.util.ArrayList; import java.util.Arrays; @@ -25,17 +27,26 @@ import java.util.List; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.doxia.tools.SiteTool; import org.apache.maven.plugins.annotations.LifecyclePhase; 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.plugins.javadoc.resolver.ResourceResolver; import org.apache.maven.plugins.javadoc.resolver.SourceResolverConfig; import org.apache.maven.project.MavenProject; +import org.apache.maven.project.MavenProjectHelper; +import org.apache.maven.project.ProjectBuilder; +import org.apache.maven.toolchain.ToolchainManager; +import org.codehaus.plexus.archiver.jar.JarArchiver; +import org.codehaus.plexus.archiver.manager.ArchiverManager; import org.codehaus.plexus.util.StringUtils; +import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.util.filter.ScopeDependencyFilter; /** - * Bundles the Javadoc documentation for test Java code in an NON aggregator project into + * Bundles the Javadoc documentation for test Java code in a NON aggregator project into * a jar using the standard * Javadoc Tool. * @@ -48,6 +59,32 @@ requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true) public class TestJavadocJarMojo extends JavadocJarMojo { + + // CHECKSTYLE_OFF: ParameterNumber + @Inject + public TestJavadocJarMojo( + MavenProjectHelper projectHelper, + JarArchiver jarArchiver, + SiteTool siteTool, + ArchiverManager archiverManager, + ResourceResolver resourceResolver, + RepositorySystem repoSystem, + ArtifactHandlerManager artifactHandlerManager, + ProjectBuilder mavenProjectBuilder, + ToolchainManager toolchainManager) { + super( + projectHelper, + jarArchiver, + siteTool, + archiverManager, + resourceResolver, + repoSystem, + artifactHandlerManager, + mavenProjectBuilder, + toolchainManager); + } + // CHECKSTYLE_ON: ParameterNumber + // ---------------------------------------------------------------------- // Javadoc Options (should be inline with Javadoc options defined in TestJavadocReport) // ---------------------------------------------------------------------- @@ -177,7 +214,7 @@ protected ScopeDependencyFilter getDependencyScopeFilter() { } /** - * Overriden to enable the resolution of -test-sources jar files. + * Overridden to enable the resolution of -test-sources jar files. * * {@inheritDoc} */ diff --git a/src/main/java/org/apache/maven/plugins/javadoc/TestJavadocNoForkReport.java b/src/main/java/org/apache/maven/plugins/javadoc/TestJavadocNoForkReport.java index f86b48328..bc78361c6 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/TestJavadocNoForkReport.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/TestJavadocNoForkReport.java @@ -18,10 +18,19 @@ */ package org.apache.maven.plugins.javadoc; +import javax.inject.Inject; + +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.doxia.tools.SiteTool; import org.apache.maven.plugins.annotations.Execute; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.plugins.javadoc.resolver.ResourceResolver; +import org.apache.maven.project.ProjectBuilder; +import org.apache.maven.toolchain.ToolchainManager; +import org.codehaus.plexus.archiver.manager.ArchiverManager; +import org.eclipse.aether.RepositorySystem; /** * Generates documentation for the Java Test code in an NON aggregator project using the standard @@ -36,4 +45,25 @@ */ @Mojo(name = "test-javadoc-no-fork", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true) @Execute(phase = LifecyclePhase.NONE) -public class TestJavadocNoForkReport extends TestJavadocReport {} +public class TestJavadocNoForkReport extends TestJavadocReport { + + @Inject + public TestJavadocNoForkReport( + SiteTool siteTool, + ArchiverManager archiverManager, + ResourceResolver resourceResolver, + RepositorySystem repoSystem, + ArtifactHandlerManager artifactHandlerManager, + ProjectBuilder mavenProjectBuilder, + ToolchainManager toolchainManager) { + super( + siteTool, + archiverManager, + resourceResolver, + repoSystem, + artifactHandlerManager, + mavenProjectBuilder, + toolchainManager); + // TODO Auto-generated constructor stub + } +} diff --git a/src/main/java/org/apache/maven/plugins/javadoc/TestJavadocReport.java b/src/main/java/org/apache/maven/plugins/javadoc/TestJavadocReport.java index 63d1d6595..4c8f900c5 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/TestJavadocReport.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/TestJavadocReport.java @@ -18,6 +18,8 @@ */ package org.apache.maven.plugins.javadoc; +import javax.inject.Inject; + import java.io.File; import java.util.ArrayList; import java.util.Arrays; @@ -28,19 +30,26 @@ import java.util.ResourceBundle; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.doxia.tools.SiteTool; import org.apache.maven.plugins.annotations.Execute; import org.apache.maven.plugins.annotations.LifecyclePhase; 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.plugins.javadoc.resolver.ResourceResolver; import org.apache.maven.plugins.javadoc.resolver.SourceResolverConfig; import org.apache.maven.project.MavenProject; +import org.apache.maven.project.ProjectBuilder; import org.apache.maven.reporting.MavenReportException; +import org.apache.maven.toolchain.ToolchainManager; +import org.codehaus.plexus.archiver.manager.ArchiverManager; import org.codehaus.plexus.util.StringUtils; +import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.util.filter.ScopeDependencyFilter; /** - * Generates documentation for the Java Test code in an NON aggregator project using the standard + * Generates documentation for the Java Test code in a NON aggregator project using the standard * Javadoc Tool. * * @author Vincent Siveton @@ -130,6 +139,25 @@ public class TestJavadocReport extends JavadocReport { // Report public methods // ---------------------------------------------------------------------- + @Inject + public TestJavadocReport( + SiteTool siteTool, + ArchiverManager archiverManager, + ResourceResolver resourceResolver, + RepositorySystem repoSystem, + ArtifactHandlerManager artifactHandlerManager, + ProjectBuilder mavenProjectBuilder, + ToolchainManager toolchainManager) { + super( + siteTool, + archiverManager, + resourceResolver, + repoSystem, + artifactHandlerManager, + mavenProjectBuilder, + toolchainManager); + } + @Override protected void executeReport(Locale unusedLocale) throws MavenReportException { addMainJavadocLink(); diff --git a/src/main/java/org/apache/maven/plugins/javadoc/TestResourcesBundleMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/TestResourcesBundleMojo.java index 64a66e15e..d8846aa7c 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/TestResourcesBundleMojo.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/TestResourcesBundleMojo.java @@ -18,12 +18,22 @@ */ package org.apache.maven.plugins.javadoc; +import javax.inject.Inject; + import java.io.File; +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.doxia.tools.SiteTool; import org.apache.maven.plugins.annotations.LifecyclePhase; 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.plugins.javadoc.resolver.ResourceResolver; +import org.apache.maven.project.MavenProjectHelper; +import org.apache.maven.project.ProjectBuilder; +import org.apache.maven.toolchain.ToolchainManager; +import org.codehaus.plexus.archiver.manager.ArchiverManager; +import org.eclipse.aether.RepositorySystem; /** * Bundle {@link TestJavadocJarMojo#testJavadocDirectory}, along with javadoc configuration options from @@ -41,6 +51,29 @@ threadSafe = true) public class TestResourcesBundleMojo extends ResourcesBundleMojo { + // CHECKSTYLE_OFF: ParameterNumber + @Inject + public TestResourcesBundleMojo( + MavenProjectHelper projectHelper, + SiteTool siteTool, + ArchiverManager archiverManager, + ResourceResolver resourceResolver, + RepositorySystem repoSystem, + ArtifactHandlerManager artifactHandlerManager, + ProjectBuilder mavenProjectBuilder, + ToolchainManager toolchainManager) { + super( + projectHelper, + siteTool, + archiverManager, + resourceResolver, + repoSystem, + artifactHandlerManager, + mavenProjectBuilder, + toolchainManager); + } + // CHECKSTYLE_ON: ParameterNumber + /** * Specifies the Test Javadoc resources directory to be included in the Javadoc (i.e. package.html, images...). */ diff --git a/src/test/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojoTest.java b/src/test/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojoTest.java index 8a6d5b4c2..d21ba29d4 100644 --- a/src/test/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojoTest.java @@ -37,7 +37,7 @@ public class AbstractJavadocMojoTest { @Before public void setUp() { - mojo = new AbstractJavadocMojo() { + mojo = new AbstractJavadocMojo(null, null, null, null, null, null, null) { @Override public void doExecute() {} }; diff --git a/src/test/java/org/apache/maven/plugins/javadoc/FixJavadocMojoTest.java b/src/test/java/org/apache/maven/plugins/javadoc/FixJavadocMojoTest.java index eedad8815..b9ad5ab9a 100644 --- a/src/test/java/org/apache/maven/plugins/javadoc/FixJavadocMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/javadoc/FixJavadocMojoTest.java @@ -319,7 +319,7 @@ public void testJavadocComment() throws Throwable { assertEquals(5, javaMethod.getTags().size()); - AbstractFixJavadocMojo mojoInstance = new FixJavadocMojo(); + AbstractFixJavadocMojo mojoInstance = new FixJavadocMojo(null); setVariableValueToObject(mojoInstance, "fixTagsSplitted", new String[] {"all"}); DocletTag tag = javaMethod.getTags().get(0); @@ -383,7 +383,7 @@ public void testJavadocCommentJdk5() throws Exception { assertEquals(4, javaMethod.getTags().size()); - AbstractFixJavadocMojo mojoInstance = new FixJavadocMojo(); + AbstractFixJavadocMojo mojoInstance = new FixJavadocMojo(null); setVariableValueToObject(mojoInstance, "fixTagsSplitted", new String[] {"all"}); DocletTag tag = javaMethod.getTags().get(0); @@ -404,7 +404,7 @@ public void testJavadocCommentJdk5() throws Exception { } public void testInitParameters() throws Throwable { - AbstractFixJavadocMojo mojoInstance = new FixJavadocMojo(); + AbstractFixJavadocMojo mojoInstance = new FixJavadocMojo(null); setVariableValueToObject(mojoInstance, "fixTags", "author, version, since, param, return, throws, link"); setVariableValueToObject(mojoInstance, "defaultSince", "1.0"); setVariableValueToObject(mojoInstance, "level", "protected"); @@ -431,7 +431,7 @@ public void testInitParameters() throws Throwable { } public void testRemoveUnknownExceptions() throws Exception { - AbstractFixJavadocMojo mojoInstance = new FixJavadocMojo(); + AbstractFixJavadocMojo mojoInstance = new FixJavadocMojo(null); setVariableValueToObject(mojoInstance, "fixTagsSplitted", new String[] {"all"}); setVariableValueToObject(mojoInstance, "project", new MavenProjectStub());