Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ under the License.
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-sink-api</artifactId>
<version>1.11.1</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.maven.reporting</groupId>
Expand All @@ -180,6 +186,12 @@ under the License.
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-impl</artifactId>
<version>3.2.0</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-io</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,15 @@
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.shared.artifact.filter.StrictPatternExcludesArtifactFilter;
import org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalysis;
import org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalyzer;
import org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalyzerException;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.context.Context;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;

/**
Expand All @@ -54,14 +53,15 @@
* @author <a href="mailto:[email protected]">Mark Hobson</a>
* @since 2.0-alpha-5
*/
public abstract class AbstractAnalyzeMojo extends AbstractMojo implements Contextualizable {
public abstract class AbstractAnalyzeMojo extends AbstractMojo {
// fields -----------------------------------------------------------------

/**
* The plexus context to look-up the right {@link ProjectDependencyAnalyzer} implementation depending on the mojo
* The plexusContainer to look-up the right {@link ProjectDependencyAnalyzer} implementation depending on the mojo
* configuration.
*/
private Context context;
@Component
private PlexusContainer plexusContainer;

/**
* The Maven project to analyze.
Expand Down Expand Up @@ -300,20 +300,15 @@ public void execute() throws MojoExecutionException, MojoFailureException {
* @throws MojoExecutionException in case of an error.
*/
protected ProjectDependencyAnalyzer createProjectDependencyAnalyzer() throws MojoExecutionException {

try {
final PlexusContainer container = (PlexusContainer) context.get(PlexusConstants.PLEXUS_KEY);
return container.lookup(ProjectDependencyAnalyzer.class, analyzer);
} catch (Exception exception) {
return plexusContainer.lookup(ProjectDependencyAnalyzer.class, analyzer);
} catch (ComponentLookupException exception) {
throw new MojoExecutionException(
"Failed to instantiate ProjectDependencyAnalyser" + " / role-hint " + analyzer, exception);
}
}

@Override
public void contextualize(Context theContext) {
this.context = theContext;
}

/**
* @return {@link #skip}
*/
Expand Down