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
  • j

    Justin

    06/15/2020, 2:48 AM
    Anyone have any insight on this: https://discuss.kotlinlang.org/t/test-dependency-in-a-kotlin-multiplatform-gradle-multi-project/16880 ?
    d
    2 replies · 2 participants
  • c

    christophsturm

    06/15/2020, 12:02 PM
    does idea not use the gradle wrapper to import my project?
    t
    g
    3 replies · 3 participants
  • a

    Aaron Todd

    06/15/2020, 1:36 PM
    Trying to setup integration tests that depend on a common test utility project. Having trouble resolving with Kotlin MPP. Right now just trying to get JVM to work. The "test-utils" project builds fine, gradle seems happy overall but the classes from the "test-utils" project are not resolved and can't be imported in "project A" tests.
    // project A
    
    val integrationTest by creating {
        kotlin.srcDir("it")
        dependsOn(getByName("jvmTest"))
        dependencies {
            implementation(project(":test-utils", "jvmMainImplementation"))
            implementation("org.jetbrains.kotlin:kotlin-test:$kotlinVersion")
            implementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlinVersion")
        }
    }
    I've tried various incantations of depending on the "test-utils" project including custom configurations. I was working on setting up a test Jar output but also having trouble with Gradle Kotlin DSL and MPP.
    // project "test-utils"
    kotlin {
        sourceSets {
            jvmMain {
                dependencies {
                    api("org.jetbrains.kotlin:kotlin-test:$kotlinVersion")
                    api("org.jetbrains.kotlin:kotlin-test-junit:$kotlinVersion")
                    ...
                }
            }
        }
    }
    I can't tell which I'm fighting, Gradle Kotlin DSL, Kotlin MPP, or both. The generic problem: How to setup a custom (test) source set and depend on another project that provides common test utils using Kotlin MPP? I've seen examples of this without Kotlin MPP but that seems to be adding an extra layer that I haven't connected. Any ideas or examples to look at?
    👍 1
    j
    4 replies · 2 participants
  • u

    ursus

    06/15/2020, 3:48 PM
    People who do many modules, do you group them under folders, i.e payment/api, ui or put everything in root and create hierarchy via dashes? i.e. payment-api, payment-ui etc
    📁 4
    d
    13 replies · 2 participants
  • j

    Joost Klitsie

    06/15/2020, 7:37 PM
    Hi everyone! I am making some project which has a JVM backend module, a shared multiplatform Common module and a multiplatform Frontend module. I wanted to use the buildSrc to define my dependencies, and chop it into nice methods like
    fun DependencyHandlerScope.implementKtorServer(flavor: String = "") {
                implementation(ktor(Serialization), flavor)
                //.... others...
                implementation(ktor(AuthJwt), flavor)
            }
    In this way, I can easily call this from my build.gradle.kts for the backend module
    dependencies {
        implementKtorServer()
        // ... other things
    This is because the dependencies in a Gradle file give you a DependencyHandlerScope context. However, with multiplatform, like this:
    val commonMain by getting {
                dependencies {
                    // ... stuff
    You have a 
    KotlinDependencyHandler
     context. So my question is: How can I make an extension function in my buildSrc module on a KotlinDependencyHandler? I tried to pull in some kotlin gradle plugin dependencies in my buildSrc/build.gradle.kts but no luck. For now, it looks like this:
    plugins {
        `kotlin-dsl`
    }
    repositories {
        jcenter()
    }
    And 
    KotlinDependencyHandler
      is until now unresolved 😞 Does anyone know what I could do here?
    a
    9 replies · 2 participants
  • b

    Brendan Weinstein

    06/15/2020, 9:45 PM
    Is there a commitment to improve kotlin gradle dsl performance? I'd love to switch to it just for the developer productivity boost of using
    cmd+b
    to see where a dependency version var is defined in a project with many modules. I am not sure that the dev productivity boost outweighs the marginal slowdown in compile time. And when major open source kotlin repositories (eg coroutines) are not using the dsl it signals that there is not even confidence within jetbrains around using it. You can
    ctrl+j
    for documentation lookup but there is little-to-no documentation of the dsl-ified version of the android plugin, and often the function signatures are not informative.
    o
    c
    +3
    34 replies · 6 participants
  • e

    elect

    06/19/2020, 11:38 AM
    I see a
    compileKotlin
    task when I build, although the project is pure java with kotlin libs, is it fine?
    r
    5 replies · 2 participants
  • t

    tim

    06/19/2020, 12:57 PM
    Hi all, i'm trying to setup one of my kotlin projects with git submodules like so:
    build.gradle.kts
    projects/api
    ...
    projects/core <-- a git submodule
    projects/core/gradle.build.kts // file in question
    Normally, I have the parent project specify plugin dependency versions. This works fine for everything except for core. Because Core is a submodule I can clone it and work on it in isolation, where in that case I need to specify plugin versions:
    kotlin("jvm") version("...") apply(true)
    but when core is consumed as a submodule and the parent project specifies the version i get a build error from gradle:
    Plugin request for plugin already on the classpath must not include a version
    Any suggestions on how to approach/workaround this?
    👀 1
    n
    g
    5 replies · 3 participants
  • s

    Stefano Longhi

    06/24/2020, 8:02 AM
    Hi guys, I asked in the getting-started channel but probably the right place is this one. Any one can help me? Thanks!
    j
    n
    12 replies · 3 participants
  • j

    Joakim Tengstrand

    06/24/2020, 2:09 PM
    Hi everyone! I cloned this repo https://github.com/gradle/guides.git and then I went into the folder 'guides/subprojects/building-kotlin-jvm-libraries/samples/code/my-kotlin-library' and executed "gradle publish" which is suggested at the end of the section "Push to local repository" in https://guides.gradle.org/building-kotlin-jvm-libraries/, but it doesn't work, I get: FAILURE: Build failed with an exception. * Where: Build file '/Users/tengstrand/source/guides/subprojects/building-kotlin-jvm-libraries/samples/code/my-kotlin-library/build.gradle.kts' line: 43 * What went wrong: Script compilation error:  Line 43:   from(java.sourceSets["main"].allSource)              ^ Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:                 public val Project.sourceSets: SourceSetContainer defined in org.gradle.kotlin.dsl                public val KotlinJvmProjectExtension.sourceSets: NamedDomainObjectContainer<KotlinSourceSet> defined in org.gradle.kotlin.dsl
    n
    1 reply · 2 participants
  • s

    Stefano Longhi

    06/24/2020, 4:35 PM
    Hi all I have another problem with gradle.. If I run the project from Intellij all ran correctly, if I try to run it from the terminal using grandle run I receive this error:
    [...]
    Successfully started process 'command '/Library/Java/JavaVirtualMachines/jdk-14.0.1.jdk/Contents/Home/bin/java''
    Error: Could not find or load main class abaddon83.tests.marvels.AppKt
    Caused by: java.lang.ClassNotFoundException: abaddon83.tests.marvels.AppKt
    :run (Thread[Execution worker for ':',5,main]) completed. Took 0.118 secs.
    BuildUid: local
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':run'.
    > Process 'command '/Library/Java/JavaVirtualMachines/jdk-14.0.1.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
    the classpath abaddon83.tests.marvels.AppKt is right 😞 any idea?
    1 reply · 1 participant
  • b

    Brian

    06/26/2020, 2:58 AM
    Has anyone worked with the
    org.jetbrains.grammarkit
    plugin? I'm having issues with Grammar Kit being able to find a class. I don't actually know if the problem is with Gradle or if it's a Grammar Kit problem. Assuming it's a build script problem, how do I ensure that
    main/kotlin
    is on the parser generator's classpath?
    1 reply · 1 participant
  • c

    Chilli

    06/28/2020, 9:28 AM
    Any idea, anyone?
    n
    3 replies · 2 participants
  • j

    Joakim Tengstrand

    06/29/2020, 3:36 PM
    I try to get multi projects to work from IntelliJ IDEA. but fails. Anyone here that managed to get it to work? A link to a working project would probably be the best. Thanks.
    d
    g
    +1
    4 replies · 4 participants
  • j

    janvladimirmostert

    06/30/2020, 8:01 PM
    if i have the following structure and i want to include project-d+e as a dependency inside project b and then again inside project-a how would i set this up?
    build.gradle.kts
    settings.gradle.kts
    subprojects
      +-- project-www
      +-- project-a (kotlin jvm)
      +-- project-b (kotlin mp jvm+js)
      +-- project-c (kotlin mp jvm+js)
      +-- project-d (java jvm)
      +-- project-e (kotlin jvm)
    inside my settings.gradle.kts (root), i've added
    include("project-www")
    include("project-a")
    include("project-b")
    ...
    include("project-e")
    what should be going into my
    project-b/settings.gradle.kts
    and
    project-b/build.gradle.kts
    in order to pull in that project-d or project-e dependencies? and then i want to include that multiplatform's JVM part in project, would i be following the same steps or should i do something different for including a multiplatform project as dependency?
    t
    a
    12 replies · 3 participants
  • l

    LastExceed

    07/01/2020, 11:32 AM
    anyone got a small scale project featuring maven-publish that i can look at as an example on how to publish to MavenCentral ? the documentation is overwhelming me
    g
    3 replies · 2 participants
  • t

    tim

    07/01/2020, 3:24 PM
    Hello, I have a multi-project kotlin setup and I want to access test helper classes cross project. Basically I have this:
    // inside project A /src/tests/kotlin
    package com.example.a
    object TestHelper { ... }
    And from project b I'd like to be able to do
    // inside project B /src/tests/kotlin
    package com.example.b
    
    import com.example.a.TestHelper
    
    fun someTest() ...
    I was checking out test fixtures gradle plugin for java but I couldn't get it to work. Wasnt sure if i was misconfigurating it, or otherwise?
    ➕ 1
    j
    2 replies · 2 participants
  • j

    Joakim Tengstrand

    07/02/2020, 9:19 AM
    Has anyone here managed to get Gradle DSL multi projects to work where you have your sub projects in e.g. a subprojects folder at the root as they do in the gradle project itself, see line 181 here? I also want the IntelliJ IDEA integration to work.
    g
    n
    +1
    21 replies · 4 participants
  • f

    Frodrigues

    07/06/2020, 12:09 PM
    Hello, I want to create a multi project configuration like this multi-kotlin-project-config-injection. But because my sub-projects use the same dependencies of each other, I also want my main project to "inject" the dependencies and plugins to every subproject. How can I do it?
    j
    5 replies · 2 participants
  • j

    Joost Klitsie

    07/08/2020, 8:07 AM
    Hi all! I have a project that contains multiple projects. I have a module for my backend and a module for my frontend (multiplatform). As soon as I start my backend process (by using
    :backend:run
    task in intellij) I cannot run my frontend project (by using
    :frontend:jsBrowserDevelopmentRun
    ). Absolutely nothing is happening as long as one of the two is running. The other has 0 output and will only magically start running once the first one is killed. (so for example there is no port clash, they use different ports anyway, but it doesn't get that far). If I save the run configuration and check the flag in intellij (or in Android studio, in both) at the run configurations to run in parallel, exactly nothing happens. I can save it all I want, but anytime I open the run configurations dialog again the parallel flag is unchecked.
    org.gradle.parallel=true
    is set in my build.gradle. Is there any way I can run 2 different modules at the same time in intellij? (they share a common library if that is important). Also, I can run them simultaneously in bash with commands like
    ./gradlew :backend:run
    on Windows. But there is no way for me to kill the process (so for example ^C does absolutely nothing, ^D does also nothing). I can only kill the process through task manager or probably if I open another bash find the process and kill it like that)
    n
    1 reply · 2 participants
  • o

    Offz

    07/09/2020, 1:49 AM
    Hello, I'm using composite builds to locally work on project
    B
    from
    A
    .
    B
    includes several subprojects and I'd like to include one, say
    subproject
    , as a dependency in
    A
    Is there any way to do this nicely with composite builds, what would my alternatives be if there isn't?
    o
    23 replies · 2 participants
  • j

    janvladimirmostert

    07/10/2020, 8:13 PM
    what is the correct way to always run another task after a build? I've tried
    task("build").finalizedBy("jsPublicPackageJson")
    but it complains
    Cannot add task 'build' as a task with that name already exists.
    o
    a
    +1
    16 replies · 4 participants
  • e

    Exerosis

    07/12/2020, 9:09 AM
    I have a multiplatform library which I have on jitpack, when I try to depend on it from just a pure java project I get this error:
    > Could not resolve com.github.Exerosis.Mynt:Mynt-metadata:1.0.4.
      Required by:
          project : > com.github.Exerosis:Mynt:1.0.4
       > Unable to find a matching variant of com.github.Exerosis.Mynt:Mynt-metadata:1.0.4:
           - Variant 'metadata-api' capability com.github.Exerosis.Mynt:Mynt-metadata:1.0.4:
               - Incompatible attributes:
                   - Required org.gradle.usage 'java-runtime' and found incompatible value 'kotlin-api'.
                   - Required org.jetbrains.kotlin.platform.type 'jvm' and found incompatible value 'common'.
               - Other attributes:
                   - Required org.gradle.dependency.bundling 'external' but no value provided.
                   - Required org.gradle.jvm.version '8' but no value provided.
                   - Required org.gradle.libraryelements 'jar' but no value provided.
                   - Found org.gradle.status 'release' but wasn't required.
    As well as a similar one for Mynt-js, am I doing something wrong? I've even tried excluding those parts:
    implementation("com.github.Exerosis:Mynt:1.0.4") {
        exclude("com.github.Exerosis", "Mynt-js")
        exclude("com.github.Exerosis", "Mynt-metadata")
    }
    But no luck 😞
    t
    2 replies · 2 participants
  • c

    Christian Sousa

    07/13/2020, 2:17 PM
    Anyone knows how can I do something like this on Kotlin DSL?
    compile group: 'com.test', name: 'lib', version: '1.0.0', ext: 'pom'
    g
    7 replies · 2 participants
  • t

    tim

    07/13/2020, 7:51 PM
    Hello, i'm trying to write e2e tests across several micro services. I'd like include various micro services in an e2e project but I'm encountering build issues when including them via settings.gralde.kts. For example, one of the included projects, (which is part of a multi project micro service), is causing build errors (i.e., "Unresolved reference" for an included plugin). Has anyone had success with this type of setup or is there a better approach? I'm going to try symlinking these services into my e2e-testing project next, but that feels a bit hacked together.
    d
    t
    27 replies · 3 participants
  • l

    Loboda Deni

    07/14/2020, 2:26 PM
    Hello. Does anyone know if there have been studies regarding the build speed of a project on kts vs groovy?
    g
    n
    +3
    20 replies · 6 participants
  • l

    Loboda Deni

    07/15/2020, 8:23 AM
    why can I get a message stating that compileOptions is unstable because its signature references unstable CompileOptions marked with @Incubating, and is there anything I can do about it?
    g
    1 reply · 2 participants
  • l

    Loboda Deni

    07/16/2020, 4:44 PM
    How do you like this approach to organizing dependencies? https://github.com/Darkos-den/BuildScriptSample
    l
    11 replies · 2 participants
  • j

    Juan Rodríguez

    07/16/2020, 6:01 PM
    Hello there, I'm moving all my gradle files to kotlin dsl but I dont know how to move
    android {}
    from individual modules to
    subprojects {}
    (root gradle.kts) to share configuration between modules. In gradle I use something like this:
    subprojects {
      afterEvaluate {
    if(project.plugins.findPlugin("com.android.application") != null ||         project.plugins.findPlugin("com.android.library") != null) {
                android{ 
                   ...
    }
    e
    2 replies · 2 participants
  • p

    Praveen Talari

    07/19/2020, 2:39 PM
    Issue: Gradle application plugin using Kotlin is not compiling Java files. Steps: 1. Create gradle application gradle init Select type of project to generate:   1: basic   2: application   3: library   4: Gradle plugin Enter selection (default: basic) [1..4] 2 Select implementation language:   1: C++   2: Groovy   3: Java   4: Kotlin   5: Swift Enter selection (default: Java) [1..5] 4 Select build script DSL:   1: Groovy   2: Kotlin Enter selection (default: Kotlin) [1..2] 2 2. Add SomeJavaClass.java file beside App.kt file class SomeJavaClass{     public void m(){         System.out.println("x");     } } 3. Try to access SomeJavaClass in App.kt main method     SomeJavaClass().m() Excepted Output: Should be able to run Actual Output: no compile issues but crash because of NoClassDefFoundError
    g
    1 reply · 2 participants
Powered by Linen
Title
p

Praveen Talari

07/19/2020, 2:39 PM
Issue: Gradle application plugin using Kotlin is not compiling Java files. Steps: 1. Create gradle application gradle init Select type of project to generate:   1: basic   2: application   3: library   4: Gradle plugin Enter selection (default: basic) [1..4] 2 Select implementation language:   1: C++   2: Groovy   3: Java   4: Kotlin   5: Swift Enter selection (default: Java) [1..5] 4 Select build script DSL:   1: Groovy   2: Kotlin Enter selection (default: Kotlin) [1..2] 2 2. Add SomeJavaClass.java file beside App.kt file class SomeJavaClass{     public void m(){         System.out.println("x");     } } 3. Try to access SomeJavaClass in App.kt main method     SomeJavaClass().m() Excepted Output: Should be able to run Actual Output: no compile issues but crash because of NoClassDefFoundError
g

gildor

07/19/2020, 2:43 PM
It's probably would be better to report issue on Gradle issue tracker
View count: 6