https://kotlinlang.org logo
Join Slack
Powered by
# gradle
  • a

    alexhelder

    08/21/2025, 1:02 AM
    What are people using to check if their dependencies are up to date? I was using ben-manes/gradle-versions-plugin but it stopped working with Gradle 9 / AGP 8.12.0
    c
    b
    v
    • 4
    • 11
  • t

    Teodora Mihaila

    08/21/2025, 12:14 PM
    Hi everyone! I'm working on adding OpenRewrite support for Kotlin 2.+. I am trying to build on top of the following PR. When trying to build the
    rewrite-kotlin
    module I get the following error:
    Copy code
    Caused by: java.lang.NoSuchMethodError: 'org.jetbrains.kotlin.buildtools.api.jvm.ClasspathEntrySnapshot org.jetbrains.kotlin.buildtools.api.CompilationService.calculateClasspathSnapshot(java.io.File, org.jetbrains.kotlin.buildtools.api.jvm.ClassSnapshotGranularity, boolean)'
    along with the following warning:
    Copy code
    w: ⚠️ 'org.jetbrains.kotlin:kotlin-compiler-embeddable' Artifact Present in Build Classpath
    The artifact `org.jetbrains.kotlin:kotlin-compiler-embeddable` is present in the build classpath along Kotlin Gradle plugin.
    This may lead to unpredictable and inconsistent behavior.
    I think it's important mentioning that I get when same error even when just trying to upgrade from Kotlin 1.9.25 to 2.2.0 in the main repo without the changes from the PR. From what I understand the cause of the error is a transitive dependency from the Kotlin Gradle plugin that introduces an older version on the build class path. So far I have tried to fix this by doing the following: 1. Exploring the config files for any hardcoded old Kotlin version, but nothing was found. 2. Commenting out the dependencies in the
    build.gradle.kts
    file of rewrite-kotlin
    module
    to prevent transitive leaks. Nothing changed. 3. Using the following command:
    ./gradlew :rewrite-kotlin:dependencies | grep -A 5 "kotlin-compiler-embeddable"
    to check which version of
    kotlin-compiler-embeddable
    was Gradle resolving. The versions all appeared to match the set Kotlin language version. 4. Disabled classpath snapshots into
    gradle.properties
    by adding:
    kotlin.incremental.useClasspathSnapshot=false
    . Nothing changed. 5. Testing multiple Gradle/JDK combinations: Gradle versions between 8.14.3 & 9.0.0 with JDK 17, 21, 23, 24. Nothing changed. Does anyone have any pointers on what could be going wrong and how to fix it?
    t
    m
    v
    • 4
    • 22
  • t

    tapchicoma

    08/21/2025, 3:38 PM
    gradle intensifies In the Kotlin team we've started looking into Kotlin DSL for Declarative Gradle. It is our chance to fix problems in existing KMP kts DSL without going through painful breaking changes. One of the challenges we have is how to design DSL for generic Kotlin library. Specifically configuration that applies to a family of Kotlin targets, not all targets. If you have some examples of shared configuration that you apply to subset of enabled targets in your existing library projects - please share them in the thread to this message. Also generic ideas on how Kotlin Library DCL DSL could look like are also welcome.
    ❤️ 9
    e
    h
    j
    • 4
    • 14
  • d

    David Herman

    08/22/2025, 7:13 AM
    I've got an old project that I'm trying to migrate over to use the new experimental jvm binaries DSL, and although I'm essentially writing code identical to the example at https://kotl.in/jvm-binaries-dsl it doesn't seem to pick up the main class I'm setting.
    t
    m
    v
    • 4
    • 9
  • f

    florent

    08/22/2025, 7:55 PM
    Morning! How do you migrate to that https://kotlinlang.org/docs/gradle-compiler-options.html#migrate-from-kotlinoptions-to-compileroptions in a convention plugin?
    t
    • 2
    • 6
  • c

    CLOVIS

    08/23/2025, 1:09 PM
    Copy code
    kotlin {
        js {
            compilerOptions {
                target.set("es2015")
            }
        }
    }
    How can I get which target is set from within a Gradle plugin? The only thing I see is
    project.kotlinExtension.sourceSets
    but that doesn't seem to have that option.
    m
    h
    +2
    • 5
    • 31
  • y

    Yongjun Hong

    08/26/2025, 12:26 PM
    🚀 [GSoC / Maven Central Utility Plugins for Gradle] Version 0.1.7 Released! 🚀 Hello everyone! I’d like to introduce a Gradle plugin I developed during the GSoC project. This plugin helps you manage Maven POM metadata more easily and efficiently, making artifact signing, POM validation, and hierarchical POM configuration much simpler. Main features: • Define a POM in the root project and manage it hierarchically • Artifact signature verification • POM validation • Automated checks for required fields In this release (v0.1.7), we’ve: • Fixed issues related to the
    license
    field • Redefined required fields • Completed the documentation You can check the updates and download the latest plugin here: • https://plugins.gradle.org/plugin/io.github.yonggoose.maven.central.utility.plugin.check • https://plugins.gradle.org/plugin/io.github.yonggoose.maven.central.utility.plugin.project • https://plugins.gradle.org/plugin/io.github.yonggoose.maven.central.utility.plugin.setting • Release notes: https://github.com/YongGoose/Maven-Central-utility-plugins-for-Gradle/releases/tag/v0.1.7 For usage instructions, you can refer to the docs directory for a simple guide: https://github.com/YongGoose/Maven-Central-utility-plugins-for-Gradle/tree/main/docs I’d really appreciate it if you could try it out and share your feedback! Special thanks to my mentor @Oleg Nenashev for continuous guidance and support throughout the project 🙏
    🙌 1
  • j

    Justin Tullgren

    08/28/2025, 10:11 PM
    Hi, this is a very gradle question so if it can’t be answered no worries.. Does anyone know how to use gradle’s testkit
    withPluginClasspath
    method to include the gradle plugin under test while also having a test set up that uses a plugin in the gradle plugin portal? We have a set of gradle plugins that set conventions on other plugins, for example the kotlin jvm plugin. To test them we build up a test build.gradle.kts file with our plugin under test id AND a real kotlin plugin. However if we use
    withPluginClasspath
    then testkit can’t find the kotlin plugin.
    t
    m
    +3
    • 6
    • 18
  • e

    Emilio Colindres

    08/31/2025, 10:57 PM
    hi all. i've been stuck on this for 2 days now. when i try to build any kmp library it gets stuck on
    Downloading com.android.library.gradle.plugin-8.11.1.pom...
    and eventually fails with
    Copy code
    Plugin [id: 'com.android.library', version: '8.11.1'] was not found in any of the following sources:
    
    * Try:
    > Run with --info or --debug option to get more log output.
    > Run with --scan to get full insights.
    > Get more help at <https://help.gradle.org>.
    
    * Exception is:
    org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'com.android.library', version: '8.11.1'] was not found in any of the following sources:
    
    - Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
    - Included Builds (No included builds contain this plugin)
    - Plugin Repositories (could not resolve plugin artifact 'com.android.library:com.android.library.gradle.plugin:8.11.1')
      Searched in the following repositories:
        Google
        MavenRepo
        Gradle Central Plugin Repository
    	at org.gradle.plugin.use.resolve.internal.PluginResolutionResult.getFound(PluginResolutionResult.java:112)
    	at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.resolvePluginRequest(DefaultPluginRequestApplicator.java:197)
    	at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyPlugins(DefaultPluginRequestApplicator.java:101)
    	at org.gradle.kotlin.dsl.provider.PluginRequestsHandler.handle(PluginRequestsHandler.kt:45)
    	at org.gradle.kotlin.dsl.provider.StandardKotlinScriptEvaluator$InterpreterHost.applyPluginsTo(KotlinScriptEvaluator.kt:242)
    	at org.gradle.kotlin.dsl.execution.Interpreter$ProgramHost.applyPluginsTo(Interpreter.kt:387)
    	at Program.execute(Unknown Source)
    	at org.gradle.kotlin.dsl.execution.Interpreter$ProgramHost.eval(Interpreter.kt:516)
    I've tried clearing global and local gradle caches, intellij caches, reinstalling intellij, restarting mac, turning vpn on and off since it was on the first time it happened, and nothing works. I've even tried a completely fresh project from scratch and it still didn't work At this point i'm thinking google's maven repo might be down? because https://maven.google.com/web/index.html shows no libraries. but i've never visited the site before so idk if that's the case. Does any one have any ideas here?
    m
    j
    • 3
    • 10
  • l

    Lukáš Kúšik

    09/02/2025, 11:39 AM
    Hey everyone, I have a KMP Gradle project that is taking a long time (1m 30s) to even configure. I'm trying to find out what is causing this. I have run a build using Gradle Scan, which says that it is the
    com.android.internal.application
    plugin causing this, in an afterEvaluate task.. But the clue ends there, could anyone point me on how to go further and how to investigate which afterEvaluate it is? Thanks!
  • e

    Edoardo Luppi

    09/10/2025, 5:28 PM
    I had this piece of build configuration:
    Copy code
    targets {
      configureEach {
        tasks.named(targetName + "SourcesJar").configure {
          dependsOn(generateCharsets)
        }
      }
    }
    With 2.2.20, I was getting a deprecation message that says: > [DEPRECATION] 'targets(TargetsFromPresetExtension.() -> Unit): Unit' is deprecated. Usages of this DSL are deprecated, please migrate to top-level 'kotlin {}' extension. After a bit of searching on my own I figured out that I just had to use:
    Copy code
    targets.configureEach {
      tasks.named(targetName + "SourcesJar").configure {
        dependsOn(generateCharsets)
      }
    }
    The deprecation definitely did not help. It seems too generic to be honest.
    v
    o
    +2
    • 5
    • 66
  • e

    Eugen Martynov

    09/12/2025, 2:45 PM
    How to apply kotlin compiler plugin in convention plugin? Documentation for gradle files:
    Copy code
    plugins {
        kotlin("plugin.power-assert") version "2.0.0"
    }
    So it is probably something to do with kotlin compile task in the convention plugin
    ✅ 1
    j
    v
    • 3
    • 7
  • l

    Leon Linhart

    09/15/2025, 9:22 AM
    I've made an interesting observation while working on a Gradle task: For a task hierarchy
    DefaultTask > MyAbstractBaseTask > MyTask > MyTask_Decorated (generated by Gradle)
    , inside
    MyAbstractBaseTask
    I've observed:
    Copy code
    println(this@MyAbstractBaseTask::class.supertypes)        // [MyAbstractBaseTask]
    println(this@MyAbstractBaseTask.javaClass.superclass)     // MyTask
    Is this expected?
    v
    • 2
    • 1
  • m

    Meet

    09/17/2025, 9:37 AM
    How to parse
    .gradle
    and
    .gradle.kts
    files into Kotlin data classes?
    v
    e
    p
    • 4
    • 10
  • p

    Piotr Krzemiński

    09/18/2025, 7:16 AM
    I'm trying to update to Kotlin 2.2.20, but I'm getting a problem during the configuration phase:
    Copy code
    An exception occurred applying plugin request [id: 'buildsrc.conventions.lang.kotlin-multiplatform']
    > Failed to apply plugin 'buildsrc.conventions.lang.kotlin-multiplatform'.
       > Future was not completed yet 'Kotlin Plugin Lifecycle: (root project 'snakeyaml-engine-kmp') stage 'EvaluateBuildscript''
    Full logs here. I cannot reproduce locally, although admittedly I have a Mac, and the build works fine on a MacOS worker. Is anyone else seeing this as well? Or having a Linux/Windows machine where it reproduces?
    t
    e
    +2
    • 5
    • 14
  • u

    ursus

    09/19/2025, 8:32 PM
    Does gradle build cache work with kmp to cache the xcframework stuff from ios build? If so, how does it play with
    umbrella
    modules? Say umbrella consists of 10 modules and that is cached. If one module changes, would I still get a cache hit on the 9, even if its exposed to ios via the umbrella?
    t
    • 2
    • 5
  • p

    Piotr Krzemiński

    09/21/2025, 3:37 PM
    this may as well be a Gradle problem, so let me cross-post it here: https://kotlinlang.slack.com/archives/C0B8H786P/p1758465878216939
    ✅ 1
  • e

    eygraber

    09/21/2025, 4:32 PM
    I just realized that many of my projects have the following in the
    GRADLE_OPTS
    env var:
    Copy code
    -Dkotlin.incremental=false
    I'm guessing that's not actually doing anything because
    -D
    is a meant for JVM properties, but is there any chance that's getting forwarded to KGP?
    t
    • 2
    • 1
  • m

    mbonnin

    09/22/2025, 9:47 AM
    Is there a way to a create Kotlin compilation (
    agp-9
    ) that contributes the main jar but does not leak its
    compileOnly
    dependencies to the main compilation? • If I use
    main.associateWith(agp-9)
    , the dependencies are automatically added • I can configure the dependencies manually but then
    internal
    declarations are not seen from
    main
    , I'm guessing because of
    friendSourceSets
    Is there a way?
    t
    • 2
    • 3
  • o

    Oliver.O

    09/24/2025, 9:54 AM
    In a KMP+Android project, an
    androidUnitTest
    dependency's symbols are not found during
    clean testReleaseUnitTest
    , unless the dependency is removed,
    testReleaseUnitTest
    is executed again, the dependency is re-added, after which
    testReleaseUnitTest
    succeeds. Does this ring a bell to anyone? Details in 🧵.
    m
    • 2
    • 4
  • s

    Said Shatila

    09/26/2025, 3:30 PM
    Hey everybody, I am building currently my first gradle plugins and I am running into some issues because it's currently an old project so I am migrating stuff, and it's kinda messy a little bit, but I will be sharing some of my code snippets over here so if someone has a better understanding would explain to me why this is happening. This is my plugin
    Copy code
    /**
     * Minimal Hilt convention:
     * - Applies Hilt Gradle plugin and KSP
     * - Wires hilt-android + hilt-compiler (KSP)
     * Assumes the module already applies com.android.* and kotlin-android outside.
     */
    class AndroidHiltConventionPlugin : Plugin<Project> {
        override fun apply(target: Project) = with(target) {
            // Apply external plugins to the target project
            pluginManager.apply("com.google.dagger.hilt.android")
            pluginManager.apply("com.google.devtools.ksp")
    
            // Access the root version catalog named "libs"
            val libs = extensions.getByType<VersionCatalogsExtension>().named("libs")
    
            dependencies {
                add("implementation", libs.findLibrary("hilt-android").get())
                add("ksp", libs.findLibrary("hilt-android-compiler").get())
            }
        }
    }
    My register in build.gradle for build logic.
    Copy code
    register("androidHilt") {
                id = "com.yinzcam.android.hilt"
                implementationClass = "yinz.cam.build_logic.conventions.AndroidHiltConventionPlugin"
            }
    Copy code
    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    buildscript {
        ext.kotlinVersion = "2.1.0"
        ext.kotlinCoroutinesVersion = '1.6.4'
        ext.kotlinSerializationVersion = '1.0.1'
        ext.dokkaVersion = "0.10.1"
        def gradlePluginVersion = "8.9.1"
    
        def hiltVersion = '2.57'
        def kspVersion = '2.1.0-1.0.29'
    
        repositories {
            google()
            mavenCentral()
            mavenLocal()
            jcenter()
        }
        dependencies {
            classpath "com.android.tools.build:gradle:$gradlePluginVersion"
            classpath 'com.google.gms:google-services:4.3.14'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$project.ext.kotlinVersion"
            classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion"
            classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.5'
            classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokkaVersion"
            classpath "org.jfrog.buildinfo:build-info-extractor-gradle:5.2.5"
            classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.5.3"
            classpath "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin:2.0.1"
            classpath "org.jetbrains.kotlin:compose-compiler-gradle-plugin:$project.ext.kotlinVersion"
            classpath "com.google.dagger:hilt-android-gradle-plugin:$hiltVersion"
            classpath "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:$kspVersion"
        }
    }
    
    plugins {
        alias(libs.plugins.hilt) apply false
    }
    This build.gradle is the one that is outside for all of the project and the main module app since the app isn't modularized still and this is the one responsible for dependencies and inner plugins
    Copy code
    buildscript {
        repositories {
            google()
            mavenCentral()
            mavenLocal()
            jcenter()
            flatDir {
                dirs 'libs'
            }
        }
        dependencies {
            classpath "com.android.tools.build:gradle:$project.ext.gradlePluginVersion"
            classpath "com.google.firebase:firebase-appdistribution-gradle:$project.ext.firebaseGradlePlugin"
        }
    }
    
    apply plugin: 'com.android.application'
    apply plugin: 'project-report'
    apply plugin: 'kotlin-android'
    apply plugin: 'kotlin-kapt'
    apply plugin: 'kotlin-parcelize'
    apply plugin: 'kotlinx-serialization'
    apply plugin: 'com.google.firebase.appdistribution'
    apply plugin: "com.google.android.libraries.mapsplatform.secrets-gradle-plugin"
    apply plugin: 'org.jetbrains.kotlin.android'
    apply plugin: 'org.jetbrains.kotlin.plugin.compose'
    apply plugin: 'org.jetbrains.kotlin.plugin.serialization'
    //apply plugin: 'com.google.devtools.ksp'
    //apply plugin: 'com.google.dagger.hilt.android'
    here where I commented apply plugin --> Up. I was trying to add my hilt plugin -->
    Copy code
    plugin {
    id ("com.yinzcam.android.hilt")
    }
    but it's not detecting it any idea about it
    Copy code
    line: 17
    
    An exception occurred applying plugin request [id: 'com.yinzcam.android.hilt']
    > Failed to apply plugin 'com.yinzcam.android.hilt'.
       > Configuration with name 'implementation' not found.
    c
    t
    v
    • 4
    • 14
  • l

    loke

    09/28/2025, 2:22 PM
    I have a Kotlin multiplatform gradle project, and I would like the generated code to contain the git change id and build date. Is there a way to pass that to the compiler so I can display it in the welcome screen?
    m
    a
    v
    • 4
    • 10
  • m

    mohamed rejeb

    09/29/2025, 10:15 AM
    Recently I start having this issue a lot If I have for example a custom group "nonWeb" and I add an expect in that "nonWeb" group I can create actual in android and desktop without issues, but it's not recognized by "ios", It's only recognized by "iosArm64", "iosX64" and "iosSimulatorArm64" Same for dependencies, if I add a dependency to nonWeb it's not added to ios
    t
    • 2
    • 4
  • m

    mbonnin

    09/30/2025, 8:52 AM
    Can I disable some K/N tests (and their matching compile and link tasks) from the KGP API without having to rely on task names?
    o
    • 2
    • 2
  • p

    PHondogo

    10/01/2025, 8:54 AM
    Is it possible to configure kotlinUpgradePackageLock task to execute automatically when needed? Now build sometime failing with message that kotlinUpgradePackageLock should be executed. I need in such cases silently execute kotlinUpgradePackageLock without breaking the build process.
    m
    • 2
    • 1
  • m

    mbonnin

    10/01/2025, 12:16 PM
    What's everyone thoughts on making overloads for Kotlin consumers in Gradle code:
    Copy code
    fun foo(action: Action<Bar>) {
            TODO()
        }
    
        /**
         * Overload for Kotlin callers
         */
        fun foo(action: Bar.() -> Unit) {
            TODO()
        }
    Is it really that important to transform the lambda parameter in a receiver? If I really want to, isn't it the whole point of the sam-with-receiver plugin? Are there any upsides to do this?
    h
    v
    • 3
    • 2
  • s

    Slackbot

    10/01/2025, 5:02 PM
    This message was deleted.
    s
    • 2
    • 4
  • g

    Guilherme Delgado

    10/13/2025, 9:59 AM
    How can I properly configure KMP modules to work with Android flavors so that dependencies between shared KMP modules resolve correctly? 🧵
    m
    • 2
    • 11
  • m

    Maksym M.

    10/16/2025, 2:33 PM
    Might be a weird question, can someone tell me where I can find plugin class for
    org.jetbrains.kotlin.plugin.parcelize
    ? Specifically the class that is being called via apply when we put this dependency in
    plugins { }
    block of a build file
    t
    • 2
    • 2
  • r

    Ricardo C.

    10/22/2025, 2:16 PM
    I’m seeing compile tasks for dependencies added for a KMP module being called during Gradle sync.
    Copy code
    kotlin {
        sourceSets {
            androidMain {
                dependencies {
                    api(projects.core.initializers.api)
                }
            }
        }
    }
    Copy code
    > Task :core:initializers:api:checkKotlinGradlePluginConfigurationErrors SKIPPED
    > Task :core:initializers:api:processResources UP-TO-DATE
    > Task :core:initializers:api:compileKotlin
    > Task :core:initializers:api:compileJava NO-SOURCE
    > Task :core:initializers:api:classes UP-TO-DATE
    > Task :core:initializers:api:jar UP-TO-DATE
    I could not find anything about it, but it does not seem normal to run them before task execution phase. Any idea what could it be?
    v
    t
    • 3
    • 4