|
35 | 35 | import org.apache.maven.plugin.AbstractMojo; |
36 | 36 | import org.apache.maven.plugin.MojoExecutionException; |
37 | 37 | import org.apache.maven.plugin.MojoFailureException; |
| 38 | +import org.apache.maven.plugins.annotations.Component; |
38 | 39 | import org.apache.maven.plugins.annotations.Parameter; |
39 | 40 | import org.apache.maven.project.MavenProject; |
40 | 41 | import org.apache.maven.shared.artifact.filter.StrictPatternExcludesArtifactFilter; |
41 | 42 | import org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalysis; |
42 | 43 | import org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalyzer; |
43 | 44 | import org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalyzerException; |
44 | | -import org.codehaus.plexus.PlexusConstants; |
45 | 45 | import org.codehaus.plexus.PlexusContainer; |
46 | | -import org.codehaus.plexus.context.Context; |
47 | | -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; |
| 46 | +import org.codehaus.plexus.component.repository.exception.ComponentLookupException; |
48 | 47 | import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter; |
49 | 48 |
|
50 | 49 | /** |
|
54 | 53 | * @author <a href="mailto:[email protected]">Mark Hobson</a> |
55 | 54 | * @since 2.0-alpha-5 |
56 | 55 | */ |
57 | | -public abstract class AbstractAnalyzeMojo extends AbstractMojo implements Contextualizable { |
| 56 | +public abstract class AbstractAnalyzeMojo extends AbstractMojo { |
58 | 57 | // fields ----------------------------------------------------------------- |
59 | 58 |
|
60 | 59 | /** |
61 | | - * The plexus context to look-up the right {@link ProjectDependencyAnalyzer} implementation depending on the mojo |
| 60 | + * The plexusContainer to look-up the right {@link ProjectDependencyAnalyzer} implementation depending on the mojo |
62 | 61 | * configuration. |
63 | 62 | */ |
64 | | - private Context context; |
| 63 | + @Component |
| 64 | + private PlexusContainer plexusContainer; |
65 | 65 |
|
66 | 66 | /** |
67 | 67 | * The Maven project to analyze. |
@@ -300,20 +300,15 @@ public void execute() throws MojoExecutionException, MojoFailureException { |
300 | 300 | * @throws MojoExecutionException in case of an error. |
301 | 301 | */ |
302 | 302 | protected ProjectDependencyAnalyzer createProjectDependencyAnalyzer() throws MojoExecutionException { |
| 303 | + |
303 | 304 | try { |
304 | | - final PlexusContainer container = (PlexusContainer) context.get(PlexusConstants.PLEXUS_KEY); |
305 | | - return container.lookup(ProjectDependencyAnalyzer.class, analyzer); |
306 | | - } catch (Exception exception) { |
| 305 | + return plexusContainer.lookup(ProjectDependencyAnalyzer.class, analyzer); |
| 306 | + } catch (ComponentLookupException exception) { |
307 | 307 | throw new MojoExecutionException( |
308 | 308 | "Failed to instantiate ProjectDependencyAnalyser" + " / role-hint " + analyzer, exception); |
309 | 309 | } |
310 | 310 | } |
311 | 311 |
|
312 | | - @Override |
313 | | - public void contextualize(Context theContext) { |
314 | | - this.context = theContext; |
315 | | - } |
316 | | - |
317 | 312 | /** |
318 | 313 | * @return {@link #skip} |
319 | 314 | */ |
|
0 commit comments