https://kotlinlang.org logo
Join Slack
Powered by
# gradle
  • 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
    • 12
  • 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
  • t

    tapchicoma

    11/05/2025, 2:41 PM
    We've missed adding it into initial Kotlin 2.2.20 what's new, but added now - in this release we've added a bunch of helpers for library publication to Maven Central: https://kotlinlang.org/docs/whatsnew2220.html#improvements-for-library-publication
    🏆 7
    m
    • 2
    • 1
  • l

    loke

    11/06/2025, 1:54 PM
    I wanted to move to JDK 25 for Kotlin. That meant I also had to move to Gradle 9.20. Is it just me, or is JDK 25 with Gradle 9 much, much slower than JDK 21 with Gradle 8?
    v
    • 2
    • 1
  • l

    loke

    11/06/2025, 1:55 PM
    Instead of building and running my program in about 10 seconds, just rerunning the code (without a full rebuild, just a few files changed) takes over a minute now.
    🧵 2
    m
    • 2
    • 25
  • a

    Ayfri

    11/07/2025, 11:23 AM
    Often when running my tasks in a medium-size projects (7-8 modules), I get like 10 to 30s of just
    > IDLE
    and Gradle staying at 0%, I have this parameters in my
    gradle.properties
    Copy code
    # Gradle optimization flags
    org.gradle.caching=true
    org.gradle.configuration-cache=true
    org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
    org.gradle.parallel=true
    And I don't understand why it's so slow to start tasks, even just a small run task for tests where I just changed 1 file it can take like 20s of Idling
    m
    a
    • 3
    • 3
  • d

    dany giguere

    11/09/2025, 1:42 AM
    Hello everyone. I've created a Kotlin coroutines validation package for spring. It's in Beta. It's my first package and I didn't want to publish it to maven until it's ready. Did I do the right thing to publish it on jitpack ? Any recommendation ? Here's the package: https://github.com/danygiguere/spring-validation-dsl
    h
    a
    v
    • 4
    • 12
  • c

    Cherrio LLC

    11/12/2025, 5:57 PM
    Hello guys, for some weird reason I need to download a project's dependencies, zip the cache and use it to build the project in a different environment, no downloading. Is this possible? If so, how?
    v
    a
    • 3
    • 9
  • a

    Ayfri

    11/14/2025, 5:51 PM
    Hello, after upgrading to Gradle 9.2.0 and JReleaser 1.20.0, I'm not able to publish anymore on Maven Central, it just refuses my GPG keys and I've tried for 8 hours to publish a new update of my library I have a GitHub Action for publishing, and on the 30 attempts for today, it always failed with
    Copy code
    > Task :kore:jreleaserDeploy
    ...
    [ERROR] JReleaser failed after 3.042 s
    ...
    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':kore:jreleaserDeploy'.
    ...
    Caused by: org.jreleaser.model.JReleaserException: Did not find public key for signing. Ensure a value has been configured and properly formatted without indentation
    (all ... are skipped lines of logs) I've created a new gpg key, uploaded it to many servers, validated it locally many times, tried 25 times to upload it on GitHub, verified that it's LF, on the last attempt I even tried to encode it into base64 but still can't manage to publish my library I'm just very exhausted and feel like my day was a waste a time (only coded for like 10 minutes to fix a bug), what am I missing ? Why is it so hard ?
    v
    • 2
    • 4
  • h

    hfhbd

    11/18/2025, 11:27 AM
    How can I create an integration test task using multiplatform plugin without executing it by default when running check? jvm { val jvmTest = compilations.getByName("test") val integrationTest = compilations.create("integrationTest") { associateWith(jvmTest) } testRuns.create("integrationTest") { setExecutionSourceFrom(integrationTest) } } }
    • 1
    • 1
  • r

    Robby

    11/18/2025, 2:27 PM
    Hello Good Evening every one. While a run the app not facing any error. But while i Generate Bundle then i getting the issue. Unable to find method ''com.android.tools.r8.D8Command$Builder com.android.tools.r8.D8Command$Builder.setBuildMetadataConsumer(java.util.function.Consumer)'' 'com.android.tools.r8.D8Command$Builder com.android.tools.r8.D8Command$Builder.setBuildMetadataConsumer(java.util.function.Consumer)' Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Any one have idea about this.
    t
    • 2
    • 2