Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
elharo committed Jan 1, 2025
1 parent b1bbacc commit e5162e2
Show file tree
Hide file tree
Showing 21 changed files with 74 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.logging.SystemStreamLog;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.dependency.utils.DependencySilentLog;
import org.apache.maven.project.DefaultProjectBuildingRequest;
Expand Down Expand Up @@ -60,8 +59,7 @@ public abstract class AbstractDependencyMojo extends AbstractMojo {
/**
* The Maven session
*/
@Component
protected MavenSession session;
protected final MavenSession session;

/**
* If the plugin should be silent.
Expand All @@ -81,29 +79,28 @@ public abstract class AbstractDependencyMojo extends AbstractMojo {
@Parameter(property = "mdep.skip", defaultValue = "false")
private boolean skip;

/**
* For IDE build support
*/
private final BuildContext buildContext;

/**
* Skip plugin execution only during incremental builds (e.g. triggered from M2E).
*
* @since 3.4.0
* @see #skip
*/
private final boolean skipDuringIncrementalBuild;
@Parameter(defaultValue = "false")
private boolean skipDuringIncrementalBuild;

/**
* For IDE build support
*/
private final BuildContext buildContext;

/**
* POM
*/
@Component
private final MavenProject project;

protected AbstractDependencyMojo(
BuildContext buildContext, boolean skipDuringIncrementalBuild, MavenProject project) {
protected AbstractDependencyMojo(MavenSession session, BuildContext buildContext, MavenProject project) {
this.session = session;
this.buildContext = buildContext;
this.skipDuringIncrementalBuild = skipDuringIncrementalBuild;
this.project = project;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.util.stream.Collectors;

import org.apache.maven.RepositoryUtils;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.DependencyManagement;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Mojo;
Expand Down Expand Up @@ -60,18 +61,15 @@ public class ListRepositoriesMojo extends AbstractDependencyMojo {

@Inject
public ListRepositoriesMojo(
BuildContext buildContext,
boolean skipDuringIncrementalBuild,
MavenProject project,
RepositorySystem repositorySystem) {
super(buildContext, skipDuringIncrementalBuild, project);
MavenSession session, BuildContext buildContext, MavenProject project, RepositorySystem repositorySystem) {
super(session, buildContext, project);
this.repositorySystem = repositorySystem;
}

/**
* Displays a list of the repositories used by this build.
*
* @throws MojoExecutionException with a message if an error occurs.
* @throws MojoExecutionException with a message if an error occurs
*/
@Override
protected void doExecute() throws MojoExecutionException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Dependency;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
Expand Down Expand Up @@ -118,13 +119,13 @@ public abstract class AbstractFromConfigurationMojo extends AbstractDependencyMo
private final ArtifactHandlerManager artifactHandlerManager;

protected AbstractFromConfigurationMojo(
MavenSession session,
BuildContext buildContext,
boolean skipDuringIncrementalBuild,
MavenProject project,
ArtifactResolver artifactResolver,
RepositoryManager repositoryManager,
ArtifactHandlerManager artifactHandlerManager) {
super(buildContext, skipDuringIncrementalBuild, project);
super(session, buildContext, project);
this.artifactResolver = artifactResolver;
this.repositoryManager = repositoryManager;
this.artifactHandlerManager = artifactHandlerManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@
*/
package org.apache.maven.plugins.dependency.fromConfiguration;

import javax.inject.Inject;

import java.io.File;
import java.io.IOException;
import java.util.List;

import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
Expand Down Expand Up @@ -84,21 +87,16 @@ public class CopyMojo extends AbstractFromConfigurationMojo {
@Parameter(property = "artifact")
private String artifact;

protected CopyMojo(
@Inject
public CopyMojo(
MavenSession session,
BuildContext buildContext,
boolean skipDuringIncrementalBuild,
MavenProject project,
ArtifactResolver artifactResolver,
RepositoryManager repositoryManager,
ArtifactHandlerManager artifactHandlerManager,
CopyUtil copyUtil) {
super(
buildContext,
skipDuringIncrementalBuild,
project,
artifactResolver,
repositoryManager,
artifactHandlerManager);
super(session, buildContext, project, artifactResolver, repositoryManager, artifactHandlerManager);
this.copyUtil = copyUtil;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.List;

import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
Expand Down Expand Up @@ -104,20 +105,14 @@ public class UnpackMojo extends AbstractFromConfigurationMojo {

@Inject
public UnpackMojo(
MavenSession session,
BuildContext buildContext,
boolean skipDuringIncrementalBuild,
MavenProject project,
ArtifactResolver artifactResolver,
RepositoryManager repositoryManager,
ArtifactHandlerManager artifactHandlerManager,
UnpackUtil unpackUtil) {
super(
buildContext,
skipDuringIncrementalBuild,
project,
artifactResolver,
repositoryManager,
artifactHandlerManager);
super(session, buildContext, project, artifactResolver, repositoryManager, artifactHandlerManager);
this.unpackUtil = unpackUtil;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.maven.RepositoryUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.dependency.AbstractDependencyMojo;
Expand Down Expand Up @@ -245,15 +246,15 @@ public abstract class AbstractDependencyFilterMojo extends AbstractDependencyMoj
@Inject
// CHECKSTYLE_OFF: ParameterNumber
protected AbstractDependencyFilterMojo(
MavenSession session,
BuildContext buildContext,
boolean skipDuringIncrementalBuild,
MavenProject project,
ResolverUtil resolverUtil,
DependencyResolver dependencyResolver,
RepositoryManager repositoryManager,
ProjectBuilder projectBuilder,
ArtifactHandlerManager artifactHandlerManager) {
super(buildContext, skipDuringIncrementalBuild, project);
super(session, buildContext, project);
this.resolverUtil = resolverUtil;
this.dependencyResolver = dependencyResolver;
this.repositoryManager = repositoryManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.File;

import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.dependency.utils.ResolverUtil;
import org.apache.maven.project.MavenProject;
Expand Down Expand Up @@ -115,17 +116,17 @@ public abstract class AbstractFromDependenciesMojo extends AbstractDependencyFil

// CHECKSTYLE_OFF: ParameterNumber
protected AbstractFromDependenciesMojo(
MavenSession session,
BuildContext buildContext,
boolean skipDuringIncrementalBuild,
MavenProject project,
ResolverUtil resolverUtil,
DependencyResolver dependencyResolver,
RepositoryManager repositoryManager,
ProjectBuilder projectBuilder,
ArtifactHandlerManager artifactHandlerManager) {
super(
session,
buildContext,
skipDuringIncrementalBuild,
project,
resolverUtil,
dependencyResolver,
Expand All @@ -136,7 +137,7 @@ protected AbstractFromDependenciesMojo(
// CHECKSTYLE_ON: ParameterNumber

/**
* @return returns the outputDirectory
* @return returns the output directory
*/
public File getOutputDirectory() {
return this.outputDirectory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
Expand Down Expand Up @@ -169,8 +170,8 @@ public class BuildClasspathMojo extends AbstractDependencyFilterMojo implements
@Inject
// CHECKSTYLE_OFF: ParameterNumber
protected BuildClasspathMojo(
MavenSession session,
BuildContext buildContext,
boolean skipDuringIncrementalBuild,
MavenProject project,
ResolverUtil resolverUtil,
DependencyResolver dependencyResolver,
Expand All @@ -179,8 +180,8 @@ protected BuildClasspathMojo(
ArtifactHandlerManager artifactHandlerManager,
MavenProjectHelper projectHelper) {
super(
session,
buildContext,
skipDuringIncrementalBuild,
project,
resolverUtil,
dependencyResolver,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.apache.maven.RepositoryUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
Expand Down Expand Up @@ -61,13 +62,11 @@
* @author <a href="mailto:[email protected]">Brian Fox</a>
* @since 1.0
*/
// CHECKSTYLE_OFF: LineLength
@Mojo(
name = "copy-dependencies",
requiresDependencyResolution = ResolutionScope.TEST,
defaultPhase = LifecyclePhase.PROCESS_SOURCES,
threadSafe = true)
// CHECKSTYLE_ON: LineLength
public class CopyDependenciesMojo extends AbstractFromDependenciesMojo {
/**
* Also copy the pom of each artifact.
Expand Down Expand Up @@ -101,8 +100,8 @@ public class CopyDependenciesMojo extends AbstractFromDependenciesMojo {
@Inject
// CHECKSTYLE_OFF: ParameterNumber
public CopyDependenciesMojo(
MavenSession session,
BuildContext buildContext,
boolean skipDuringIncrementalBuild,
MavenProject project,
ResolverUtil resolverUtil,
DependencyResolver dependencyResolver,
Expand All @@ -112,8 +111,8 @@ public CopyDependenciesMojo(
CopyUtil copyUtil,
ArtifactInstaller installer) {
super(
session,
buildContext,
skipDuringIncrementalBuild,
project,
resolverUtil,
dependencyResolver,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
Expand Down Expand Up @@ -107,8 +108,8 @@ public class UnpackDependenciesMojo extends AbstractFromDependenciesMojo {
@Inject
// CHECKSTYLE_OFF: ParameterNumber
public UnpackDependenciesMojo(
MavenSession session,
BuildContext buildContext,
boolean skipDuringIncrementalBuild,
MavenProject project,
ResolverUtil resolverUtil,
DependencyResolver dependencyResolver,
Expand All @@ -117,8 +118,8 @@ public UnpackDependenciesMojo(
ArtifactHandlerManager artifactHandlerManager,
UnpackUtil unpackUtil) {
super(
session,
buildContext,
skipDuringIncrementalBuild,
project,
resolverUtil,
dependencyResolver,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.File;

import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.dependency.fromDependencies.AbstractDependencyFilterMojo;
import org.apache.maven.plugins.dependency.utils.DependencyUtil;
Expand Down Expand Up @@ -69,17 +70,17 @@ public abstract class AbstractResolveMojo extends AbstractDependencyFilterMojo {

// CHECKSTYLE_OFF: ParameterNumber
protected AbstractResolveMojo(
MavenSession session,
BuildContext buildContext,
boolean skipDuringIncrementalBuild,
MavenProject project,
ResolverUtil resolverUtil,
DependencyResolver dependencyResolver,
RepositoryManager repositoryManager,
ProjectBuilder projectBuilder,
ArtifactHandlerManager artifactHandlerManager) {
super(
session,
buildContext,
skipDuringIncrementalBuild,
project,
resolverUtil,
dependencyResolver,
Expand All @@ -96,7 +97,6 @@ protected FilterArtifacts getArtifactsFilter() {
final FilterArtifacts filter = new FilterArtifacts();

if (excludeReactor) {

filter.addFilter(new ExcludeReactorProjectsArtifactFilter(reactorProjects, getLog()));
}

Expand Down
Loading

0 comments on commit e5162e2

Please sign in to comment.