Skip to content

Commit

Permalink
Migrate from Plexus to Sisu Guice (#341)
Browse files Browse the repository at this point in the history
* Migrate from Plexus to Sisu Guice
* no inject on abstract classes=
  • Loading branch information
elharo authored Nov 19, 2024
1 parent 39857ea commit 69c1ba7
Show file tree
Hide file tree
Showing 22 changed files with 504 additions and 37 deletions.
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,14 @@ under the License.
<!-- Do not upgrade, leads to IT failures, needs analysis -->
<version>3.4.0</version>
</dependency>

<dependency>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.plexus</artifactId>
<version>0.9.0.M3</version>
<scope>test</scope>
</dependency>

<!-- Doxia -->
<dependency>
<groupId>org.apache.maven.doxia</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
// ----------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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;

// ----------------------------------------------------------------------
Expand All @@ -272,41 +268,50 @@ public abstract class AbstractJavadocMojo extends AbstractMojo {
/**
* SiteTool.
*/
@Component
protected SiteTool siteTool;

/**
* Archiver manager
*
* @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;

/**
* Project builder
*
* @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();

// ----------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
* <p>Bundles the Javadoc documentation for main <code>Java code</code> in an <b>aggregator</b> project into a jar
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>Java code</code> in an <b>aggregator</b> project using the standard
Expand All @@ -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

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
* <p>Generates documentation for the <code>Java code</code> in an <b>aggregator</b> project using the standard
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
* <p>Bundles the Javadoc documentation for <code>Java Test code</code> in an <b>aggregator</b> project into a jar
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>Java Test code</code> in an <b>aggregator</b> project using the standard
Expand All @@ -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);
}
}
Loading

0 comments on commit 69c1ba7

Please sign in to comment.