How to get all dependecy in a mojo ?
My mojo extends AbstractWarMojo, I want to get all the Project's dependencies including the transitive denpendecies. So i config the MavenProject in my mojo like thsi: /** * The maven project. * * @parameter expression=${project} * @required * @readonly */ private MavenProject project; project.getArtifacts() is a empty collection. I saw war plugin and them get all the war's dependencies in this way? who can tell me how to get all dependecy in a mojo ? Thank you.
Re: How to get all dependecy in a mojo ?
Is this what you are looking for? [1] /** * All dependencies that this project has, including transitive ones. * Contents are lazily populated, so depending on what phases have run dependencies in some scopes won't be included. * eg. if only compile phase has run, dependencies with scope test won't be included. * * @return [EMAIL PROTECTED] Set} lt; [EMAIL PROTECTED] Artifact} * @see #getDependencyArtifacts() to get only direct dependencies */ public Set getArtifacts() { return artifacts == null ? Collections.EMPTY_SET : artifacts; } Also keep in keep in mind effects of @requiresDependencyResolution [2] [1] - http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java?view=markup [2] - http://maven.apache.org/developers/mojo-api-specification.html -- View this message in context: http://www.nabble.com/How-to-get-all-dependecy-in-a-mojo---tp19533728p19534612.html Sent from the Maven - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to get all dependecy in a mojo ?
You need to add @requiresDependencyResolution test (or compile etc) -Original Message- From: 陈思淼 [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 17, 2008 10:44 AM To: Maven Users List Subject: How to get all dependecy in a mojo ? My mojo extends AbstractWarMojo, I want to get all the Project's dependencies including the transitive denpendecies. So i config the MavenProject in my mojo like thsi: /** * The maven project. * * @parameter expression=${project} * @required * @readonly */ private MavenProject project; project.getArtifacts() is a empty collection. I saw war plugin and them get all the war's dependencies in this way? who can tell me how to get all dependecy in a mojo ? Thank you.
Re: How to get all dependecy in a mojo ?
I got the expect result.I use mvn compile myplugin:mojo to run my own task, instead of mvn myplugin:mojo. It works. Is it because the compile phase to load the dependency graph of the project, even if I use @requiresDependencyResolution test it doesn't work. 2008/9/17 Brian E. Fox [EMAIL PROTECTED] You need to add @requiresDependencyResolution test (or compile etc) -Original Message- From: 陈思淼 [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 17, 2008 10:44 AM To: Maven Users List Subject: How to get all dependecy in a mojo ? My mojo extends AbstractWarMojo, I want to get all the Project's dependencies including the transitive denpendecies. So i config the MavenProject in my mojo like thsi: /** * The maven project. * * @parameter expression=${project} * @required * @readonly */ private MavenProject project; project.getArtifacts() is a empty collection. I saw war plugin and them get all the war's dependencies in this way? who can tell me how to get all dependecy in a mojo ? Thank you.
Re: How to get all dependecy in a mojo ?
Here is a snippet from something I'm currently working on. It can see the transitive dependencies with getArtifacts(). in the mojo: * @goal add-externalized-properties * @phase process-resources * @requiresDependencyResolution compile */ public class AddExternalizedPropertiesMojo extends AbstractMojo { ... /** * @parameter expression=${project} * @required * @readonly */ private MavenProject project; -- in resulting META-INF\maven\plugin.xml: plugin ... mojos mojo goaladd-externalized-properties/goal ... requiresDependencyResolutioncompile/requiresDependencyResolution ... phaseprocess-resources/phase -- View this message in context: http://www.nabble.com/How-to-get-all-dependecy-in-a-mojo---tp19533728p19544802.html Sent from the Maven - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]