Skip to content

[Gradle] Ensure Kotlin ecosystem plugin brings Kotlin Gradle plugin classes into build classpath#6296

Open
Yahor Berdnikau (Tapchicoma) wants to merge 2 commits into
masterfrom
yahor/kt-78294-fix-settings-plugin
Open

[Gradle] Ensure Kotlin ecosystem plugin brings Kotlin Gradle plugin classes into build classpath#6296
Yahor Berdnikau (Tapchicoma) wants to merge 2 commits into
masterfrom
yahor/kt-78294-fix-settings-plugin

Conversation

@Tapchicoma

Copy link
Copy Markdown
Contributor

Due to Gradle classloaders hierarchy - depending only on Kotlin Gradle
plugins, bom is not enough, as BOM is not applied to child classloaders.
To fix it, ecosystem plugin should bring Kotlin Gradle plugin as direct
dependency, so it will override any versions from child sub-classloaders.

This change should be fine as now we allow users to just override Kotlin
compiler version via 'kotlin.compilerVersion', so pinning KGP version
should not be a problem for them.

^KT-78294 Verification Pending

@kotlin-safemerge

kotlin-safemerge Bot commented Jun 17, 2026

Copy link
Copy Markdown

Code Owners

RuleOwnersApproval
**.​gradle.​kts, /​repo/​sellmair
kotlin-build-infrastructure

CristianGM
/​libraries/​tools/​kotlin-​gradle-​plugin-​integration-​tests/​
kotlin-build-tools

Egorand 🔒

@Egorand Egor Andreevich (Egorand) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have concerns about how future-proof the approach is, but overall looks good!

/final


