Skip to content

Move gradle-plugin dependencies to the version catalog#3033

Open
KlyneChrysler wants to merge 2 commits into
google:mainfrom
KlyneChrysler:build/2968-catalog-03-gradle-plugin
Open

Move gradle-plugin dependencies to the version catalog#3033
KlyneChrysler wants to merge 2 commits into
google:mainfrom
KlyneChrysler:build/2968-catalog-03-gradle-plugin

Conversation

@KlyneChrysler

Copy link
Copy Markdown
Contributor

Third slice of #2968, following #3026 and #3031.

The Kotlin Gradle plugin artifacts, kotlin-compiler-embeddable, AGP, and Truth move to catalog accessors, and the generateKSPVersions task reads the coroutines version from the catalog. googleTruthVersion is removed from gradle.properties since gradle-plugin was its last consumer. kotlinBaseVersion stays because TestConfig loads gradle.properties directly at test runtime.

Verified that resolution is unchanged: ./gradlew :gradle-plugin:dependencies output for the compile, runtime, testCompile, and testRuntime classpaths is identical before and after this commit. :gradle-plugin:compileTestKotlin passes.

Third slice of google#2968. Adds the Kotlin Gradle plugin artifacts, AGP,
and Truth to the catalog; generateKSPVersions reads the coroutines
version from the catalog. googleTruthVersion is removed from
gradle.properties as gradle-plugin was its last consumer.
kotlinBaseVersion stays: TestConfig loads gradle.properties directly
at test runtime.

@jaschdoc jaschdoc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you for another contribution. I just have one question before proceeding.

compileOnly("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinBaseVersion")
compileOnly("org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlinBaseVersion")
compileOnly(libs.kotlin.gradle.plugin.api)
compileOnly(libs.kotlin.gradle.plugin.asProvider())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could you explain why this is required .asProvider()? :)

@KlyneChrysler KlyneChrysler Jul 10, 2026

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.

The catalog has both kotlin-gradle-plugin and kotlin-gradle-plugin-api, so kotlin-gradle-plugin is simultaneously a leaf alias and a prefix of another alias.

In that case Gradle's generated type safe accessor libs.kotlin.gradle.plugin is an accessor group rather than a dependency provider, and the leaf has to be selected explicitly with .asProvider(). Without it the build script does not compile.

If you prefer cleaner call sites I am happy to rename the aliases instead, for example kotlinGradlePlugin and kotlinGradlePluginApi, which avoids the prefix collision entirely.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Sounds good, thank you for the explanation. Please rename such that the use site is libs.kotlin.gradlePluginApi and libs.kotlin.gradlePlugin.

@jaschdoc jaschdoc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just a minor renaming around the gradle plugin api. Looks good otherwise :)

compileOnly("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinBaseVersion")
compileOnly("org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlinBaseVersion")
compileOnly(libs.kotlin.gradle.plugin.api)
compileOnly(libs.kotlin.gradle.plugin.asProvider())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Sounds good, thank you for the explanation. Please rename such that the use site is libs.kotlin.gradlePluginApi and libs.kotlin.gradlePlugin.

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.

2 participants