-
-
Notifications
You must be signed in to change notification settings - Fork 124
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
Kotlin 2: bug when using associateWith: redeclaring dependencies on child configurations, leading to erroneous advice to remove or change dependencies that don't exist in build scripts #1239
Comments
I posted a Kotlin Slack thread to ask whether there were any notable changes to how KGP handles source sets in 2.0.20: https://kotlinlang.slack.com/archives/C0KLZSCHF/p1723827452933009. |
I tested the just-released 2.0.20. No change. |
Just FYI, I tested with DAGP 2.0.0 and Kotlin 2.0.20. No change. |
I am confused! When you use It sounds like this was broken before but is working now 🤔 The documentation on this seems to be misleading. I can see how it would appear as if the DSL is saying "exclude from ABI analysis, which therefore means we don't say one way or the other about the ABI and Please let me know if I'm misreading the situation. Thanks! |
Thank you for looking into this! I too am confused, because I'm not declaring anything as an Whereas no advice is given with 2.0.20-Beta1 and before, here is all the advice for my reproducer when I change nothing other than upgrading to 2.0.20-Beta2 or later:
Focusing in on:
...those particular dependencies are declared as dependencies {
api(libs.spring.context)
api(libs.springboot)
[...] Looking at:
...those are all Thank you for the explanation of how ABI exclusions work. I agree it's useful for DAGP to advise when something is declared in an |
wow, what a weird bug, in that case! |
I'm afraid this is due to some change in KGP -- I would argue it is a rather extreme bug. At this line, I dropped a breakpoint, and I've attached a screenshot below showing the dependencies that are declared on the As you know, you have not declared those dependencies yourself in your build scripts. My best guess is that KGP is re-declaring upstream dependencies on downstream/child configurations. So, you declare something on There is literally nothing DAGP can do here. It's operating on the information that Gradle gives it, which is based on what the build scripts and plugins in a project are doing. I say it's an extreme bug because it almost just breaks DAGP for Kotlin 2. Plugins should be really reticent to add dependencies, and KGP is a, well, extreme offender in this case. |
It seems that may very well be the case. I forgot to post earlier that JetBrains created an issue to look into this: https://youtrack.jetbrains.com/issue/KT-70871 I'll add a reference to these details there, and follow it for updates. |
A workaround for this and similar issues is to remove the auto-added dependencies in a Here is an example to remove the dependency that is automatically added by Gradle's test suites plugin:
org.example.gradle.feature.test.gradle.kts I think I said this before in similar issues here: I think every plugin that automatically adds dependencies because it wants to provide some convenience should have an option to turn that off. But as we see on the above example, even the Gradle core plugins do not always offer that. |
…o `integrationTestImplementation` for autonomousapps/dependency-analysis-gradle-plugin#1239.
Thank you for the workaround idea, @jjohannes! In the case of any overlap, how could you know which
|
Can you use the |
…tonomousapps/dependency-analysis-gradle-plugin#1239 by ignoring the integration test source set.
…y-analysis-gradle-plugin#1239 by ignoring the integration test source set.
Rather than trying to hack what KGP is doing, I've decided to just Hopefully JetBrains will reopen KT-70871, or at least respond to our questions there with something that offers a way forward. |
Build scan link
https://scans.gradle.com/s/lozbs26qkgomy
Plugin version
1.33.0
Gradle version
8.9 and 8.10
JDK version
11.0.24
(Optional) Kotlin and Kotlin Gradle Plugin (KGP) version
2.0.20-Beta2, 2.0.20-RC, and 2.0.20-RC2.
(Optional) Android Gradle Plugin (AGP) version
N/A
(Optional)
reason
output for bugs relating to incorrect adviceNumerous, but for example:
Describe the bug
Per #1026, I've been using the following in the precompiled script plugins for my custom JVM Test Suite Plugin suites:
With Kotlin 2.0.20-Beta1 and prior this works, and I don't get any advice to change
<testSuiteName>Api
dependencies to<testSuiteName>Implementation
.If I upgrade from 2.0.20-Beta1 to 2.0.20-Beta2, 2.0.20-RC, or 2.0.20-RC2, with no other changes, all that advice returns as if I wasn't filtering my test suite source sets from ABI analysis.
To Reproduce
gradlew buildHealth
.2.0.20-Beta2 reproducer:
https://github.com/sdkotlin/sd-kotlin-spring-talks/tree/f55c327ee46061982ceebdd745070cc78d5fa831
It does not reproduce with Kotlin 2.0.20-Beta1:
https://github.com/sdkotlin/sd-kotlin-spring-talks/tree/bcc1b9538b173a4b4be8ad7490808feb258d733f
It does not reproduce with a different but similarly-configured project when it's upgraded to Kotlin 2.0.20-Beta2:
https://github.com/sdkotlin/sd-kotlin-talks/tree/0b57a33323aa1d9209762d5a8ab4c652605e877a
Expected behavior
No
<testSuiteName>Api
to<testSuiteName>Implementation
advice when ABI filtering the corresponding source sets.Additional context
This seems to be at least a partial regression of #1026 with Kotlin 2.0.20-Beta2+.
The text was updated successfully, but these errors were encountered: