Skip to content

Commit

Permalink
[MDEP-966] @component to @Inject for ListClassesMojo and ListReposito…
Browse files Browse the repository at this point in the history
…riesMojo (#475)

* @component to @Inject for ListClassesMojo
* ListRepositoriesMojo
* PropertiesMojo
* AnalyzeReport
* AnalyzeDuplicateMojo
  • Loading branch information
elharo authored Nov 18, 2024
1 parent e681d70 commit 41391f2
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.apache.maven.plugins.dependency;

import javax.inject.Inject;

import java.io.File;
import java.io.IOException;
import java.util.Enumeration;
Expand All @@ -28,7 +30,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.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.dependency.utils.ParamArtifact;
Expand All @@ -45,11 +46,15 @@
@Mojo(name = "list-classes", requiresProject = false, threadSafe = true)
public class ListClassesMojo extends AbstractMojo {

@Component
private ResolverUtil resolverUtil;

private ParamArtifact paramArtifact = new ParamArtifact();

@Inject
public ListClassesMojo(ResolverUtil resolverUtil) {
this.resolverUtil = resolverUtil;
}

/**
* The group ID of the artifact to download. Ignored if {@code artifact} is used.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.apache.maven.plugins.dependency;

import javax.inject.Inject;

import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
Expand All @@ -31,7 +33,6 @@
import org.apache.maven.RepositoryUtils;
import org.apache.maven.model.DependencyManagement;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Mojo;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.artifact.ArtifactTypeRegistry;
Expand All @@ -53,9 +54,13 @@
@Mojo(name = "list-repositories", threadSafe = true)
public class ListRepositoriesMojo extends AbstractDependencyMojo {

@Component
private RepositorySystem repositorySystem;

@Inject
public ListRepositoriesMojo(RepositorySystem repositorySystem) {
this.repositorySystem = repositorySystem;
}

/**
* Displays a list of the repositories used by this build.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.apache.maven.plugins.dependency.analyze;

import javax.inject.Inject;

import java.io.IOException;
import java.io.Reader;
import java.util.Collections;
Expand All @@ -34,7 +36,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.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
Expand Down Expand Up @@ -66,9 +67,13 @@ public class AnalyzeDuplicateMojo extends AbstractMojo {
/**
* The Maven project to analyze.
*/
@Component
private MavenProject project;

@Inject
public AnalyzeDuplicateMojo(MavenProject project) {
this.project = project;
}

/**
* {@inheritDoc}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
*/
package org.apache.maven.plugins.dependency.analyze;

import javax.inject.Inject;

import java.util.Locale;
import java.util.Set;

import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Execute;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
Expand All @@ -48,7 +49,6 @@ public class AnalyzeReport extends AbstractMavenReport {
/**
* The Maven project dependency analyzer to use.
*/
@Component
private ProjectDependencyAnalyzer analyzer;

/**
Expand Down Expand Up @@ -87,9 +87,14 @@ public class AnalyzeReport extends AbstractMavenReport {
/**
* Internationalization component
*/
@Component
private I18N i18n;

@Inject
public AnalyzeReport(ProjectDependencyAnalyzer analyzer, I18N i18n) {
this.analyzer = analyzer;
this.i18n = i18n;
}

// Mojo methods -----------------------------------------------------------

/*
Expand Down Expand Up @@ -142,11 +147,13 @@ public String getOutputName() {
}

/** {@inheritDoc} */
@Override
public String getName(Locale locale) {
return getI18nString(locale, "name");
}

/** {@inheritDoc} */
@Override
public String getDescription(Locale locale) {
return getI18nString(locale, "description");
}
Expand Down

0 comments on commit 41391f2

Please sign in to comment.