https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
gradle
  • p

    PHondogo

    08/15/2022, 10:02 PM
    Hello! How can I specify different res folder for Android target in MPP project? There is only resources property. In sourceSet.
    b
    • 2
    • 3
  • v

    Vampire

    08/19/2022, 9:37 AM
    Why does it say it is red? Maybe try to refresh or reimport the Gradle project
    a
    e
    • 3
    • 3
  • a

    Akram Bensalem

    08/19/2022, 9:45 AM
    I created a new Project without using Version Catalog and it turns to be Red also after convert build.gradle to build.gradle.kts !!! I think the problem is with the IDE something went wrong !!! I use "Android Studio Electric Eel | 2022.1.1 Canary 9"
    v
    • 2
    • 1
  • j

    Ji Sungbin

    08/19/2022, 1:41 PM
    Hi, How do I get arguments in TaskProvider#configure lambda? If you look at Google’s code, it is receiving arguments from configure, but when I actually try it, an error appears. Also, I checked if Google has overridden the TaskProvider#configure function, but I couldn’t find it.
    g
    m
    v
    • 4
    • 8
  • a

    andylamax

    08/21/2022, 6:01 AM
    x-posting here coz I think it may be more gradle related than compose https://kotlinlang.slack.com/archives/C01D6HTPATV/p1661061555103729
  • m

    moltendorf

    08/21/2022, 3:18 PM
    Hi there, I've been working on building libraries and getting to providing/using them via implementation() calls; however in this final case the "dependency" is a Kotlin/JS project and I want to serve it using Ktor (Kotlin/Jvm; i.e. this dependency belongs in resources kinda?) Not sure how to use it as that instead of "code" (the library doesn't even show up in the build/ directory so I can't manually copy it even?)
    b
    • 2
    • 68
  • r

    Rob Elliot

    08/22/2022, 1:47 PM
    I'm looking into migrating a Groovy codebase to Kotlin. I was doing OK with having the Kotlin code depend on the Groovy code, but after some thought I think the migration will be easier if the Groovy code depends on the Kotlin code. I'm struggling to get
    compileGroovy
    to see the Kotlin classes though. Could anyone give me some pointers?
    a
    v
    • 3
    • 16
  • t

    Tom Yuval

    08/22/2022, 2:04 PM
    Sorry if this was asked before, but searching didn’t yield anything meaningful: When some of my tests fail and I try to detect that using Gradle (e.g.
    ./gradlew allTests
    or
    ./gradlew check
    ), this doesn’t work when I’ve already run the tests before. What happens is that the first time I run
    gradlew
    it indeed fails because of the failing tests, but then if I run it a second time it doesn’t run the tests again as the tasks are already “up-to-date” – but it also doesn’t fail (as if the tasks being up-to-date is a good enough reason to pass, even though the tasks’ up-to-date state is that they’re failing). Is there some way to tell Gradle to fail when the “up-to-date” tasks it doesn’t want to run again failed the last time? Clarification: I’m not asking how to make Gradle rerun the tests – if nothing’s changed since the last run then I’m happy with Gradle considering everything up-to-date and not wasting time re-executing tasks. I just want it to fail (= return with a non-zero exit code) in that state, like it did upon the first run of the failing tests, and not “pretend” that everything’s OK.
    s
    v
    • 3
    • 28
  • a

    Ayfri

    08/23/2022, 9:56 PM
    Hi, what is the kotlin equivalent of
    dependencies {
       runtimeClasspath files ("../core/build/classes/kotlin/main")
       runtimeClasspath files ("build/classes/kotlin/main")   
    }
    ?
    v
    • 2
    • 6
  • j

    João Gabriel Zó

    08/25/2022, 1:32 PM
    How can I use graalvm in a project with multiple subprojects? I’ve added the plugin to my
    settings.gradle
    but I’m still receiving
    Plugin with id 'org.graalvm.buildtools.native' not found.
    s
    • 2
    • 3
  • i

    isto

    08/26/2022, 5:56 AM
    how to convert
    task buildZip(type: Zip) {
        from compileJava
        from processResources              
        into('lib') {
            from configurations.runtime
        }
    }
    into kotlin? There are many examples related to file copying but I have trouble finding info on how to refer to
    compileJava
    and
    processResources
    in kts
    j
    • 2
    • 4
  • h

    hfhbd

    08/30/2022, 12:07 PM
    How do you update the kotlin srcDir with a property? I want to allow the user of this task to update outputFolder, which should update kotlin.srcDir too. IntelliJ marks the initial folder as source folder, but the folder isn't added to the compiler as input.
    @get:OutputDirectory
    abstract val outputFolder: DirectoryProperty
    
    init {
      outputFolder.convention(project.layout.buildDirectory.dir("generated/foo"))
      
      project.plugins.withId("org.jetbrains.kotlin.jvm") {
        val srcSet = project.extensions.findByType(SourceSetContainer::class.java)!!.getByName("main")
         val kotlin = srcSet.extensions.getByName("kotlin") as SourceDirectorySet
         kotlin.srcDir(outputFolder.dir("kotlin"))
      }
    }
    t
    • 2
    • 6
  • s

    Stylianos Gakis

    08/31/2022, 8:18 AM
    I know that there’s a possibility to name your directory as
    src/**/java
    or
    src/**/kotlin
    and then gradle recognizes those two as separate source sets. For example there’s a bug in
    ktlint-gradle
    since it doesn’t handle that case. We’ve now migrated from that plugin and can use the
    kotlin
    name, but question is, should we? Is there any build speed or anything really that would improve by doing such a move? Our project is 100% Kotlin already and will stay so too.
    t
    v
    • 3
    • 7
  • g

    Gleb Minaev

    09/03/2022, 5:04 PM
    Hi! I have a multimodule multiplatform Gradle project. All submodules are configured in the same way. Also some of them depend on other ones. I want to add examples to each module, so decided to add another JVM target (they allready have one) with name
    example
    . But when I just add the new target Gradle sync fails saying that each of
    jvmMain
    ,
    exampleMain
    ,
    jvmTest
    and
    exampleTest
    source sets can not determine which artifacts of dependency projects to use,
    jvm
    or
    example
    ones. How can I specify which target to depend on? Or how to "hide" some targets from depending on (and publishing)?
    t
    a
    • 3
    • 4
  • e

    Ellen Spertus

    09/03/2022, 7:02 PM
    [Cross-posed from #Dokka]: I'm working on creating a template project that uses Gradle to run Dokka but can't figure out how to include all
    package.md
    files, regardless of what directories they appear in (the way all source code is included, regardless of directory). I tried:
    tasks.withType<org.jetbrains.dokka.gradle.DokkaTask>().configureEach {
        dokkaSourceSets {
            named("main") {
                includes.from("package.md")
            }
        }
    }
    but this only looks for
    package.md
    in the root directory:
    C:\Users\ellen\IdeaProjects\gradle-test\package.md (The system cannot find the file specified)
    How would I make it look for files named
    package.md
    in any
    src
    directory?
    t
    i
    • 3
    • 3
  • p

    PHondogo

    09/09/2022, 6:35 AM
    Hello! Is it possible to specify "Hard wrap at" in gradle.properties so that Intellij Idea can take it and apply?
    e
    v
    • 3
    • 4
  • g

    Guilherme Delgado

    09/09/2022, 3:43 PM
    Does anyone can make https://github.com/jmfayard/refreshVersions/ work with Versions Catalog? Following this steps. Every-time I run
    refreshVersions
    or
    refreshVersionsMigrate
    (with --debug flag) commands, it throws saying:
    Invocation of ‘Task.project’ by task ‘:<command>’ at execution time is unsupported.
    Also, if I try to run with
    --mode
    flag it says
    > Unknown command-line option ‘--mode’.
    I’m stuck here. The project was created from 0 with Versions Catalog (no versions.properties) and I’m using gradle 7.5.1
    v
    • 2
    • 5
  • m

    Matthew Murray

    09/09/2022, 11:29 PM
    My library’s build.gradle.kts isn’t able to resolve
    String.lowercase()
    for some reason, and
    String.toLowerCase()
    seems to be deprecated and doesn’t work. Anyone have any ideas on why my build.gradle.kts can’t access this method?
    v
    • 2
    • 2
  • m

    Marco Pierucci

    09/09/2022, 11:49 PM
    Hello! Am trying to create a super simple cusotm plugin in a included build to encapsulate common android setup. But the moment I apply the plugin I got
    Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find com.android.tools.build:gradle:7.2.2.?
    v
    • 2
    • 15
  • v

    Venkataramanan Parameswaran

    09/12/2022, 12:57 PM
    Hi! I have an app that uses 'library 1' and 'library 2' . Let's say library1 uses coil version-1(an image library for example) and library2 uses coil version 2... when implementing both library 1 and library 2 in my app... only the latest version of coil i.e., coil version 2 is downloaded... is there any way to mitigate this issue?
    v
    • 2
    • 1
  • b

    Bhargav

    09/14/2022, 12:14 PM
    Hey everyone, I am trying to create multiple namespaces and applicationId base on different flavour dimensions where I do have /src for all different flavor Dimensions I am able to generate different namespaces and applicationId but facing issue like, whichever the last flavour is execute/build, it allowing only that name spaces (package name) instead of active build variant which I have selected. where I have common layout in main directory which is common for all flavour. Does any one had face similar problem/issue or implemented ?
  • g

    Guilherme Delgado

    09/14/2022, 3:17 PM
    I’m trying to migrate a configuration like:
    plugins {
        kotlin("multiplatform")
        id("org.jetbrains.compose") version Versions.JetBrains.Compose.desktop
    }
    to a convention plugin where:
    with(pluginManager) {
      apply("org.jetbrains.kotlin.multiplatform:${catalog.findVersion("kotlin").get()}")
      apply("org.jetbrains.compose:${catalog.findVersion("desktopCompose").get()}")
    }
    but when I run it throws saying (same for the second line if I comment the first):
    Caused by: org.gradle.api.plugins.UnknownPluginException: Plugin with id 'org.jetbrains.kotlin.multiplatform:1.7.10' not found.
    	at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:144)
    I’ve checked here and the syntax of the plugin is correct. What am I missing here? 🤔 Thanks!
    s
    e
    i
    • 4
    • 26
  • j

    jmfayard

    09/15/2022, 4:09 PM
    Bonjour, any Kotliner interested by either • migrating to Gradle Versions Catalog the easy way • having available dependencies updates automatically show up in
    gradle/libs.versions.gradle
    ? refreshVersions just added support for Gradle Versions Catalog It's a huge feature though, so we would love for gentle early adatopers to give it a try https://github.com/jmfayard/refreshVersions/wiki/RefreshVersions-%E2%99%A5%EF%B8%8F-Gradle-Version-Catalog
    g
    • 2
    • 4
  • m

    mkrussel

    09/15/2022, 7:32 PM
    I’ve got a couple of precompiled
    .aar
    files that I’m trying to include as a dependency in my library. These libraries are intended to be part of my library group, but they are slow to build and don’t change often (and maintained by a different team). To use them I created some gradle projects declaring them as an artifact and then made other library depend on them using
    implementation(project(":project"))
    . I also added plugins and configuration to publish the artifacts.
    val artifact = file("$name.aar")
    configurations.maybeCreate("default")
    artifacts.add("default", artifact)
    This works for building and when I publish those artifacts also get published with the correct versions and my other libraries correctly depend on them. The problem is that I get some warnings when syncing Intellij with the projects that depend on those projects (in thread) and the commonMain source set (using KMM) is not getting treated as source code). So I want to do this right. I found this https://youtrack.jetbrains.com/issue/IDEA-274929 that states what I’m doing is wrong. If I follow the recommendation everything syncs up right. But this will break the publication goals that I have. Plus due to how gradle caches remote artifacts, I feel this will create problems when trying to update the files. I can probably make everything work, but I’m wondering if there is a proper way to create a project that does just provide a precompiled artifact like I’m doing.
  • g

    Guilherme Delgado

    09/15/2022, 9:46 PM
    Anyone experiencing this (gradle-7.5.1-all.zip or gradle-7.5.1-bin.zip)? 🤔
    org.gradle.api.InvalidUserDataException: Invalid TOML catalog definition:
      - Problem: In version catalog libs, unknown top level elements [plugins].
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    Although it seams to fail, it works 🤷‍♂️ . Bundles, Libraries and Plugins are generated and I can use them with no problem.
    m
    v
    • 3
    • 7
  • k

    Kristian Nedrevold

    09/16/2022, 6:45 AM
    Can gradle recompile on file changes? Like stb can with stb ~run?
    e
    • 2
    • 2
  • z

    Zach

    09/16/2022, 7:02 PM
    I am attempting to import a ksp dependency, but when I do
    ksp()
    it shows up as an unresolved reference. In an attempt to add ksp to my project, I followed the quickstart guide here https://kotlinlang.org/docs/ksp-quickstart.html but when I sync gradle I get a significant amount of errors. Am I doing something wrong?
    t
    v
    • 3
    • 8
  • d

    dsvoronin

    09/16/2022, 7:47 PM
    Hello, i'am currently investigating ongoing blockers for project isolation in android project, and wondering that known issues in kotlin gradle plugin has no target version. I am under impression that android team actively preparing it for next 8.0 agp release: https://issuetracker.google.com/issues/190016272/dependencies Also there are no "Epic"(Story) about supporting it that i could link for my internal tracker research. I am currently using https://youtrack.jetbrains.com/issues/KT?q=%22project%20isolation%22
    t
    • 2
    • 4
  • n

    napperley

    09/17/2022, 3:16 AM
    How do I manually create a Test source set (for linuxCommon)? Currently the sourceSets block looks like the following:
    // ...
    sourceSets {
            commonMain {
                dependencies {
                    // ...
                }
            }
            val linuxCommonMain by creating {
                // ...
            }
            @Suppress("UNUSED_VARIABLE")
            val linuxX64Main by getting {
                dependsOn(linuxCommonMain)
            }
            @Suppress("UNUSED_VARIABLE")
            val frontendMain by getting {
                resources.srcDir(webDir)
            }
        }
    e
    v
    • 3
    • 7
  • n

    Norbi

    09/19/2022, 12:55 PM
    How can I setup a Kotlin multi-platform library project with different JVM targets for different JVM versions? Something like:
    kotlin {
        jvm { // Java 8 compatible
            ???
        }
        jvm("java17") {// Java 17 compatible
            ???
        }
    Is it possible? Thanks.
    e
    • 2
    • 1
Powered by Linen
Title
n

Norbi

09/19/2022, 12:55 PM
How can I setup a Kotlin multi-platform library project with different JVM targets for different JVM versions? Something like:
kotlin {
    jvm { // Java 8 compatible
        ???
    }
    jvm("java17") {// Java 17 compatible
        ???
    }
Is it possible? Thanks.
e

ephemient

09/19/2022, 1:17 PM
did you try it? you can set the JVM targets per Kotlin target with
kotlin {
    jvm {
        attributes {
            attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 8)
        }
        compilations.all {
            kotlinOptions {
                jvmTarget = "1.8"
            }
        }
    }
    jvm("java17") {
        attributes {
            attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 17)
        }
        compilations.all {
            kotlinOptions {
                jvmTarget = "17"
            }
        }
    }
}
it's a shame it isn't more automatic than this, but it works
View count: 9