views:

36

answers:

1

I am trying to generate a maven plugin as described in the maven documentation.

So I created a new plugin project with Eclipse, using the mvn archetype:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.test</groupId>
  <artifactId>hotdeploy</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>maven-plugin</packaging>
  <description>Maven Plugin to hotdeploy portlets to server</description>
  <dependencies>
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-plugin-api</artifactId>
      <version>2.2.1</version>
    </dependency>
  </dependencies>
</project>

I used the created java class file:

package com.test.mavenplugins;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;

/**
 * Hot Deploy something components to local server.
 * @goal hotdeploy
 */
public class HotDeployMojo extends AbstractMojo {
     public void execute() throws MojoExecutionException
        {
            getLog().info("Hello, world.");
        }
}

and ran mvn install without errors. Then I included this plugin in another project:

  <build>
    <plugins>
      <plugin>
        <groupId>com.test</groupId>
        <artifactId>hotdeploy</artifactId>
        <version>0.0.1-SNAPSHOT</version>
      </plugin>
    </plugins>
  </build>

But when I call mvn com.test:hotdeploy:hotdeploy, I get the following error:

[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Required goal not found: com.test:hotdeploy:hotdeploy in com.test:hotdeploy:0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------

Can anybody help me resolve this error?

A: 

Works when passing the version:

$ mvn com.test:hotdeploy:0.0.1-SNAPSHOT:hotdeploy
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building hotdeploy 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- hotdeploy:0.0.1-SNAPSHOT:hotdeploy (default-cli) @ hotdeploy ---
[INFO] Hello, world.
[INFO] ------------------------------------------------------------------------
...

BTW, I'd suggest to follow the maven-$name-plugin or $name-maven-plugin naming convention for the artifactId.

Just in case, you might also want to read:

Pascal Thivent
Sorry, it does not work for me, I still get the same error: "Required goal not found: com.test:hotdeploy:0.0.1-SNAPSHOT:hotdeploy in com.test:hotdeploy:0.0.1-SNAPSHOT"
Bertolt
@Bertolt Weird, I used your code...
Pascal Thivent
@Bertolt I retested with Maven 2.2.1, it just works.
Pascal Thivent
Thanks for trying. I also read the description in the link, but still no success. I also could not figure out yet, why it won't find the goal.
Bertolt