NoSuchMethodError in TestKit after 2.9 -> 2.10 transition

After upgrading from 2.9 to 2.10, we are getting this error when calling GradleRunner.create()....build():

org.gradle.tooling.internal.consumer.DefaultBuildLauncher.withInjectedClassPath(Lorg/gradle/testkit/jarjar/org/gradle/internal/classpath/ClassPath;)Lorg/gradle/tooling/internal/consumer/AbstractLongRunningOperation;
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:261)
	at org.gradle.testkit.runner.internal.DefaultGradleRunner.build(DefaultGradleRunner.java:210)

It seems to be related to this change that moved withInjectedClassPath method between classes - this caused binary incompatibility in Java ByteCode.

Hi Augi,

This is a known issue and is fixed in the next release. To fix with 2.10, you need to ensure that the test-kit jar is earlier on the classpath than the gradle-core jar. How do you have your dependencies specified? e.g. what does your dependencies {} block look like?

Don’t upgrade 2.10 it has lots of bugs. 2.9 is better in many ways. I have similar issue and post my queries at various iphone Developer forum but no solve my query. and get back to my old 2.9 version

Thank you, Luke, for confirmation that it’s a known bug.

The order is actually not clean to be because some dependencies are defined in root project (in subprojects section). I will wait for a new release…

@augi,

You could use a nightly build prior to the next release if you need to.

Tried 2.10 and 2.11-rc-1: still broken in the same way.
Regressed to 2.9 - working again.

Working with Intellij IDEA 15.0.3, project imported with Standard IDEA mechanism (not the IDE gradle plugin).

@shorn1 No work has been done regarding this issue in the meantime.

Unfortunately, it doesn’t seems to be fixed in Gradle 2.11 :frowning:

Tried 2.12-20160210000018+0000 nightly build, it doesn’t seems to be fixed.

I understand the frustration but no work has been done on this issue in the meantime. You can fix it in the IDE by changing the order of the classpath. Simply move the TestKit JAR before the Tooling API JAR.

I will post an explicit message here when we get around to fixing it.

Our company recently switched to gradle build system from primary scons build system. Whole bunch of our integration tests broken when we switched to gradle 2.10. I had to answer a whole bunch of WHY??? from devs and from management and ignore all of our integration tests. We are intended to have our first release with gradle build system in next 2-3 months.

I look forward to the fix for this.

Cheers,
Tony

The following plugin can be used to work around this issue until it is resolved: https://plugins.gradle.org/plugin/com.palantir.idea-test-fix

We wrote this plugin after encountering this issue in our own Gradle plugin development in IDEA – it automatically does the classpath re-ordering (moves TestKit before the Tooling API JAR) whenever the idea task is run. Applying this plugin to a project, re-running the idea task and re-importing the resulting project in IDEA should fix the issue.

@bmuschko, is there a JIRA bug that tracks the underlying issue? Would be interested in following it since the best-case scenario would be for the root issue to be fixed (and depending on the scope/current prioritization and what the fix would involve, might be interested in working on it as well).

The issue is likely going to be fixed with Gradle 2.14. I created GRADLE-3433 to track the issue.