title: Get dependencies of WAR Artifact using Maven 2 API
body: <p>I have found a few posts surrounding the question of artifact retrieval however the answers don't seem to work in my specific case.</p>
  
  <p>I am writing a plugin that will help with <a href="http://maven.apache.org/plugins/maven-war-plugin/examples/skinny-wars.html" rel="nofollow">skinny war EAR</a> 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.</p>
  
  <pre><code>// Neither of the two below return WAR transitive dependencies, just the WARs
  project.getDependencies()
  project.getArtifacts()
  </code></pre>
  
  <p>My new approach is currently this:</p>
  
  <pre><code>ArtifactRepository localRepository = project.getDistributionManagementArtifactRepository();
  List remoteRepositories = project.getRemoteArtifactRepositories();
  
  ResolutionGroup resolutionGroup = artifactMetadataSource.retrieve(warArtifact, localRepository, remoteRepositories);
  Set&lt;Artifact&gt; artifactDependencies = resolutionGroup.getArtifacts();
  </code></pre>
  
  <p>(N.B. This is making use of the project's <code>ArtifactMetadataSource</code> component object and the dependencies <code>maven-dependency-plugin:2.4</code>)</p>
  
  <p>This is <em>not</em> working. The <code>artifactDependencies</code> set is empty. Now this must be possible because running <code>mvn dependency:tree</code> in the directory for the module <code>warArtifact</code> works fine as expected. </p>
  
  <p>Any ideas?</p>