Add Kotlin script template support for Gradle KTS#6792
Merged
Conversation
Leverage K2 FIR compiler extensions to configure implicit receivers and default imports for build.gradle.kts and settings.gradle.kts files. This improves type information for Gradle DSL methods, enabling better recipe matching and method resolution. Implements FirScriptConfiguratorExtension and FirScriptResolutionConfigurationExtension to provide Project/Settings as implicit receivers and Gradle API packages as default imports.
9 tasks
Now that Kotlin script templates provide type information for .gradle.kts files, merge separate GroovyVisitor/KotlinVisitor pairs into single JavaVisitor implementations where possible. - UpdateJavaCompatibility: replace dual GroovyIsoVisitor + KotlinIsoVisitor with a single JavaVisitor that handles both DSLs - UpgradeTransitiveDependencyVersion: replace inline GroovyIsoVisitor and KotlinIsoVisitor literal visitors with shared ChangeStringLiteral, and simplify the constraints precondition check
Replace MethodMatcher-based pluginManagement/buildscript detection with simple name matching, since the synthetic class names (RewriteSettings, RewriteGradleProject) don't match the real types resolved by the K2 compiler (org.gradle.api.initialization.Settings, org.gradle.api.Project).
After FIR analysis, run JvmFir2IrPipelinePhase to populate the irFile field on KotlinSource, enabling future use of IR-based type mapping for improved Kotlin parsing.
Convert ChangeDependencyGroupId and ChangeDependencyArtifactId from GroovyIsoVisitor to JavaIsoVisitor so they work with both Groovy and Kotlin DSL build files.
Update MethodMatcher patterns from synthetic Groovy template types (RewriteGradleProject, RewriteSettings, PluginSpec, Plugin) to real Gradle API types (org.gradle.api.Project, Settings, PluginDependenciesSpec, PluginDependencySpec) with matchOverrides=true, enabling matching for both Groovy DSL and Kotlin DSL scripts.
74221d4 to
19540ab
Compare
The K2 compiler used for KTS parsing loads many JDK modules and consumes significant memory. The default test worker heap is insufficient, causing OutOfMemoryError on CI.
timtebeek
commented
Feb 23, 2026
Comment on lines
+16
to
+19
| import org.gradle.plugin.use.PluginDependenciesSpec | ||
| import org.gradle.plugin.use.PluginDependencySpec | ||
|
|
||
| interface PluginSpec extends PluginDependenciesSpec { |
Member
Author
There was a problem hiding this comment.
Specifically for plugins we're not yet seeing the new improved types available, but I figured we can iterate on that in a subsequent PR and already get the improved types for dependencies merged early.
Contributor
There was a problem hiding this comment.
That's likely because our local method is being preferred over the parent method as the only difference is the return type.
shanman190
approved these changes
Feb 23, 2026
knutwannheden
added a commit
that referenced
this pull request
Feb 24, 2026
Deeply nested Py.Binary nodes (e.g., 256 implicitly concatenated strings in asn1crypto/_teletex_codec.py) overflow Python's default recursion limit (1000) during RPC serialization. Double it to 2000.
macsux
pushed a commit
that referenced
this pull request
Feb 27, 2026
Deeply nested Py.Binary nodes (e.g., 256 implicitly concatenated strings in asn1crypto/_teletex_codec.py) overflow Python's default recursion limit (1000) during RPC serialization. Double it to 2000.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Leverage K2 FIR compiler extensions to configure implicit receivers and default imports for
build.gradle.ktsandsettings.gradle.ktsfiles. This improves type information for Gradle DSL methods, enabling better recipe matching and method resolution.Changes
scriptImplicitReceivers()andscriptDefaultImports()builder methodsProject/Settingsreceivers and Gradle default importsDEFAULT_IMPORTSpublic for reuseTest Plan
rewrite-kotlintests passrewrite-gradletests pass