You can open this sample inside an IDE using the IntelliJ native importer, Eclipse Buildship.

This sample shows how the minimum Gradle version modelling offered by dev.gradleplugins.java-gradle-plugin (and dev.gradleplugins.groovy-gradle-plugin) can improve your Gradle plugin development. The plugin only has dependencies on the redistributed Gradle API, see this chapter for more information. The build also has a minimal configuration with a vanilla TestKit test.

build.gradle
plugins {
	id 'dev.gradleplugins.java-gradle-plugin' version '1.2'
	id 'groovy-base' // for Spock testing
}

gradlePlugin {
	compatibility {
		minimumGradleVersion = '4.9'
	}

	testSourceSets sourceSets.test
	plugins {
		helloWorld {
			id = 'com.example.hello'
			implementationClass = 'com.example.BasicPlugin'
		}
	}
}

repositories {
	mavenCentral()
}

dependencies { (1)
	testImplementation platform('org.spockframework:spock-bom:1.2-groovy-2.5')
	testImplementation 'org.spockframework:spock-core'
	testImplementation gradleTestKit()
}
build.gradle.kts
plugins {
	id("dev.gradleplugins.java-gradle-plugin") version("1.2")
	id("groovy-base") // for Spock testing
}

gradlePlugin {
	compatibility {
		minimumGradleVersion.set("4.9")
	}

	testSourceSets(sourceSets.test.get())
	plugins {
		create("helloWorld") {
			id = "com.example.hello"
			implementationClass = "com.example.BasicPlugin"
		}
	}
}

repositories {
	mavenCentral()
}

dependencies { (1)
	testImplementation(platform("org.spockframework:spock-bom:1.2-groovy-2.5"))
	testImplementation("org.spockframework:spock-core")
	testImplementation(gradleTestKit())
}

To build and test the plugin:

$ ./gradlew test

BUILD SUCCESSFUL
6 actionable tasks: 6 executed

The plugin builds and executes the test as expected. The important point here is the implicit dependencies:

$ ./gradlew dependencies
...
compileClasspath - Compile classpath for source set 'main'.
\--- dev.gradleplugins:gradle-api:4.9
     \--- org.codehaus.groovy:groovy:2.4.12
...
testRuntimeClasspath - Runtime classpath of source set 'test'.
+--- org.spockframework:spock-bom:1.2-groovy-2.5
|    \--- org.spockframework:spock-core:1.2-groovy-2.5 (c)
\--- org.spockframework:spock-core -> 1.2-groovy-2.5
     +--- org.codehaus.groovy:groovy:2.5.2
     +--- org.codehaus.groovy:groovy-json:2.5.2
     |    \--- org.codehaus.groovy:groovy:2.5.2
     +--- org.codehaus.groovy:groovy-nio:2.5.2
     |    \--- org.codehaus.groovy:groovy:2.5.2
     +--- org.codehaus.groovy:groovy-macro:2.5.2
     |    \--- org.codehaus.groovy:groovy:2.5.2
     +--- org.codehaus.groovy:groovy-templates:2.5.2
     |    +--- org.codehaus.groovy:groovy:2.5.2
     |    \--- org.codehaus.groovy:groovy-xml:2.5.2
     |         \--- org.codehaus.groovy:groovy:2.5.2
     +--- org.codehaus.groovy:groovy-test:2.5.2
     |    +--- org.codehaus.groovy:groovy:2.5.2
     |    \--- junit:junit:4.12
     |         \--- org.hamcrest:hamcrest-core:1.3
     +--- org.codehaus.groovy:groovy-sql:2.5.2
     |    \--- org.codehaus.groovy:groovy:2.5.2
     +--- org.codehaus.groovy:groovy-xml:2.5.2 (*)
     \--- junit:junit:4.12 (*)
...

We can see the Gradle 4.9 API dependencies for the compileClasspath, and the absence of the API dependencies for testRuntimeClasspath as expected.

For more information, see Gradle Plugin Development reference chapters and user manual chapter.