Meet
09/17/2025, 9:37 AM.gradle and .gradle.kts files into Kotlin data classes?Meet
09/17/2025, 9:38 AMplugins and dependencies from Gradle build files and map them into Kotlin data classes.
Example Groovy DSL (build.gradle):
plugins {
id 'com.android.application' version '8.1.0'
}
dependencies {
implementation "androidx.core:core-ktx:1.12.0"
}
Example Kotlin DSL (build.gradle.kts):
plugins {
id("com.android.application") version "8.1.0"
}
dependencies {
implementation("androidx.core:core-ktx:1.12.0")
}
Target data classes:
data class PluginEntry(val id: String, val version: String?)
data class DependencyEntry(val configuration: String, val notation: String)
data class GradleFile(
val plugins: List<PluginEntry>,
val dependencies: List<DependencyEntry>
)
👉 How can I parse both .gradle and .gradle.kts files into such Kotlin data classes?
• Is there a library for this?
• Or do I need different approaches for Groovy DSL and Kotlin DSL?Vampire
09/17/2025, 10:42 AMMeet
09/17/2025, 10:44 AMephemient
09/17/2025, 1:47 PMplugins blocks directly,
https://github.com/gradle/gradle/blob/master/platforms/core-configuration/kotlin-dsl/src/main/kotlin/org/gradle/kotlin/dsl/execution/PluginsBlockInterpretation.kt
but there is no guarantee that it will succeed and Gradle will fall back to executing the code to determine which plugins have been requestedephemient
09/17/2025, 1:48 PMMeet
09/17/2025, 1:51 PMVampire
09/17/2025, 2:23 PMPiotr Krzemiński
09/18/2025, 7:13 AMMeet
09/18/2025, 7:15 AMMeet
09/18/2025, 7:16 AMMeet
11/04/2025, 3:39 PMMeet
11/06/2025, 5:25 AM