kotlin-dsl
  • jonathan gafner

    jonathan gafner

    02/14/2022, 12:43 PM
    Hi I saw that it is possible to do something like this:
    val taskName by creating...
    Since it is a multi project repo I would like to make the taskName be depended on the project name :
    val task+$projectName by creating
    is there a way to configure the task name like this somehow ? Thanks
  • e

    Eli Graber

    03/01/2022, 10:06 PM
    I understand the frustration behind closing https://github.com/gradle/gradle/issues/16779 but can someone from Gradle actually comment on it? This would be a super helpful solution to a super annoying problem (https://github.com/gradle/gradle/issues/16345)
  • Julio Cesar Bueno Cotta

    Julio Cesar Bueno Cotta

    03/25/2022, 10:00 AM
    Hello there, sorry if this is not the right place, but some help would be very appreciated. I am facing a bug in R8 and Keeper and it seems the workaround was provided in kotlin dsl... and I have no idea how to convert that snippet back to gradle... which is what I am using in the whole project... Would someone be able to help with that?
    tasks.withType<L8DexDesugarLibTask> {
      if (name.endsWith("AndroidTest")) {
        // To avoid collisions with obfuscated names
        keepRulesConfigurations.set(listOf("-dontobfuscate"))
        // To just keep everything in your test app that might be used by the tested app
        keepRulesConfigurations.set(listOf("-keep class j$.** { *; }"))
      }
    }
    from: https://issuetracker.google.com/issues/158018485
  • Sam Edwards

    Sam Edwards

    04/14/2022, 12:50 PM
    I wrote an article about how
    kotlin-dsl
    forces you to use Kotlin 1.4 syntax, even though newer versions of Gradle like 7.4, have Kotlin 1.5 bundled in it. In the article I go into why that's the case and how you can override that and use Kotlin 1.5 syntax if you choose. Just note, if you do this you could limit yourself to newer versions of Gradle. Any feedback or suggestions is appreciated! Thanks @Martin and @tony for already reviewing! https://handstandsam.com/2022/04/13/using-the-kotlin-dsl-gradle-plugin-forces-kotlin-1-4-compatibility/
  • Martin

    Martin

    04/27/2022, 5:12 PM
    Can I add
    implementation(gradleKotlinDsl())
    from a
    build.gradle
    file (not build.gradle.kts)?
  • ephemient

    ephemient

    05/22/2022, 1:13 PM
  • Martin

    Martin

    06/23/2022, 9:36 AM
    What's the plan for embedded Kotlin 1.7? 7.5 is around the corner but only upgrades to 1.6. And dependencies such as KotlinPoet started targetting 1.7.
  • m

    Mark

    08/13/2022, 8:02 PM
    Hello! Is it possible to use the versions catalog inside of convention plugins? I have them in the
    build-logic
    , in the build logic's gradle.settings.kts I have:
    versionCatalogs {
        register("libs") {
            from(files("../gradle/libs.versions.toml")) // include from parent project
        }
    }
    Which allows me to use the versions in the build.gradle.kts, but they aren't available inside the
    src/main/kotlin/
    , for example I can't access it on my
    src/main/kotlin/project.base-conventions.kts
  • s

    Suresh

    08/20/2022, 1:22 AM
    Hello, what’s the best way to access the version catalog info ( like
    versionAliases
    ) from main source so that i can display the dependency versions in my application management UI ? Right now i am generating source using groovy string templates by expanding the properties. Is there any other mechanism for accessing this info in a type safe way (like
    VersionCatalogsExtension
    ) ?
  • Tapchicoma

    Tapchicoma

    08/22/2022, 10:45 AM
    Will it make sense (or are there plans) to further improve generated Kotlin DSL helpers? For example provide
    TaskContainer.configureEachWithType<T : Task>(action: Action<T>)
    ? 🤔
  • a

    Andrey Mishchenko

    08/26/2022, 5:54 AM
    I found really unfortunate case with type-safe accessors generation. I have 2 different precompiled script plugins, One has Android Library gradle plugin, another Android Application gradle plugin, both have extension with name
    android
    but different type and apparently only 1 extension is generated and it’s one with Library, so I cannot use type safe accessors from plugin which configures application It looks as pretty common case, is there any issue about this, I mean handling of different extensions with the same name, at least would like to understand that it’s a known behaviour/limitation/bug I probably can just create a separate included build for plugin, but I would say that it’s not very convenient (I have to configure plugins project exactly the same way with all the same dependencies)
  • Javi

    Javi

    09/11/2022, 11:33 AM
    Try changing the IntelliJ JDK
  • i

    Igor Wojda

    09/20/2022, 3:36 PM
    Hey I am trying to bring my open-source Android project up to date by adding TOML dependency files, but I am getting bunch of
    must be locked before it can be used to compute a classpath
    errors 😞 . I was playing with build scripts, but I don't understand why this is happening, so I don't know how to fix it. I need a bit of help with fixing these errors. Can someone take a quick look at this branch?https://github.com/igorwojda/android-showcase/tree/update-versioncatalog-error
  • b

    Ben Madore

    10/05/2022, 8:36 PM
    does anyone know of a kts linting type tool that can be configured to fail on disallowed idioms in *.kts files. For instance, say, if i wanted to force developers to only use dependencies from a catalog and not in-line them e.g. allow:
    implementations(libs.mylibrary.foo)
    disallow:
    implementation("com.myorg.mylibrary:foo:1.2.3")
  • t

    Tevin Jeffrey

    10/10/2022, 11:03 PM
    I see Gradle launches a Kotlin daemon for compiling build scripts using a version of Kotlin that was shipped with Gradle. In my case Gradle 7.5.1 is bundled with Kotlin 1.6.21. The problem is that if my project uses a different version of Kotlin, 1.7.10, incompatible with the one shipped with Gradle. During a build, there will be 2 daemon processes, one (1.7.10) actively compiling code during the execution phase and another (1.6.21) sitting around long after the configuration phase. Given my memory constraints I have a few questions: • Is there a way to configure the jvm arguments of the Gradle bundled Kotlin daemon separately from the daemon started by the Kotlin plugin? • Is there a way to configure the version of the Kotlin used to compile build scripts. • Can the build script daemon be stopped once the configuration phase is over?
  • e

    efemoney

    10/13/2022, 2:15 AM
    Bringing up the topic of settings script accessors (for kotlin DSL) 😞. Is there any tracking issue or plans around this? With 7.6 and the new toolchainManagement APIs I see Gradle added the “fake”
    toolchainManagement.jvm
    extension function and imo its kinda weird to have an API that is available but fails the build by default. More and more plugin authors are encouraged to write and publish settings plugins but the experience of using these with the kotlin DSL is quite bad.
  • Javi

    Javi

    10/14/2022, 10:43 PM
    Based on this https://github.com/Kotlin/KEEP/issues/309#issuecomment-1277778011 which implies creating a compiler plugin, is it possible in the future to use FIR in that plugin in order to generate the accessors for the applied plugins too?
  • v

    Vladimir Sitnikov

    10/19/2022, 12:05 PM
    There’s an interesting update regarding Kotlin lambdas: https://youtrack.jetbrains.com/issue/KT-15514/Annotate-blocks-that-are-being-executed-ou[…]he-current-call-frame-and-warn-on-captured-vars-into-them They consider adding the notion of “non-local lambdas”. I am not sure it helps Gradle directly, however, it might be it would prevent cases like “forgotten
    doLast
  • Martin

    Martin

    11/04/2022, 11:36 AM
    When using Kotlin build script, very often (if not always?) the auto-import uses inline imports, (i.e. adds
    com.example.FooExtension
    ) instead of importing it at the top of the file (
    import com.example.FooExtension
    ). Is it possible to tweak this?
  • t

    Taylor Smith

    11/04/2022, 5:24 PM
    Hey everyone! I've run into somewhat of a dead end. I'm trying to publish a conventions plugin for boilerplate in our multi-module projects. The plugin works, but
    project.findProperty()
    does not work in the
    subproject
    scope. Same code works fine when applied directly to the subprojects, but not when using the
    subprojects
    block and applying it to the
    rootProject
    subprojects {
        apply(plugin="com.google.cloud.tools.jib")
        apply(plugin="maven-publish")
        apply(plugin="com.jfrog.artifactory")
    
        artifactory {
            setContextUrl("<https://my.jfrog.io/company/>")
    
            publish {
                repository {
                    setProperty("repoKey", "mvn-local")
                    setProperty("maven", true)
                    // Set these in your $HOME/.gradle/gradle.properties:
                    setProperty("username", project.findProperty("ARTIFACTORY_USER"))
                    setProperty("password", project.findProperty("ARTIFACTORY_PASSWORD"))
                    defaults(delegateClosureOf<groovy.lang.GroovyObject> {
                        invokeMethod("publications", "mavenJava")
                        setProperty("publishPom", true)
                        setProperty("publishArtifacts", true)
                    })
                }
            }
    
            resolve {
                setProperty("repoKey", "mvn-local")
            }
        }
  • CristianGM

    CristianGM

    11/10/2022, 5:00 PM
    Which folder or folders should I copy if I want to reuse compiled scripts? (so I can reduce
    Script compilation
    time)
  • r

    Rooz

    11/10/2022, 10:06 PM
    New Kotlin DSL training class offered by the Gradle team. Its free. please sign up and give us your feedback https://gradle.com/training/configuring-gradle-build-tool-with-kotlin/?time=1670371200
  • p

    Paul Merlin

    11/17/2022, 3:49 PM
    FYI IntelliJ 2022.3 actually in beta, comes with drastic performance improvement for IDE assistance in the
    .gradle.kts
    editor. Code completion is fast! 🚀 This work by the Kotlin Team changes the UX so much ❤️ https://blog.jetbrains.com/idea/2022/11/intellij-idea-2022-3-beta-2/#Improved_IDE_performance_for_Kotlin
  • c

    Claude Brisson

    11/18/2022, 2:31 PM
    Hi, community. I have a multimodule project [here](https://gitlab.republicate.com/claude/skorm), most submodules are kotlin libraries except a java library submodule, and the problem I encounter is that [this submodule](https://gitlab.republicate.com/claude/skorm/-/blob/main/skorm-jdbc/build.gradle.kts) publish plugin doesn't find anything to publish:
    ./gradlew -i :skorm-jdbc:publishToMavenLocal
    [...]
    > Task :skorm-jdbc:publishToMavenLocal
    Skipping task ':skorm-jdbc:publishToMavenLocal' as it has no actions.
    I'm using 7.5.1.
  • s

    Slackbot

    11/18/2022, 2:34 PM
    This message was deleted.
  • Amanda

    Amanda

    11/29/2022, 10:26 PM
    We have a 90 min Configuring Gradle Build Tool with Kotlin Course scheduled for Dec 7th. It is geared towards people new to Gradle and want to start with the Kotlin DSL. This is the first run of the course, more to come later in different time zones. Feel free to share with people you think might need it!