Torsten Curdt wrote:
Ok, guys

By default Maven will only search certain groupIds for plugins. They are "org.apache.maven.plugins" and "org.codehaus.mojo". So for a quick fix to try your plugin you can set the plugin to your groupId to "org.apache.maven.plugins". You can set the groupIds where Maven searches for plugins but use one of the defaults to get you going.

I am trying to get started with writing my first m2 plugin.
But I've run into some problems. (using maven 2.0.1)

I've created a simple mojo:

 /**
  * @goal minijar
  * @description strips unused classes from the dependencies
  * @resolveTransitiveDependencies
  * */
 public final class MiniJarMojo extends AbstractMojo {

    /**
     * @parameter expression="${project.artifacts}"
     * */
    private Set dependencies;

    /**
     * @parameter expression="${project.runtimeClasspathElements}"
     * */
    private Set runtimeClazzpath;

    private File directory;

    public void setOutputDirectory( final String pDirectory ) {
        directory = new File(pDirectory);
    }

    public void execute() throws MojoExecutionException {

        System.out.println("dependencies: " + dependencies);
        System.out.println("classpath: " + runtimeClazzpath);

    }
 }

With the following pom.xml

 <project>
  <parent>
    <artifactId>maven-plugin-parent</artifactId>
    <groupId>org.apache.maven.plugins</groupId>
    <version>2.0</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>
  <groupId>minijar.plugin</groupId>
  <artifactId>maven-minijar-plugin</artifactId>
  <packaging>maven-plugin</packaging>
  <name>Maven MiniJar Plugin</name>
  <version>1.0-SNAPSHOT</version>
  <dependencies>
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-project</artifactId>
    </dependency>
  </dependencies>
 </project>

A "mvn install" works just fine. Then I integrated
the plugin into my project's pom.xml

  <build>
    <sourceDirectory>src/java</sourceDirectory>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>minijar.plugin</groupId>
          <artifactId>maven-minijar-plugin</artifactId>
          <configuration></configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

Now when I call "mvn minijar:minijar" I get the following error...

[INFO] Searching repository for plugin with prefix: 'minijar'.
[INFO] ------------------------------------------------------------------------ ----
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------ ----
[INFO] null
[INFO] ------------------------------------------------------------------------ ----
[INFO] Trace
java.lang.NullPointerException
at org.apache.maven.plugin.descriptor.PluginDescriptor.getMojo (PluginDescriptor.java:259) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.getMojoDescriptor (DefaultLifecycleExecutor.java:1443) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.segmentTaskListByAgg regationNeeds(DefaultLifecycleExecutor.java:378) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute (DefaultLifecycleExecutor.java:134)

Am I missing something obvious here?
Any idea?

cheers
--
Torsten


--
jvz.

Jason van Zyl
jason at maven.org
http://maven.apache.org

We know what we are, but know not what we may be.

  -- Shakespeare

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to