How to download and evoke a maven plugin?

How to download and evoke a maven plugin?

This isn’t possible. We hope to add something like this after the Gradle 1.0 release.

How long down the line is this?

I am trying to convert a maven project. My biggest worries are the plugin functionality.

It’s a high priority for post-1.0. We don’t have a date at this point.

For some plugins there is a way to do this today. It is not very convenient but might be an option. Whether you can run a plugin like this, depends on the properties it is using. If those are standard properties it is no problem to inject them from Gradle. If they use Maven domain objects, for example a Maven project object to retrieve information about the dependencies, the following will not work.

What is your scenario? Do you want to reuse custom plugins of your enterprise or standard Maven plugins?

buildscript {
 repositories {
  mavenLocal()
  mavenCentral()
 }
 dependencies {
  classpath "org.sonatype.mavenbook.plugins:first-maven-plugin:1.0-SNAPSHOT"
 }
}
  task testPlugin << {
 def mojo = new org.sonatype.mavenbook.plugins.EchoMojo()
 mojo.message = "Hello from Gradle"
 mojo.execute()
}

The Maven plugin is an example from the Maven book. You need to install it to your local repo. For more details see here: http://books.sonatype.com/books/mvnref-book/reference/writing-plugins-sect-custom-plugin.html

this is interesting. thanks

The line in the example code of def mojo = new org.sonatype.mavenbook.plugins.EchoMojo()

Should that be

org.sonatype.mavenbook.plugins.first-maven-plugin.EchoMojo()?

And will this work a mojo that we have written that takes a set of params?

Done some further work. Yes, it should be org.sonatype.mavenbook.plugins.EchoMojo() Also, looking at the maven book, EchoMojo class is a goal of echo. But within gradle, the goal is not called as it would be within mvn. Instead it is the class that is called. So got there eventually