I just installed the maven eclipse plugin and all is great. I have tried creating my first mojo. After the setup, it has downloaded all the required dependencies.
Now what is troubling me is that Eclipse isn't able to resolve the org.apache.maven.plugins
classes.
My pom.xml :
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.blah.dalm.mojo</groupId>
<artifactId>assembly-mojo</artifactId>
<packaging>maven-plugin</packaging>
<name>Assembly Mojo</name>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>${basedir}</sourceDirectory>
<!-- Plugin Configurations -->
<plugins>
<!-- Compiler plugin to use 1.6 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<executions>
<execution>
</execution>
</executions>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<!-- Dependencies -->
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.0</version>
</dependency>
</dependencies>
</project>
My mojo file AssemblyMojo.java:
package com.blah.dalm.mojo;
import java.util.List;
import org.apache.maven.plugin.MojoExecutionException; // <-- This is where it says it cannot resolve the class or package.
/**
* "Assemble Goal"
* @goal assemble-goal
* @author Husain Khambaty
*
*/
public class AssemblyMojo {
/**
* @parameter expression="${assembly.sourcePath}"
* @required
*/
private String sourcePath;
/**
* @parameter expression="${assembly.outputPath}"
* @required
*/
private String outputFilePath;
/**
* @parameter
*/
private List<String> excludeList;
/**
* @parameter
*/
private String filterRule;
public void execute() throws MojoExecutionException { // <-- And here
}
}
It is unable to resolve the MojoExectionException class (therefore I believe it isn't able to find the rerquired jars, which I guess it is supposed to automatically fetch after the Eclipse-Maven integration).
When I build it, it builds just fine.