You need to add: @requiresDependencyResolution
HTH, Brett On 9/6/05, Ashley Williams <[EMAIL PROTECTED]> wrote: > > I've been bashing my head against a brick wall trying to get the list > of artifacts back from the project object for my plugin but > project.getArtifacts() always returns an empty list whereas I expect > the list of artifacts corresponding to the target pom <dependency> tags. > > 1. I recreated the problem by creating a default project like so: > m2 archetype:create -DgroupId=acme -DartifactId=test - > DarchetypeArtifactId=maven-archetype-mojo > > 2. then I replaced the generated mojo with this class that has a goal > called test and whose execute method just prints out the artifacts > size and it always prints out zero: > > package com.mycompany; > > import org.apache.maven.plugin.AbstractMojo; > import org.apache.maven.plugin.MojoExecutionException; > import org.apache.maven.project.MavenProject; > > /** > * Test Mojo > * > * @goal test > * > * @execute phase="generate-sources" > */ > public class MyMojo extends AbstractMojo { > /** > * @parameter expression="${project}" > * @required > */ > private MavenProject project; > > public void execute() throws MojoExecutionException { > System.out.println("project.getName()=" + project.getName()); > System.out.println("project.getArtifacts().size()=" > + project.getArtifacts().size()); > } > } > > (So that it would compile I had to add a dependency in the pom: > <dependency> > <groupId>org.apache.maven</groupId> > <artifactId>maven-project</artifactId> > <version>2.0-beta-1-SNAPSHOT</version> > </dependency>) > > 3. Finally I ran the plugin in the same directory as my target poms > like so: > m2 acme:test:1.0-SNAPSHOT:test > > and got the following results no matter which pom I ran it against: > > project.getName()=MBean Demo > project.getArtifacts().size()=0 > > > Notice that the name that is printed corresponds to the target pom so > the plugin does manage to pick up some details ok. > > Maybe I should get the dependencies using a different api, but its > the same call used by the eclipse plugin at > EclipseWriter.writeEclipseClasspath just before the call to > addDependency(). > > Anyone shed any light? > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >