You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Karl Heinz Marbaise <ka...@soebes.de> on 2009/12/19 18:36:01 UTC

Maven (3.0) Plugin Development ...dependencies

Hi,

just started with a little plugin....the idea is to get all dependencies of
the current project with their transitive dependencies as well...and to get
access to the pom information...

so i started a little bit naiv...with a simple Mojo...like the following:

    	Set depArtifacts = project.getDependencyArtifacts();
	Iterator depArtIter = depArtifacts.iterator();
        while (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 );
           }
           .....
           if (depProject.getDependencyArtifacts() != null) {
	           if (depProject.getDependencyArtifacts().size() > 0) {
	        	   //Here seemed to be the problem...!
	           }
           }
        }


But I'm a little bit astonished about the last lines, cause if i run this
plugin on my project i will get only the dependencies of the current project
not the transitive dependencies of the artifacts and theirs ...

[INFO] Artifacts: 4
[INFO] DEP:maven-model org.apache.maven 3.0-alpha-5[3.0-alpha-5]null
[INFO]  LC:The Apache Software License, Version 2.0
[http://www.apache.org/licenses/LICENSE-2.0.txt]
[INFO] DEP:maven-compat org.apache.maven 3.0-alpha-5[3.0-alpha-5]null
[INFO]  LC:The Apache Software License, Version 2.0
[http://www.apache.org/licenses/LICENSE-2.0.txt]
[INFO] DEP:maven-core org.apache.maven 3.0-alpha-5[3.0-alpha-5]null
[INFO]  LC:The Apache Software License, Version 2.0
[http://www.apache.org/licenses/LICENSE-2.0.txt]
[INFO] DEP:maven-reporting-api org.apache.maven.reporting 2.2.0[2.2.0]null
[INFO]  LC:The Apache Software License, Version 2.0
[http://www.apache.org/licenses/LICENSE-2.0.txt]
[INFO]
------------------------------------------------------------------------

I have checked that with the maven-dependency-plugin and tried a mvn
dependency:tree on the same project....and get many more output...

[INFO] [dependency:tree {execution: default-cli}]
[INFO] com.soebes.maven.plugins:licensesverifier-test:jar:1.0-SNAPSHOT
[INFO] +- org.apache.maven:maven-model:jar:3.0-alpha-5:compile
[INFO] |  \- org.codehaus.plexus:plexus-utils:jar:2.0.1:compile
[INFO] +- org.apache.maven:maven-compat:jar:3.0-alpha-5:compile
[INFO] |  +- org.apache.maven:maven-model-builder:jar:3.0-alpha-5:compile
[INFO] |  +- org.apache.maven:maven-settings:jar:3.0-alpha-5:compile
[INFO] |  +- org.apache.maven:maven-artifact:jar:3.0-alpha-5:compile
[INFO] |  +- org.codehaus.plexus:plexus-interpolation:jar:1.11:compile
[INFO] |  +- org.codehaus.plexus:plexus-container-default:jar:1.5.1:compile
[INFO] |  |  +- org.apache.xbean:xbean-reflect:jar:3.4:compile
[INFO] |  |  |  +- log4j:log4j:jar:1.2.12:compile
[INFO] |  |  |  \- commons-logging:commons-logging-api:jar:1.1:compile
[INFO] |  |  \-
com.google.code.google-collections:google-collect:jar:snapshot-20080530:compile
[INFO] |  +-
org.codehaus.plexus:plexus-component-annotations:jar:1.5.1:compile
[INFO] |  \-
org.apache.maven.wagon:wagon-provider-api:jar:1.0-beta-6:compile
[INFO] +- org.apache.maven:maven-core:jar:3.0-alpha-5:compile
[INFO] |  +- org.apache.maven:maven-plugin-api:jar:3.0-alpha-5:compile
[INFO] |  +- org.codehaus.plexus:plexus-classworlds:jar:2.2.2:compile
[INFO] |  \- org.sonatype.plexus:plexus-sec-dispatcher:jar:1.3:compile
[INFO] |     \- org.sonatype.plexus:plexus-cipher:jar:1.4:compile
[INFO] \- org.apache.maven.reporting:maven-reporting-api:jar:2.2.0:compile
[INFO]    +- org.apache.maven.doxia:doxia-sink-api:jar:1.1:compile
[INFO]    \- org.apache.maven.doxia:doxia-logging-api:jar:1.1:compile

May be someone can give me some tips how to handle that ?

Many thanks in advance...

Kind regards
Karl Heinz Marbaise

-- 
View this message in context: http://old.nabble.com/Maven-%283.0%29-Plugin-Development-...dependencies-tp26856892p26856892.html
Sent from the Maven Developers mailing list archive at Nabble.com.


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


Re: Maven (3.0) Plugin Development ...dependencies

Posted by Karl Heinz Marbaise <ka...@soebes.de>.
Hi,

Benjamin,
your tip did it...

Thanks for your help

Kind regards
Karl Heinz Marbaise
-- 
View this message in context: http://old.nabble.com/Maven-%283.0%29-Plugin-Development-...dependencies-tp26856892p26858020.html
Sent from the Maven Developers mailing list archive at Nabble.com.


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


Re: Maven (3.0) Plugin Development ...dependencies

Posted by Karl Heinz Marbaise <ka...@soebes.de>.
Hi,

Benjamin,
you tip did it...

Thanks for your help

Kind regards
Karl Heinz Marbaise
-- 
View this message in context: http://old.nabble.com/Maven-%283.0%29-Plugin-Development-...dependencies-tp26856892p26858018.html
Sent from the Maven Developers mailing list archive at Nabble.com.


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


Re: Maven (3.0) Plugin Development ...dependencies

Posted by Benjamin Bentmann <be...@udo.edu>.
Karl Heinz Marbaise wrote:

> just started with a little plugin....the idea is to get all dependencies of
> the current project with their transitive dependencies as well... [...]
> 
>     	Set depArtifacts = project.getDependencyArtifacts();

Try project.getArtifacts() instead.


Benjamin

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