PluginApplicationException error caused by variable hidding

I am writing a custom plugin using Gradle 2.9, and I get this error when I run the plugin test:

org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id 'simple-example']

I have narrowed down the error to this Groovy code:

import org.gradle.api.DefaultTask;
import org.gradle.api.tasks.TaskAction;

public class SimpleExampleTask extends DefaultTask {
    public static final String NAME = "simpleExample";

    // Change "name" to "name1" and the test passes
    // Or declare it as public to disable Groovy's automatic get/set accessor methods
    String name;

    @TaskAction
    void run() {
        System.out.println("Hello");
    }
}

By trial and error, and by running it as Java instead of Groovy, I discovered that the “name” variable caused the AbstractTask.getName() method to become hidden, wrecking havoc. Part of why this was so hard to figure out is because Groovy creates get/set accessor methods with the name variable, unless the variable is explicitly declared as public.

The error message threw me off for a while. I doubt the error message can be improved, but you can see this problem in action when cloning this project on github.