Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle test executors use the wrong version of Kotlin stdlib with java-gradle-plugin #12692

Open
cesar1000 opened this issue Apr 1, 2020 · 5 comments

Comments

@cesar1000
Copy link

cesar1000 commented Apr 1, 2020

Expected Behavior

Tests should use the version of Kotlin stdlib declared in the test runtime classpath.

Current Behavior

When applying java-gradle-plugin, tests use Kotlin stdlib 1.3.61 consistently (with Gradle 6.2.2), even if the build is configured to use 1.3.71.

Context

It seems like the application classpath of the test executor worker contains version 1.3.61 of Kotlin stdlib, and that gets picked up at runtime even of the build is configured to use 1.3.71:

image

The application classpath in the debug logs looks like this:

<test class directories>
~/.gradle/caches/6.2.2/generated-gradle-jars/gradle-api-6.2.2.jar
~/.gradle/wrapper/dists/gradle-6.2.2-bin/1q1x0w9jt7yxk5iea7m897kou/gradle-6.2.2/lib/groovy-all-1.3-2.5.8.jar
~/.gradle/wrapper/dists/gradle-6.2.2-bin/1q1x0w9jt7yxk5iea7m897kou/gradle-6.2.2/lib/kotlin-stdlib-1.3.61.jar
<other gradle dependencies>
<my test runtime classpath>
~/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.71/898273189ad22779da6bed88ded39b14cb5fd432/kotlin-stdlib-1.3.71.jar
...

Steps to Reproduce

A Kotlin project with java-gradle-plugin and Kotlin stdlib 1.3.71 would do. Just watch for KotlinVersion.CURRENT in your test.

Your Environment

Gradle 6.2.2 with Kotlin 1.3.71

@ljacomet
Copy link
Member

ljacomet commented Jun 4, 2020

@cesar1000 Thanks for the report.
Any chance you can share a small reproducer?

@cesar1000 cesar1000 changed the title Gradle test executors use the wrong version of Kotlin stdlib Gradle test executors use the wrong version of Kotlin stdlib with java-gradle-plugin Jun 8, 2020
@cesar1000
Copy link
Author

It looks like the issue shows up when using java-gradle-plugin, which seems to skip dependency resolution and insert its own version of Kotlin in the classpath. In this example, the version in the classpath is 1.3.72, but the actual version used at runtime by the test is 1.3.70:

image

I put up a tiny reproducer here: https://github.com/cesar1000/wrong-kotlin-version.

@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. If you're interested in how we try to keep the backlog in a healthy state, please read our blog post on how we refine our backlog. If you feel this is something you could contribute, please have a look at our Contributor Guide. Thank you for your contribution.

@stale stale bot added the stale label Apr 16, 2022
@stale
Copy link

stale bot commented Jun 19, 2022

This issue has been automatically closed due to inactivity. If you can reproduce this on a recent version of Gradle or if you have a good use case for this feature, please feel free to to let know so we can reopen the issue. Please try to provide steps to reproduce, a quick explanation of your use case or a high-quality pull request.

@stale stale bot closed this as completed Jun 19, 2022
@eskatos eskatos removed the stale label Jun 21, 2022
@eskatos eskatos reopened this Jun 21, 2022
@martinbonnin
Copy link
Contributor

I think this is an instance of #1835. java-gradle-plugin pulls gradleApi() and gradleTestKit(). The surprising thing is that they do not appear in ./gradlew dependencies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants