I am writing a Maven plugin that performs dependency analysis in Maven projects. For this analysis, I need to transiently resolve project dependencies in files. Basically, I need all the JARs that the project uses directly or indirectly as local files so that my plugin can analyze them.
How to do this in modern (~ 3.3.x) Maven?
What I did in earlier versions was:
Enter many components and parameters.
@Component
protected ArtifactResolver artifactResolver;
@Component
protected ArtifactMetadataSource artifactMetadataSource;
@Component
protected ArtifactFactory artifactFactory;
@Parameter(defaultValue="${localRepository}", required=true, readonly=true)
protected ArtifactRepository localRepository;
@Component(role=MavenProjectBuilder.class)
protected MavenProjectBuilder mavenProjectBuilder;
@Component
protected ArtifactGraphBuilder artifactGraphBuilder;
@Parameter(defaultValue="${project.remoteArtifactRepositories}", required = true, readonly = true)
protected List<ArtifactRepository> remoteArtifactRepositories;
@Parameter( defaultValue = "${project}", readonly = true)
protected MavenProject project;
Creating artifacts from dependencies:
final Set<Artifact> dependencyArtifacts =
MavenMetadataSource.createArtifacts(artifactFactory,
project.getDependencies(), "compile", null, project);
Use ArtifactResolverfor transit resolution of artifacts:
artifactResolver.resolveTransitively(artifacts, originatingArtifact,
managedVersions, localRepository, remoteRepositories,
artifactMetadataSource, filter, moreListeners);
Now I'm trying to move all this into the current Maven (3.3.9), and suddenly nearly all ( ArtifactMetadataSource, ArtifactFactory, MavenProjectBuilder) is out of date with a zero notification that should be used instead.