Thanks a lot




Karl Heinz Marbaise-2 wrote:
> 
> Hi there,
> 
> 
>> public class PlatformProviderConfigurer
>>         extends AbstractMojo {
>> 
>>     /** @parameter default-value="${project}" */
>>     private MavenProject mavenProject;
>> 
>>     public void execute() throws MojoExecutionException {
>>        
>>         Set<DefaultArtifact> dependencyArtifacts =
>> mavenProject.getDependencyArtifacts();
> 
> 
>>         Set<DefaultArtifact> artifacts = mavenProject.getArtifacts();
> This will give you the needed information....
> 
>       Set depArtifacts = project.getArtifacts();
> 
> for (Iterator depArtIter = depArtifacts.iterator();depArtIter.hasNext(); )
> {
>       Artifact depArt = (Artifact) depArtIter.next();
> 
>       MavenProject depProject = null;
>       try
>       {
>          depProject = projectBuilder.buildFromRepository(depArt, 
> remoteRepositories, localRepository);
>       }
>       catch (ProjectBuildingException e)
>       {
>           throw new MojoExecutionException( "Unable to build project: " 
> + depArt.getDependencyConflictId(), e );
>       }
> 
> }
> 
> 
> What you need in your Mojo:
> 
>      /**
>       * Used to build a maven projects from artifacts in the remote 
> repository.
>       *
>       * @parameter 
> expression="${component.org.apache.maven.project.MavenProjectBuilder}"
>       * @required
>       * @readonly
>       */
>      protected DefaultMavenProjectBuilder projectBuilder;
> //    * @component 
> role"org.apache.maven.project.DefaultMavenProjectBuilder"
> roleHint="default"
> 
>      /**
>       * Location of the local repository.
>       *
>       * @parameter expression="${localRepository}"
>       * @readonly
>       * @required
>       */
>      protected org.apache.maven.artifact.repository.ArtifactRepository 
> localRepository;
> 
>      /**
>       * List of Remote Repositories used by the resolver
>       *
>       * @parameter expression="${project.remoteArtifactRepositories}"
>       * @readonly
>       * @required
>       */
>      protected java.util.List remoteRepositories;
> 
> 
> With the above construct you will get all dependencies incl. the 
> transitive dependencies.
> 
> Kind regards
> Karl Heinz Marbaise
> -- 
> SoftwareEntwicklung Beratung Schulung    Tel.: +49 (0) 2405 / 415 893
> Dipl.Ing.(FH) Karl Heinz Marbaise        ICQ#: 135949029
> Hauptstrasse 177                         USt.IdNr: DE191347579
> 52146 Würselen                           http://www.soebes.de
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
> For additional commands, e-mail: dev-h...@maven.apache.org
> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/How-to-get-dependency-artifacts-for-another-artifact---tp27167882p27168440.html
Sent from the Maven Developers mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
For additional commands, e-mail: dev-h...@maven.apache.org

Reply via email to