How to access local maven repository in plexus component?

170 views Asked by At

I am writing a custom DependencyAnalyzer which plugs into the dependency:analyze goal. The analyzer is a plexus component whose sole parameter is the MavenProject instance.

My analyzer needs access to the local repository to be able to invoke the DependencyTreeBuilder (from org.apache.maven.shared.dependency.tree), which is the same component used by dependency:tree in verbose mode.

I understand that in a mojo, I could use a parameter with the expression "${localRepository}" to get the required ArtifactRepository instance. However, I could not find a way to get the repository from the plexus component.

I managed to add a dependency to the ArtifactRepositoryFactory plexus component, but have no idea what to pass to its createArtifactRepository() method.

Is there any way to get the ArtifactRepository, or alternatively, a way to evaluate expressions from a plexus component?


Note: this is similar to How to get access to Maven's dependency hierarchy within a plugin, but the code given there applies to a mojo, whereas I need the code in a plexus component.

0

There are 0 answers