to create a scala mojo you need to add scala support into your pom.xml for a normal mojo project
<project> ... <dependencies> <dependency> <groupId>org.apache.maven</groupId> <artifactId>maven-plugin-api</artifactId> <version>2.0</version> </dependency> <dependency> <groupId>com.jsuereth</groupId> <artifactId>scala-mojo-support</artifactId> <version>0.4</version> </dependency> ... </dependencies> <build> <plugins> <plugin> <groupId>org.scala-tools</groupId> <artifactId>maven-scala-plugin</artifactId> <executions> <execution> <goals> <goal>add-source</goal> <goal>compile</goal> <goal>testCompile</goal> </goals> </execution> </executions> </plugin> <plugin> <artifactId>maven-plugin-plugin</artifactId> <dependencies> <dependency> <groupId>com.jsuereth</groupId> <artifactId>scala-mojo-support</artifactId> <version>0.4</version> </dependency> </dependencies> </plugin> ... </plugins> </build> <repositories> <repository> <id>scala-tools.org</id> <name>Scala-tools Maven2 Repository</name> <url>http://scala-tools.org/repo-releases</url> </repository> ... </repositories> <pluginRepositories> <pluginRepository> <id>scala-tools.org</id> <name>Scala-tools Maven2 Repository</name> <url>http://scala-tools.org/repo-releases</url> </pluginRepository> ... </pluginRepositories> ... </project>
To create a scala mojo goal, simple create a scala class that extends AbstractMojo and annotate it appropriately, e.g.
package org.scala_tools.mojo import org.apache.maven.plugin._ import java.io.File /** * Goal which echos "HAI" * * @goal echo * * @phase process-sources */ class TestMojo extends AbstractMojo { /** * Location of the file. * @parameter expression="${project.build.directory}" * @required */ var outputDirectory : File = _; @throws(classOf[MojoExecutionException]) override def execute() { getLog.error("HAI") getLog.error("outputDirectory = " + outputDirectory);//.getAbsolutePath); } }