https://docs.gradle.org/current/userguide/custom_plugins.html
Shouldn’t it be:
import org.gradle.api.Project
import org.gradle.api.Plugin
class GreetingPlugin implements Plugin<Project> {
void apply(Project project) {
project.task('hello') << {
println "Hello from the GreetingPlugin"
}
}
}
If I have the “apply” in there I get an error to the effect that GreetingPlugin is defined twice. Includes:
Example 39.1. A custom plugin
Example 39.2. A custom plugin extension
Example 39.3. A custom plugin with configuration closure
Also “39.5.4. Writing tests for your plugin” which reads:
class GreetingPluginTest {
@Test
public void greeterPluginAddsGreetingTaskToProject() {
Project project = ProjectBuilder.builder().build()
project.pluginManager.apply 'org.samples.greeting'
assertTrue(project.tasks.hello instanceof GreetingTask)
}
}
Last line should probably have a test for GreetingPlugin not GreetingTask.