https://kotlinlang.org logo
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
  • w

    wuseal

    08/06/2019, 3:26 PM
    If I need to get kotlin_version value in
    build.gradle.kts
    from
    gradle.properties
    file, I can get the value by
    val kotlin_version: String = property("kotlin_version").toString()
    but can’t by
    val kotlin_version: String by properties
    . WHY?😂 , Anybody could tell me?
    m
    j
    • 3
    • 8
  • m

    Matej Drobnič

    08/07/2019, 6:43 AM
    Is there a way to access properties of the plugins that do NOT support declaractive plugin syntax (e.g. only support
    apply from
    syntax) in kts gradle script? Currently I'm doing a hack by putting all properties of this plugin into regular non-kts gradle file and then applying that file, but it's ugly.
    m
    g
    • 3
    • 20
  • t

    thana

    08/07/2019, 12:16 PM
    when using the kotlin gradle dsl is it finally possible to make versions like used here global so i dont have to change 423852311 occurances of them on an update?
    plugins {
        kotlin("multiplatform") version "1.3.41"
    }
    d
    g
    • 3
    • 11
  • t

    thana

    08/07/2019, 12:28 PM
    i have a multi module build. in my parent build.gradle i used
    plugins {
        id "org.jetbrains.kotlin.multiplatform" version '1.3.41' apply false
    }
    now i finally wanted to try out the kotlin dsl and creaed a child module with a build.gradle.kts where i use
    apply(plugin = "org.jetbrains.kotlin.multiplatform")
    but now the
    kotlin { }
    block cannot be resolved what am i doing wrong?
    a
    • 2
    • 6
  • t

    thana

    08/08/2019, 10:35 AM
    i have a task that copys the generated
    .js
    and
    .meta.js
    files from the
    js()
    target somewhere else for some reason. with the original groovy i could acces this folder with
    compileKotlinJs.destinationDir
    . How can i do that with kotlin dsl?
    s
    s
    • 3
    • 3
  • o

    Ola Adolfsson

    08/08/2019, 2:27 PM
    Can it be solved without installing xCode?
    a
    • 2
    • 2
  • a

    Alexander Weickmann

    08/08/2019, 4:34 PM
    HI all, To reuse Gradle Configuration in subprojects, I would like to declare and then use a function, like is done here: https://github.com/JetBrains/kotlin-wrappers/blob/master/build.gradle#L54 How can I achieve the same in Kotlin DSL?
    m
    g
    • 3
    • 13
  • m

    mbonnin

    08/08/2019, 5:58 PM
    Any idea why I need to specify the version explicitely if I depend on
    kotlin-stdlib-jdk8
    but not for plain
    kotlin-stdlib
    ?
    implementation("org.jetbrains.kotlin:kotlin-stdlib")
    works but
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
    doesn't
    o
    s
    • 3
    • 19
  • p

    pablisco

    08/10/2019, 1:11 PM
    We've been moving to use Kotlin DSL and therefore moving the dependencies to
    buildSrc
    as a
    dependendies.kt
    file. However we have tests inside
    buildSrc
    so the
    build.gradle.kts
    inside
    buildSrc
    has dependencies too. Anyone has or can think of a way to use the dependencies from the build script in the
    buildSrc
    folder?
    ➖ 1
    ➕ 1
    m
    g
    +2
    • 5
    • 28
  • t

    thana

    08/13/2019, 11:46 AM
    is there a way to automatically apply the kotlin option
    jvmTarget = "1.8
    to all submodules?
    g
    • 2
    • 8
  • t

    thana

    08/13/2019, 2:50 PM
    intellij informs me that i could convert the following into a lambda (what i'd really like to do):
    tasks.withType(Test::class).configureEach(object : Action<Test> {
            override fun execute(it: Test) {
                it.outputs.upToDateWhen { false }
            }
        })
    Yet when i do it manually or let intellij do it for with following result:
    tasks.withType(Test::class).configureEach {
            it.outputs.upToDateWhen { false }
        }
    It complains that
    it
    is undefined. Any idea why?
    k
    l
    • 3
    • 5
  • g

    ghedeon

    08/14/2019, 8:55 PM
    Is it possible to write tasks in Kotlin in buildSrc, without migrating to DSL?
    :yes: 3
    m
    g
    +2
    • 5
    • 44
  • n

    Nikolai Skladnev

    08/16/2019, 11:04 AM
    Hi, I have kotlinJS project and want publish artifact by maven-publish plugin, but created .pom hasn't our dependencies. How can I configure project for adding project dependencies to publicated .pom?
    g
    i
    • 3
    • 10
  • m

    Matej Drobnič

    08/20/2019, 5:13 AM
    Is there a way to trigger apply dependencies with a keyboard shortcut? I couldn't find a relevant action
    g
    e
    • 3
    • 3
  • s

    Slackbot

    08/20/2019, 9:36 AM
    This message was deleted.
    g
    • 2
    • 2
  • t

    tulio

    08/21/2019, 7:53 PM
    I wanted to do something like
    tasks.register(CustomTask)
    and just override the name in my CustomTask
    g
    • 2
    • 4
  • j

    juliocbcotta

    08/23/2019, 2:34 AM
    Is there any plugin for AS that helps me to convert my build.gradle files to build.gradle.kts files ?
    v
    g
    i
    • 4
    • 5
  • r

    ribesg

    08/23/2019, 9:34 AM
    What dependency do I need to add to my buildSrc project to be able to call
    Project.publishing
    added by
    maven-publish
    ?
    e
    • 2
    • 4
  • m

    Marc Knaup

    08/23/2019, 1:42 PM
    My guess is that because I’m using
    .kts
    Gradle files Android Studio doesn’t import all settings properly and I cannot access the module settings to change the version manually.
    o
    • 2
    • 1
  • r

    robertoestivill

    08/23/2019, 2:58 PM
    Any clues on this one folks https://stackoverflow.com/questions/57627119/android-subprojects-with-kotlin-dsl ?
    ✅ 1
    m
    m
    +2
    • 5
    • 31
  • m

    mbonnin

    08/24/2019, 11:54 AM
    So I just bumped into this:
    The Kotlin Gradle plugin was loaded multiple times in different subprojects, which is not supported and may break the build.
    Please add the Kotlin plugin to the common parent project or the root project, then remove the versions in the subprojects.
    What exact kotlin plugin are we talking about ? My root project has modules using
    org.jetbrains.kotlin.android
    and others using plain
    org.jetbrains.kotlin.jvm
    . Can they/Should they both be applied in the root build.gradle.kts ?
    g
    • 2
    • 5
  • d

    darkmoon_uk

    08/27/2019, 4:33 AM
    I'm converting some existing Groovy/Gradle scripts to Kotlin DSL and found a bit of a gap in Kotlin's capability when it comes to reading arbitrary JSON. In these Groovy scripts, an arbitrary JSON structure is read from a file using the wonderfully named JsonSlurper and accessed via 'dot' path. e.g.
    val buildConfig : Any? = JsonSlurper().parseText(buildConfigFile.readText())
    val defaultInstallDir = buildConfig.SetupDefaults.InstallDir  // Not compiling as Kotlin compiler doesn't generate dynamic access code
    I understand this kind of dynamicism is exactly where Groovy excels (and suffers in equal measure), where Kotlin is meant to be more type safe.
    g
    • 2
    • 1
  • d

    darkmoon_uk

    08/27/2019, 4:34 AM
    But how best to convert this - am I basically left with having to create a model class; or use long-form reflection - is there a shorter way?
    j
    g
    • 3
    • 5
  • s

    stepango

    08/27/2019, 11:04 AM
    Is there any way of disabling the task but still running all the tasks which depends on it?:)
    m
    n
    • 3
    • 2
  • j

    Jeremy

    08/31/2019, 10:01 PM
    I'm converting a script to kotlin dsl. What is the correct syntax of kapt?
    kapt("group:name:version")
    results in
    inferred type is String but Action<KaptExtension> was expected
    d
    o
    g
    • 4
    • 11
  • k

    Kroppeb

    08/31/2019, 10:24 PM
    When I try to
    import kotlinx.serialization.*
    it tells me it can't resolve
    serialization
    . I'm assuming it is cause my build.gradle is messed up or something
    d
    • 2
    • 4
  • m

    mbonnin

    09/02/2019, 1:42 PM
    When converting from
    build.gradle
    to
    build.gradle.kts
    , it looks like autocomplete in IDEA doesn't work until a first gradle sync is successful. Generated accessors are missing but also more regular things are underlined in red. So what I do is usually comment all of the build.gradle.kts and then uncomment parts as I fix them. Is there a better way to do this ? I feel like even if my
    android
    block is wrong, the
    dependencies
    could be parsed correctly ?
    o
    • 2
    • 1
  • c

    Czar

    09/03/2019, 6:55 AM
    Hi! In parent `build.gradle.kts`:
    subprojects {
      dependencies {
        implementation(platform(SpringBootPlugin.BOM_COORDINATES))
      }
    }
    in a subproject:
    dependencies {
      kapt("org.springframework.boot:spring-boot-configuration-processor")
    }
    result:
    > Could not find org.springframework.boot😒pring-boot-configuration-processor:.
    if I change
    kapt
    to
    implementation
    , dependency resolution will work, but obviously won't do what is needed. I know this is in part Spring question, but the problem seems to be more gradle than Spring. Basically there is a platform defined by BOM and there is a configuration defined by kapt plugin, gradle does not resolve dependency version for it.
    e
    • 2
    • 2
  • f

    Feri Nagy

    09/03/2019, 10:58 AM
    Hi! I see similar questions, but I did not quite find my answer, so here we go again. I converted our gradle scripts to kotlin, extracting common version constants and logic to
    buildSrc
    . Now (hopefully) only last thing remains. In the
    buildSrc/build.gradle.kts
    we have:
    dependencies {
        implementation("com.android.tools.build:gradle:3.4.1")
    }
    Then in root project’s
    build.gradle.kts
    we have:
    buildscript {
        repositories {
            google()
            ...
        }
        dependencies {
            classpath("com.android.tools.build:gradle:3.4.1")
            ...
        }
    }
    Is there a way so that the version
    3.4.1
    would be specified only in single place? Thanks for any tips.
    m
    g
    • 3
    • 9
  • b

    Bernhard

    09/09/2019, 8:13 AM
    is there a list of kotlin plugins modules available anywhere?
    g
    c
    • 3
    • 6
Powered by Linen
Title
b

Bernhard

09/09/2019, 8:13 AM
is there a list of kotlin plugins modules available anywhere?
g

gildor

09/09/2019, 8:14 AM
Modules?
b

Bernhard

09/09/2019, 8:45 AM
/**
 * Applies the given Kotlin plugin [module].
 *
 * For example: `plugins { kotlin("jvm") version "1.3.41" }`
 *
 * Visit the [plugin portal](<https://plugins.gradle.org/search?term=org.jetbrains.kotlin>) to see the list of available plugins.
 *
 * @param module simple name of the Kotlin Gradle plugin module, for example "jvm", "android", "kapt", "plugin.allopen" etc...
 */
fun PluginDependenciesSpec.kotlin(module: String): PluginDependencySpec =
    id("org.jetbrains.kotlin.$module")
currently looking for jpa support
can I just use kotlin(“plugin.jpa”) version xxx
ah nvm, there’s a url in the docs my bad
c

Czar

09/09/2019, 10:37 AM
yup, it's exactly as you wanted it:
kotlin("jvm")
kotlin("plugin.spring")
kotlin("plugin.jpa")
kotlin("kapt")
View count: 3