dependencies {
commonApi(platform(project(":kotlin-gradle-plugins-bom")))
commonApi(project(":kotlin-gradle-plugin"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My main concern is that I believe this would break if kotlin-dsl adds another dependency governed by kotlin-gradle-plugins-bom, and we'll have to then explicitly add it here to avoid another version clash? Though if the possibility of kotlin-dsl acquiring another dependency is very low then I'm fine with this approach. I'd suggest adding a comment explaining why we're doing this!

A larger question I guess is whether we want the ecosystem plugin to enforce version alignment across subprojects (including buildSrc) of a project it's added to? I'm not familiar with how to properly do this from a settings plugin, but component metadata rules seems to be one way?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is a build scan from the added test. As you see kotlin-dsl plugin still brings KGP and kotlin-sam-with-receiver plugins version 1.7.10 (Gradle Kotlin runtime) and it does not fail the build.

1.7.10 version here could be surprising but on the classloaders level it shoud use the snapshot one brought by settings plugin.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A larger question I guess is whether we want the ecosystem plugin to enforce version alignment across subprojects (including buildSrc) of a project it's added to?

I would say - no. Included projects should be self-contained, and we should not try to align versions between them. Specifically, from use-case of dynamically added included builds.

@Egorand Egor Andreevich (Egorand) Jun 18, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is a build scan from the added test. As you see kotlin-dsl plugin still brings KGP and kotlin-sam-with-receiver plugins version 1.7.10 (Gradle Kotlin runtime) and it does not fail the build.

1.7.10 version here could be surprising but on the classloaders level it shoud use the snapshot one brought by settings plugin.

Right, but I imagine it would still eventually use version 1.7.10 of kotlin-sam-with-receiver? My guess is that there's either no binary incompatibility between kotlin-sam-with-receiver:1.7.10 and kotlin-sam-with-receiver:2.4.255-SNAPSHOT, or kotlin-dsl doesn't really use any API from that plugin. If it did - we would've probably had to add an explicit dependency on kotlin-sam-with-receiver to the ecosystem plugin as well? Which demonstrates the larger problem: any Kotlin artifacts kotlin-dsl depends on, the ecosystem plugin should depend on as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My guess is that there's either no binary incompatibility between kotlin-sam-with-receiver:1.7.10 and kotlin-sam-with-receiver:2.4.255-SNAPSHOT

There is definitely some binary incompatibility between these versions

@Tapchicoma

Copy link
Copy Markdown
Contributor Author

/safe-merge

@kotlin-safemerge

Copy link
Copy Markdown

Command rejected: Missing code owners approval - verify the check 'Code Owners Approval' is green.

@Tapchicoma

Copy link
Copy Markdown
Contributor Author

/safe-merge

@kotlin-safemerge kotlin-safemerge Bot force-pushed the yahor/kt-78294-fix-settings-plugin branch from b46cf54 to e950b91 Compare June 18, 2026 12:39
@KotlinBuild

Build Server (KotlinBuild) commented Jun 18, 2026

Copy link
Copy Markdown

Quality gate is triggered at https://buildserver.labs.intellij.net/build/977605352 — use this link to get full insight.

Quality gate was triggered with the following revisions:

kotlin
Branch: refs/merge/GITHUB-6296/safe-merge
Commit: d0ba496


Triggered a retry attempt №1 out of 1.


Quality gate failed. See https://buildserver.labs.intellij.net/build/977605352 to get full insight.

@kotlin-safemerge kotlin-safemerge Bot dismissed Cristian Garcia (CristianGM)’s stale review June 18, 2026 16:17

New changes affect files owned by this reviewer. Re-review is required.
For internal PRs, review can be finalized by adding /final to the approving message.

@Tapchicoma

Copy link
Copy Markdown
Contributor Author

/dry-run

@KotlinBuild

Build Server (KotlinBuild) commented Jun 19, 2026

Copy link
Copy Markdown

THIS IS A DRY RUN

Quality gate is triggered at https://buildserver.labs.intellij.net/build/978394619 — use this link to get full insight.

Quality gate was triggered with the following revisions:

kotlin
Branch: refs/merge/GITHUB-6296/safe-merge
Commit: 1679231


Quality gate failed. See https://buildserver.labs.intellij.net/build/978394619 to get full insight.

@Tapchicoma

Copy link
Copy Markdown
Contributor Author

/safe-merge

@kotlin-safemerge

Copy link
Copy Markdown

Autosquash aborted: Conflict detected in file(s): libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/testbase/testGradleBuildInjection.kt. Commit 'fixup! [Gradle] Fix build scan option in tests for newer Gradle versions' and fixup 'fixup! fixup! [Gradle] Ensure Kotlin ecosystem plugin brings Kotlin Gradle plugin classes into build classpath' both modify these files. Please rebase manually.

@Tapchicoma Yahor Berdnikau (Tapchicoma) force-pushed the yahor/kt-78294-fix-settings-plugin branch from 29d4596 to 4aef012 Compare June 19, 2026 11:47
@Tapchicoma

Copy link
Copy Markdown
Contributor Author

/safe-merge

@KotlinBuild

Build Server (KotlinBuild) commented Jun 19, 2026

Copy link
Copy Markdown

Quality gate is triggered at https://buildserver.labs.intellij.net/build/978615867 — use this link to get full insight.

Quality gate was triggered with the following revisions:

kotlin
Branch: refs/merge/GITHUB-6296/safe-merge
Commit: 4aef012


Triggered a retry attempt №1 out of 1.

@Tapchicoma

Copy link
Copy Markdown
Contributor Author

/safe-merge

@kotlin-safemerge

Copy link
Copy Markdown

Command rejected: A Coordinator build is already in progress for this pull request. Please wait for it to finish or cancel it with /cancel-coordinator

@Tapchicoma

Copy link
Copy Markdown
Contributor Author

/cancel-coordinator

@Tapchicoma

Copy link
Copy Markdown
Contributor Author

/safe-merge

@kotlin-safemerge

Copy link
Copy Markdown

Autosquash aborted: Conflict detected in file(s): libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/testbase/testGradleBuildInjection.kt. Commit '[Gradle] Fix build scan option in tests for newer Gradle versions' and fixup 'fixup! [Gradle] Ensure Kotlin ecosystem plugin brings Kotlin Gradle plugin classes into build classpath' both modify these files. Please rebase manually.

…lasses into build classpath

Due to Gradle classloaders hierarchy - depending only on Kotlin Gradle
plugins, bom is not enough, as BOM is not applied to child classloaders.
To fix it, ecosystem plugin should bring Kotlin Gradle plugin as direct
dependency, so it will override any versions from child sub-classloaders.

This change should be fine as now we allow users to just override Kotlin
 compiler version via 'kotlin.compilerVersion', so pinning KGP version
 should not be a problem for them.

 ^KT-78294 Verification Pending
Since Gradle 9.5 develocity plugin is used by default when `--scan`
option is provided to the build.
@Tapchicoma Yahor Berdnikau (Tapchicoma) force-pushed the yahor/kt-78294-fix-settings-plugin branch from 2b4ca99 to 3be13a0 Compare June 19, 2026 13:56
@Tapchicoma

Copy link
Copy Markdown
Contributor Author

/safe-merge

@KotlinBuild

Build Server (KotlinBuild) commented Jun 19, 2026

Copy link
Copy Markdown

Quality gate is triggered at https://buildserver.labs.intellij.net/build/978762649 — use this link to get full insight.

Quality gate was triggered with the following revisions:

kotlin
Branch: refs/merge/GITHUB-6296/safe-merge
Commit: 3be13a0


Triggered a retry attempt №1 out of 1.


Quality gate failed. See https://buildserver.labs.intellij.net/build/978762649 to get full insight.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants