Could not find implementation class for plugin error when using plugin "java-gradle-plugin"

Gradle 4.10.2

I’ve read this post but I may have a different issue, but I’m not sure.

This is my first time writing a plugin so I’m just following Writing Gradle Plugins tutorial, and Gradle Plugin Development Plugin.

Here’s my plugin’s build.gradle file

apply plugin: 'java'
apply plugin: 'java-gradle-plugin'

gradlePlugin {
    plugins {
        simplePlugin {
            id = 'org.example.greeting-plugin'
            implementationClass = 'org.example.greeting.GreetingPlugin'

However when I get this when I build

$ ./gradlew clean build

**> Task :jar**

:jar: A valid plugin descriptor was found for but the implementation class org.example.greeting.GreetingPlugin was not found in the jar.


How can I fix it?

The tutorial has the source code in the /top-level/buildSrc/src... tree. Once I moved it to the /top-level/src/... tree, it worked.