I have found a few posts surrounding the question of artifact retrieval however the answers don't seem to work in my specific case.
I am writing a plugin that will help with skinny war EAR generation and I am running a plugin that I have written for my EAR maven module. In the plugin code I have got to the stage where I want to be able to get the dependencies / artifacts of the WAR dependencies - currently these are not coming through with anything I have tried. I presume this is because even running a dependency:tree on my EAR module doesn't include them, they are not 'transitive' dependencies.
// Neither of the two below return WAR transitive dependencies, just the WARs
project.getDependencies()
project.getArtifacts()
My new approach is currently this:
ArtifactRepository localRepository = project.getDistributionManagementArtifactRepository();
List remoteRepositories = project.getRemoteArtifactRepositories();
ResolutionGroup resolutionGroup = artifactMetadataSource.retrieve(warArtifact, localRepository, remoteRepositories);
Set<Artifact> artifactDependencies = resolutionGroup.getArtifacts();
(N.B. This is making use of the project's ArtifactMetadataSource
component object and the dependencies maven-dependency-plugin:2.4
)
This is not working. The artifactDependencies
set is empty. Now this must be possible because running mvn dependency:tree
in the directory for the module warArtifact
works fine as expected.
Any ideas?
I finally have an answer. Admittedly it doesn't properly answer my original question but it's what I've gone with.
Reason it doesn't completely answer my original post: it requires Maven 3.
Here it is anyway for those that are interested:
My POM defines the following dependencies: