When using doclet-tags, you should use:
@parameter default-value="${project}"

Robert

Op Sun, 20 Jan 2013 22:34:31 +0100 schreef Jeremy Long <jeremy.l...@gmail.com>:

I am trying to create a simple plugin to inspect project dependencies using the MavenProject - but I'm getting an error because the MavenProject is not
bound (see below for details).

Here is the code for the plugin:

/**
 * Goal that checks project dependencies
 * @goal package
 * @phase package
 * @requiresProject false
 * @requiresDependencyResolution runtime
 * @requiresOnline true
 * @execute phase="package"
 */
public class DependencyCheckMojo extends AbstractMojo {

    /**
     * POM
     *
     * @component
     */
    protected MavenProject project;

    public void execute() throws MojoExecutionException {
        if (project != null) {
            Set<Artifact> artifacts = project.getArtifacts();
            for (Artifact a : artifacts) {
                getLog().error(a.getFile().toString());
            }
        } else {
            getLog().error("Dependency Check - Maven project is null");
        }
    }
}

The POM for the plugin is:

    ....
    <groupId>org.codesecure</groupId>
    <artifactId>DependencyCheck-Plugin</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>maven-plugin</packaging>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-plugin-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <goalPrefix>dependencycheck</goalPrefix>
                </configuration>
                <executions>
                    <execution>
                        <id>mojo-descriptor</id>
                        <goals>
                            <goal>descriptor</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-plugin-api</artifactId>
            <version>3.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-core</artifactId>
            <version>3.0</version>
        </dependency>
    ....


However, when I use this plugin in another project:

            <plugin>
                <groupId>org.codesecure</groupId>
                <artifactId>DependencyCheck-Plugin</artifactId>
                <version>1.0-SNAPSHOT</version>
                <executions>
                  <execution>
                    <phase>package</phase>
                    <goals>
                      <goal>package</goal>
                    </goals>
                  </execution>
                </executions>
            </plugin>

And I run 'mvn package' I get the following error:

[ERROR] Failed to execute goal
org.codesecure:DependencyCheck-Plugin:1.0-SNAPSHO
T:package (default) on project sample: Execution default of goal
org.codesecure:
DependencyCheck-Plugin:1.0-SNAPSHOT:package failed: Unable to load the mojo
'pac
kage' (or one of its required components) from the plugin
'org.codesecure:Depend
encyCheck-Plugin:1.0-SNAPSHOT': com.google.inject.ProvisionException: Guice
prov
ision errors:
[ERROR]
[ERROR] 1) No implementation for org.apache.maven.project.MavenProject was
bound
.
[ERROR] while locating org.codesecure.DependencyCheckMojo


Any idea what I'm doing wrong?

Thanks in advance,

Jeremy

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

Reply via email to