Quantcast
Channel: Apache Timeline
Viewing all articles
Browse latest Browse all 5648

Generate A Maven artifact's dependencies and licenses ( how to instantiate a MavenProject using a giving artifact coordinate)

$
0
0
Hello,

I have a need to create an spreadsheet ( for legal purpose) containing a
Maven artifact, base on a given coordinate, and all of its transitive
dependencies and associated license info

There are 2 plugins having this kind of requirements:
maven-project-info-report-plugin and license-maven-plugin, both of these
projects have a maven project to work with. ( ie MavenProject )

For my case, I need to instantiate MavenProject from the provided
artifact using ProjectBuilder component, but this gives all kind of problem
from stack overflow to NPE

here is code

private MavenProject getMavenProjectFromArtifact( Artifact artifact )
throws ProjectBuildingException

ProjectBuildingRequest request = new
DefaultProjectBuildingRequest();
request.setLocalRepository( localRepository );
request.setPluginArtifactRepositories( pluginArtifactRepositories );
request.setRemoteRepositories( remoteRepositories );
request.setResolveDependencies( true );
request.setResolveVersionRanges( true );

ProjectBuildingResult result = projectBuilder.build( artifact,
request );

return result.getProject();

Am I using the right builder?

Any advice to get this working is very much appreciated.

Thanks

-Dan

Viewing all articles
Browse latest Browse all 5648

Trending Articles