Dependencies: gradleApi() and gradleTestKit() does not coexist


(xtracoder) #1

In my test project i’m trying to unit-test my gradle plugin and follow steps described here:
https://docs.gradle.org/current/userguide/test_kit.html

At the same time I need some generic Gradle APIs, therefore I add

dependencies {
	compile gradleApi()
}

After that invocation of

GradleRunner.create()
        .with....
        .build();

Results in

Exception in thread "main" java.lang.NoSuchMethodError: org.gradle.tooling.internal.consumer.DefaultBuildLauncher.withInjectedClassPath(Lorg/gradle/testkit/jarjar/org/gradle/internal/classpath/ClassPath;)Lorg/gradle/tooling/internal/consumer/AbstractLongRunningOperation;
	at org.gradle.testkit.runner.internal.ToolingApiGradleExecutor.run(ToolingApiGradleExecutor.java:98)
	at org.gradle.testkit.runner.internal.DefaultGradleRunner.run(DefaultGradleRunner.java:270)
	at org.gradle.testkit.runner.internal.DefaultGradleRunner.build(DefaultGradleRunner.java:219)
	at my.MyTestMain.testViaGradleRunner(MyTestMain.java:32)
	at my.MyTestMain.main(MyTestMain.java:20)