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

    ankushg

    08/26/2021, 5:51 PM
    Hey friends, Is there a way to either • get the
    KotlinCompile
    task for a given
    KotlinCompilation
    , or alternatively • get the
    KotlinCompilation
    for a given
    KotlinCompile
    task? For background (in case there's a better way to do what I'm trying to do) I have a multiplatform project with a
    JS(IR)
    target. I'm trying to get the
    KotlinJsIrLink
    task (a subclass of
    KotlinCompile
    ) for the production, main artifact so that I can write a Gradle task to send the generated
    .d.ts
    file elsewhere. I can do
    tasks.withType<KotlinJsIrLink>.filter { it.mode == KotlinJsBinaryMode.PRODUCTION }
    but I still get the tasks corresponding to test compilations in there. I can also do
    kotlin.targets.flatMap { it.compilations }.filter { it is KotlinJsIrCompilation && it.name == KotlinCompilation.MAIN_COMPILATION_NAME }
    but that includes non-production compilations, and I can't figure out how to go from that to the
    KotlinJsIrLink
    tasks. Any tips would be appreciated!
    b
    • 2
    • 1
  • n

    Nick

    08/26/2021, 7:00 PM
    Is it possible to create a build.gradle.kts file, in addition to a build.gradle file, and add any new dependencies in there? I’d like to transition from groovy to kotlin.
    t
    c
    • 3
    • 6
  • j

    jmfayard

    08/27/2021, 11:24 AM
    What are your favorite Gradle plugins? I want to write about Gradle
    h
    j
    +5
    • 8
    • 11
  • a

    Ayfri

    08/27/2021, 5:05 PM
    Hi, do you know how can I define the plugins of my project using the
    libs.versions.toml
    ?
    :yes: 1
    :not-kotlin: 2
    :stackoverflow: 2
    e
    • 2
    • 3
  • r

    Richard Glen

    08/28/2021, 4:07 AM
    In Kotlin/JS, how does the index.html get generated? Where can I find this in the kotlin gradle source code?
    b
    • 2
    • 5
  • j

    Jeff Davidson

    08/29/2021, 4:21 AM
    I want to share some internal-only utilities for both main and test code between multiple projects in a multi-project build. what would be the best way to accomplish that? defining projects just for the utilities doesn't seem great because it seems they'd have to be published along with the regular artifacts, and I'd rather not expose these utilities as public APIs. would you create a sourceset pointed to the utility code for each project that needs it?
    e
    s
    • 3
    • 9
  • e

    Erdem Tuna

    08/30/2021, 11:05 AM
    Hello, I have project properties set from command line. I want to pass them to another task. How to call a task with arguments from another task in the 
    build.gradle.kts
    ?
    v
    • 2
    • 1
  • v

    Vitaliy Zarubin

    08/30/2021, 12:21 PM
    what does the abbreviation kts (gradle) stand for?
    p
    b
    b
    • 4
    • 4
  • p

    pcarrier

    08/30/2021, 12:44 PM
    Trying:
    project.tasks.withType(KotlinCompile::class.java).configureEach {
    			kotlinOptions {
    				allWarningsAsErrors = true
    				freeCompilerArgs = freeCompilerArgs +
    					listOf("-Xopt-in=kotlin.RequiresOptIn", "-opt-in=kotlin.time.ExperimentalTime")
    			}
    		}
    and running into:
    e: Invalid argument: -opt-in=kotlin.time.ExperimentalTime
    Am I getting the syntax wrong? That's how it's documented @ https://kotlinlang.org/docs/opt-in-requirements.html#module-wide-opt-in AFAICT
    👀 1
    b
    e
    • 3
    • 2
  • k

    Kirill Grouchnikov

    08/31/2021, 2:05 AM
    Is there a way to get local copies of all jars that are runtime dependencies of a multi-module project? In "traditional" gradle world I use a
    Copy
    task with
    subprojects.findAll { /* some condition */ }.collect { it.configurations.compileClasspath }
    g
    r
    • 3
    • 10
  • p

    Pitel

    08/31/2021, 6:29 AM
    Hi. How am I supposed to add sourceSet wiuth my genberated code?
    sourceSets.named("main") {
    	java.srcDirs("$buildDir/generated/graphql")
    }
    SourceSet with name 'main' not found.
    e
    d
    • 3
    • 3
  • s

    suresh

    08/31/2021, 3:55 PM
    https://github.com/gradle/gradle/pull/18148
    🎉 4
    z
    j
    b
    • 4
    • 5
  • c

    Chachako

    09/01/2021, 9:55 AM
    Hi everyone, I wrote a gradle plugin, I want to integration testing, what suggestions or simple example, it is a bit difficult to get 🤯
    :not-kotlin: 2
    j
    m
    z
    • 4
    • 12
  • j

    James Whitehead

    09/01/2021, 10:39 AM
    Hi all, when generating a new kotlin project via gradle cli it automatically adds the "kotlin-bom" dependency to the project. Isn't this redundant due to the kotlin jvm gradle plugin?
    j
    • 2
    • 1
  • h

    hfhbd

    09/01/2021, 3:26 PM
    Anybody else getting this error after updating Gradle to 7.2 and Kotlin to 1.5.30?
    * What went wrong:
    Execution failed for task build
    > Failed to notify task execution listener.
    > KOTLIN_STAT_LABEl_PROPERTY
    🇳🇴 1
    t
    • 2
    • 7
  • f

    FunkyMuse

    09/01/2021, 9:02 PM
    Hey guys, after updating to gradle 7.0.2 i'm getting
    > Task :app:stripReleaseDebugSymbols
    Unable to strip the following libraries, packaging them as they are
    same thing is happening with gradle 7.0.1 too
    :not-kotlin: 4
    z
    • 2
    • 1
  • g

    Gama11

    09/03/2021, 1:17 PM
    is there any difference between
    tasks.withType<KotlinCompile>().configureEach {
    and
    tasks.withType<KotlinCompile> {
    ? It seems like the
    configureEach
    is redundant
    f
    • 2
    • 5
  • u

    ursus

    09/05/2021, 2:21 AM
    I'm trying to write a gradle plugin, I put it in /buildSrc, I define the META-INF/gradle-plugins/foo.bar.properties with fully qualified name, I apply it at the target project with
    apply plugin: foo.bar
    . Everyting works Then I change the plugin source from groovy to kotlin, and it doesn't work
    class BrowserStackPlugin :Plugin<Project> {
        override fun apply(project: Project) {
           ...
        }
    }
    A problem occurred evaluating project ':app'.
    > No implementation class specified for plugin 'foo.bar' in jar:file:/C:/Users/ursus/.gradle/caches/jars-8/d86af8da5bcd5c16642c4dc40605c5b9/buildSrc.jar!/META-INF/gradle-plugins/foo.bar.properties.
    Are kotlin plugins not supported in buildSrc??
    e
    m
    e
    • 4
    • 11
  • s

    Scott Whitman

    09/05/2021, 10:08 PM
    I'm trying to add Kotlin Serialization to my Custom Plugin. How do I put
    plugins {
        kotlin("plugin.serialization") version "1.5.30"
    }
    into
    override fun apply(project: Project) {
        // none of these work
        // project.pluginManager.apply("org.jetbrains.kotlin.plugin.serialization:1.5.30")
        // project.pluginManager.apply("org.jetbrains.kotlin.plugin.serialization")
        // project.plugins.apply("org.jetbrains.kotlin.plugin.serialization:1.5.30")
        // project.plugins.apply("org.jetbrains.kotlin.plugin.serialization")
    }
    Everything I have tried give me an error
    Plugin with id 'org.jetbrains.kotlin.plugin.serialization' not found
    r
    • 2
    • 1
  • n

    nuhkoca

    09/07/2021, 10:10 AM
    I am trying to access
    Groovy
    extra in my
    KTS
    scripts but I couldn’t make it. I have something in my
    constants.gradle
    ext {
        javaTypes = [
                NULL        : "null",
                TRUE        : "true",
                FALSE       : "false",
                BOOLEAN     : "boolean",
                STRING      : "String",
                STRING_ARRAY: "String[]",
                INT         : "int",
                LONG        : "long"
        ]
    }
    val javaTypes by extra
    
    buildConfigField(javaTypes.STRING, constants.HTTP_DEV_URL, asString(Urls.http_dev_url))
    And in a KTS script, I am trying to access it like above but I am getting error:
    Unresolved reference: javaTypes
    Can you help me? Thanks.
    m
    • 2
    • 3
  • r

    Richard Glen

    09/07/2021, 2:11 PM
    How do I trigger an added script option in package json?
    • 1
    • 3
  • d

    dsvoronin

    09/07/2021, 10:24 PM
    kotlin 1.5.21 i observe remote cache misses for any kotlinCompile task between macOs and Linux with single difference:
    Appending input value fingerprint for 'kotlinJavaToolchainProvider' to build cache key: 579ef60211f6a32e39cd244937049220
    Appending input value fingerprint for 'kotlinJavaToolchainProvider' to build cache key: 7b38054c10085dfb665417dd82eb8269
    why it could be different? nested
    kotlinJavaToolchainProvider.javaVersion
    are equal Why it's even calculated as a part of compilation task cache if only
    javaVersion
    property marked as
    @Input
    ?
    t
    n
    w
    • 4
    • 79
  • u

    ursus

    09/08/2021, 12:03 AM
    If I have a monorepo of multiple apps depending on many common modules, does it make sense for me to use composite builds, if I want to stay monorepo? Some performance benefit? It seems it's all built from source anyways And even if there was some build speed, if I were to break apart this one big gradle project into say 3 (per app), and I were to change a common module api, I'd need to open 3 projects (3 IDE instances) and work in the changes, right?
    :not-kotlin: 2
    z
    c
    +4
    • 7
    • 13
  • k

    Karlo Lozovina

    09/08/2021, 1:21 PM
    What would be the best reasons to use Gradle subprojects instead of tossing everything into one big pile? I have a smallish project of 15-20k lines of Kotlin, and a colleague has been telling me to split it up into multiple subprojects. Doing it naively creates a lot of circular dependencies so I'd have to refactor it a lot...
    r
    c
    t
    • 4
    • 9
  • a

    appleobject

    09/08/2021, 9:40 PM
    I updated to the latest android studio "arctic" and whenever my gradle build it returns error with reason unknown
    :not-kotlin: 2
    z
    • 2
    • 1
  • j

    Joffrey

    09/10/2021, 10:52 PM
    Hey guys is there any way to pass environment variables to the process running Kotlin/Native iOS tests? The following works fine for
    mingwX64
    target:
    tasks.withType<org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeTest> {
        environment("SOME_VAR", "some value")
    }
    But for some reason those are not passed when running iOS tests. Does this have to do with the fact that iOS tests run in a simulator and therefore likely start a separate process? Is there any way to pass environment variables to that other process, then? (Note that in reality I'm setting
    environment()
    in a nested
    doFirst { }
    block because I need execution time information, but the problem occurs as well even without this peculiarity so I simplified the example)
    ✅ 1
    • 1
    • 1
  • a

    A. Sachdeva

    09/12/2021, 7:33 PM
    Hi . I am doing some experiments with gradle and the
    kotlin-dsl
    gradle plugin for android. So far i really liked the concept of configuring dependencies via a single
    buildSrc/src/main/Dependencies.kt
    file. I want to take it a step further and have the whole app configuration configured from pure kotlin files. is that possible? something like the old
    apply from("${project.rootDir}/commons.gradle")
    , but for koltin , like if i add an android library, all i need to do is add a build.gradle.kts file in library root with some static function call, like
    GradleConfigurations.librarySetup(this)
    and there i could automatically setup project plugins, dependencies, the
    android{}
    block, etc? How to do that? So far i have been able to do this for the root level
    build.gradle.kts
    file, but
    app/build.gradle.kts
    seems to use internal/inaccessible extensions. so any other approach ?
    v
    • 2
    • 2
  • a

    andylamax

    09/13/2021, 1:45 AM
    Hi, I am having trouble configuring a new compilation (called integrationTest) for the js target. Technically, the compilation is not the hard part, its the test task that is making me pulling my hair. The ultimate goal is to be able to set unit, integration and acceptance tests for all targets of the application. How does one achieve this? More in thread
    • 1
    • 3
  • o

    Orhan Tozan

    09/13/2021, 8:49 AM
    Can someone tell me why Gradle offline mode makes such a huge difference (like 10x faster) when building, while my internet is 1000MB/s? What is it doing? Is it redownloading all the dependencies? I assume not. Why does the "internet" part of the gradle builds take so long? I'm on AS Arctic Fox 2020.3.1 Patch 2
    :not-kotlin: 4
    a
    v
    • 3
    • 7
  • j

    Jonas Frid

    09/13/2021, 12:50 PM
    I have a gradle config in Android Studio that runs all my tests. How do I execute that from the terminal?
    v
    • 2
    • 1
Powered by Linen
Title
j

Jonas Frid

09/13/2021, 12:50 PM
I have a gradle config in Android Studio that runs all my tests. How do I execute that from the terminal?
v

Vampire

09/13/2021, 1:49 PM
./gradlew check
?
View count: 2