diff --git a/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractReleaseMojo.java b/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractReleaseMojo.java index 99c48351..20ae91bc 100644 --- a/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractReleaseMojo.java +++ b/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractReleaseMojo.java @@ -28,7 +28,6 @@ import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.AbstractMojo; -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; @@ -59,11 +58,6 @@ public abstract class AbstractReleaseMojo extends AbstractMojo { @Parameter(defaultValue = "${project}", readonly = true, required = true) protected MavenProject project; - /** - */ - @Component - protected ReleaseManager releaseManager; - /** * Additional arguments to pass to the Maven executions, separated by spaces. */ @@ -130,6 +124,12 @@ public abstract class AbstractReleaseMojo extends AbstractMojo { @Parameter(defaultValue = "default", property = "releaseStrategyId") private String releaseStrategyId; + protected ReleaseManager releaseManager; + + protected AbstractReleaseMojo(ReleaseManager releaseManager) { + this.releaseManager = releaseManager; + } + /** * Gets the environment settings configured for this release. * diff --git a/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractScmReleaseMojo.java b/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractScmReleaseMojo.java index 5b0f4434..d70306fd 100644 --- a/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractScmReleaseMojo.java +++ b/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractScmReleaseMojo.java @@ -18,16 +18,18 @@ */ package org.apache.maven.plugins.release; +import javax.inject.Inject; + import java.util.Map; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.model.Scm; 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.scm.manager.ScmManager; +import org.apache.maven.shared.release.ReleaseManager; import org.apache.maven.shared.release.config.ReleaseDescriptorBuilder; /** @@ -123,8 +125,13 @@ public abstract class AbstractScmReleaseMojo extends AbstractReleaseMojo { /** * The SCM manager. */ - @Component - private ScmManager scmManager; + private final ScmManager scmManager; + + @Inject + protected AbstractScmReleaseMojo(ReleaseManager releaseManager, ScmManager scmManager) { + super(releaseManager); + this.scmManager = scmManager; + } @Override public void execute() throws MojoExecutionException, MojoFailureException { diff --git a/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/BranchReleaseMojo.java b/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/BranchReleaseMojo.java index f0eb8cc4..01124b3c 100644 --- a/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/BranchReleaseMojo.java +++ b/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/BranchReleaseMojo.java @@ -18,16 +18,20 @@ */ package org.apache.maven.plugins.release; +import javax.inject.Inject; + import java.util.Arrays; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.scm.manager.ScmManager; import org.apache.maven.shared.release.DefaultReleaseManagerListener; import org.apache.maven.shared.release.ReleaseBranchRequest; import org.apache.maven.shared.release.ReleaseExecutionException; import org.apache.maven.shared.release.ReleaseFailureException; +import org.apache.maven.shared.release.ReleaseManager; import org.apache.maven.shared.release.config.ReleaseDescriptorBuilder; import org.codehaus.plexus.configuration.PlexusConfiguration; @@ -244,6 +248,11 @@ public class BranchReleaseMojo extends AbstractScmReleaseMojo { @Parameter(defaultValue = "false", property = "pinExternals") private boolean pinExternals; + @Inject + public BranchReleaseMojo(ReleaseManager releaseManager, ScmManager scmManager) { + super(releaseManager, scmManager); + } + @Override public void execute() throws MojoExecutionException, MojoFailureException { super.execute(); diff --git a/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/CleanReleaseMojo.java b/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/CleanReleaseMojo.java index 0221d760..d1dd3ff1 100644 --- a/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/CleanReleaseMojo.java +++ b/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/CleanReleaseMojo.java @@ -18,12 +18,15 @@ */ package org.apache.maven.plugins.release; +import javax.inject.Inject; + import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.shared.release.DefaultReleaseManagerListener; import org.apache.maven.shared.release.ReleaseCleanRequest; import org.apache.maven.shared.release.ReleaseFailureException; +import org.apache.maven.shared.release.ReleaseManager; import org.apache.maven.shared.release.config.ReleaseDescriptorBuilder; /** @@ -37,6 +40,12 @@ */ @Mojo(name = "clean", aggregator = true) public class CleanReleaseMojo extends AbstractReleaseMojo { + + @Inject + public CleanReleaseMojo(ReleaseManager releaseManager) { + super(releaseManager); + } + @Override public void execute() throws MojoExecutionException, MojoFailureException { ReleaseDescriptorBuilder releaseDescriptor = new ReleaseDescriptorBuilder(); diff --git a/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PerformReleaseMojo.java b/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PerformReleaseMojo.java index 2dbf8981..9bb00d23 100644 --- a/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PerformReleaseMojo.java +++ b/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PerformReleaseMojo.java @@ -18,18 +18,20 @@ */ package org.apache.maven.plugins.release; +import javax.inject.Inject; + import java.io.File; import java.util.Map; 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.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.scm.manager.ScmManager; import org.apache.maven.shared.release.DefaultReleaseManagerListener; import org.apache.maven.shared.release.ReleaseExecutionException; import org.apache.maven.shared.release.ReleaseFailureException; +import org.apache.maven.shared.release.ReleaseManager; import org.apache.maven.shared.release.ReleasePerformRequest; import org.apache.maven.shared.release.config.ReleaseDescriptorBuilder; import org.codehaus.plexus.util.StringUtils; @@ -136,8 +138,13 @@ public class PerformReleaseMojo extends AbstractReleaseMojo { /** * The SCM manager. */ - @Component - private ScmManager scmManager; + private final ScmManager scmManager; + + @Inject + public PerformReleaseMojo(ReleaseManager releaseManager, ScmManager scmManager) { + super(releaseManager); + this.scmManager = scmManager; + } @Override protected String getAdditionalProfiles() { @@ -154,7 +161,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { } } - // goals may be splitted into multiple line in configuration. + // goals may be split into multiple lines in configuration. // Let's build a single line command if (goals != null) { goals = StringUtils.join(StringUtils.split(goals), " "); diff --git a/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java b/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java index 6647157a..eef995f6 100644 --- a/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java +++ b/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java @@ -18,6 +18,8 @@ */ package org.apache.maven.plugins.release; +import javax.inject.Inject; + import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; @@ -28,9 +30,11 @@ 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.scm.manager.ScmManager; import org.apache.maven.shared.release.DefaultReleaseManagerListener; import org.apache.maven.shared.release.ReleaseExecutionException; import org.apache.maven.shared.release.ReleaseFailureException; +import org.apache.maven.shared.release.ReleaseManager; import org.apache.maven.shared.release.ReleasePrepareRequest; import org.apache.maven.shared.release.config.ReleaseDescriptorBuilder; import org.codehaus.plexus.configuration.PlexusConfiguration; @@ -330,6 +334,11 @@ public class PrepareReleaseMojo extends AbstractScmReleaseMojo { @Parameter(defaultValue = "false", property = "pinExternals") private boolean pinExternals; + @Inject + public PrepareReleaseMojo(ReleaseManager releaseManager, ScmManager scmManager) { + super(releaseManager, scmManager); + } + /** * {@inheritDoc} */ diff --git a/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareWithPomReleaseMojo.java b/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareWithPomReleaseMojo.java index 91531cbd..7f03be5e 100644 --- a/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareWithPomReleaseMojo.java +++ b/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareWithPomReleaseMojo.java @@ -18,11 +18,15 @@ */ package org.apache.maven.plugins.release; +import javax.inject.Inject; + import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; 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.scm.manager.ScmManager; +import org.apache.maven.shared.release.ReleaseManager; /** * Prepare for a release in SCM, fully resolving dependencies for the purpose of producing a "release POM". @@ -38,6 +42,11 @@ public class PrepareWithPomReleaseMojo extends PrepareReleaseMojo { @Parameter(defaultValue = "true", property = "generateReleasePoms") private boolean generateReleasePoms; + @Inject + public PrepareWithPomReleaseMojo(ReleaseManager releaseManager, ScmManager scmManager) { + super(releaseManager, scmManager); + } + @Override public void execute() throws MojoExecutionException, MojoFailureException { prepareRelease(generateReleasePoms); diff --git a/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/RollbackReleaseMojo.java b/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/RollbackReleaseMojo.java index 60f250d9..2eb609f4 100644 --- a/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/RollbackReleaseMojo.java +++ b/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/RollbackReleaseMojo.java @@ -18,13 +18,17 @@ */ package org.apache.maven.plugins.release; +import javax.inject.Inject; + import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.scm.manager.ScmManager; import org.apache.maven.shared.release.DefaultReleaseManagerListener; import org.apache.maven.shared.release.ReleaseExecutionException; import org.apache.maven.shared.release.ReleaseFailureException; +import org.apache.maven.shared.release.ReleaseManager; import org.apache.maven.shared.release.ReleaseRollbackRequest; import org.apache.maven.shared.release.config.ReleaseDescriptorBuilder; @@ -61,6 +65,11 @@ public class RollbackReleaseMojo extends AbstractScmReleaseMojo { property = "scmRollbackCommitComment") private String scmRollbackCommitComment = "@{prefix} rollback the release of @{releaseLabel}"; + @Inject + public RollbackReleaseMojo(ReleaseManager releaseManager, ScmManager scmManager) { + super(releaseManager, scmManager); + } + @Override public void execute() throws MojoExecutionException, MojoFailureException { super.execute(); diff --git a/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/StageReleaseMojo.java b/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/StageReleaseMojo.java index e099696f..7104f24b 100644 --- a/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/StageReleaseMojo.java +++ b/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/StageReleaseMojo.java @@ -18,8 +18,12 @@ */ package org.apache.maven.plugins.release; +import javax.inject.Inject; + import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.scm.manager.ScmManager; +import org.apache.maven.shared.release.ReleaseManager; /** * Perform a release from SCM to a staging repository. @@ -43,6 +47,11 @@ public class StageReleaseMojo extends PerformReleaseMojo { @Parameter(property = "stagingRepository", required = true) private String stagingRepository; + @Inject + public StageReleaseMojo(ReleaseManager releaseManager, ScmManager scmManager) { + super(releaseManager, scmManager); + } + @Override void createGoals() { if (goals == null) { diff --git a/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/UpdateVersionsMojo.java b/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/UpdateVersionsMojo.java index caf9acd9..ad9d3b74 100644 --- a/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/UpdateVersionsMojo.java +++ b/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/UpdateVersionsMojo.java @@ -18,6 +18,8 @@ */ package org.apache.maven.plugins.release; +import javax.inject.Inject; + import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -26,6 +28,7 @@ import org.apache.maven.shared.release.DefaultReleaseManagerListener; import org.apache.maven.shared.release.ReleaseExecutionException; import org.apache.maven.shared.release.ReleaseFailureException; +import org.apache.maven.shared.release.ReleaseManager; import org.apache.maven.shared.release.ReleaseUpdateVersionsRequest; import org.apache.maven.shared.release.config.ReleaseDescriptorBuilder; import org.codehaus.plexus.configuration.PlexusConfiguration; @@ -99,6 +102,11 @@ public class UpdateVersionsMojo extends AbstractReleaseMojo { @Parameter(property = "projectVersionPolicyConfig") private PlexusConfiguration projectVersionPolicyConfig; + @Inject + public UpdateVersionsMojo(ReleaseManager releaseManager) { + super(releaseManager); + } + @Override public void execute() throws MojoExecutionException, MojoFailureException { final ReleaseDescriptorBuilder config = createReleaseDescriptor();