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

    spand

    05/28/2021, 9:03 AM
    Anyone have good experiences with enabling shared build caches (ie. read-only from CI) for Kotlin projects?
    g
    • 2
    • 3
  • u

    ursus

    05/29/2021, 12:37 AM
    Is there a way if a given
    implementation
    dependency is used in a given module? (for all modules; other than obviously trying each one and running build)
    e
    • 2
    • 49
  • n

    Nikhil

    05/29/2021, 5:27 PM
    Hi, Can someone help on how to use signing on Gradle 7.0 (I’m using gradle 7.0 kKotlin dsl - To sign the artifact)
    signing {
        useGpgCmd()
        sign(publishing.publications["somePublicatioin"])
    }
    According to documentation I’ve tried setting up the keyName and passphrase in my gradle.properties https://docs.gradle.org/current/userguide/signing_plugin.html#example_configure_the_gnupgsignatory
    signing.gnupg.executable=gpg
    signing.gnupg.useLegacyGpg=true
    signing.gnupg.keyName=24875D73
    signing.gnupg.passphrase=password
    But everytime when I’m running
    ./gradlew publish
    , gnupg is asking me to put the passphrase p.s: I’m using gpg legacy
    n
    • 2
    • 3
  • u

    ursus

    05/29/2021, 6:10 PM
    If got this weird issue, build fails, I run gradlew clean, build again, fails again with the same reason (some generated code is not there) I clone the project again, build the same commit, works... tldr; why is this? are there things not cleaned by clean? codegening compiler plugins?
    e
    • 2
    • 2
  • r

    Ran Magen

    05/30/2021, 6:59 PM
    Hi everyone, I’ve desperately trying for hours (not kidding) to get
    kotlinx-serialization
    to work. I’ve tried any reasonable set up I can think of, but the code fails at runtime saying:
    Serializer for class 'SpsRecordIn' is not found.
    Mark the class as @Serializable or provide the serializer explicitly.
    However:
    import kotlinx.serialization.Serializable
    ...
    @Serializable
    data class SpsRecordIn(...)
    This is in my
    build.gradle.kts
    :
    plugins {
      application
      kotlin("jvm") version "1.5.10"
      kotlin("plugin.serialization") version "1.5.10"
    }
    Can anyone help?
    l
    t
    • 3
    • 3
  • r

    rkeazor

    05/30/2021, 11:47 PM
    org.jetbrains.kotlin. is explictly adding this lib still needed when updating to kotlin 1.5
    ❓ 3
    😆 1
    l
    • 2
    • 2
  • s

    SrSouza

    05/31/2021, 5:54 PM
    Hi folks, anyone already have this issue in a CI? If so, any workaround ? https://github.com/gradle/gradle/issues/9337
    :stackoverflow: 2
    p
    • 2
    • 4
  • a

    Anthony Nixon

    06/01/2021, 12:17 PM
    Has anyone had the issue where Run through gutter refuses to use Gradle? Had everything working find on a Ubuntu install, moved to another system (PopOS) and have the below installed. Now I'm unable to run gradle
    main()
    funs except by explicitly creating a gradle task or run config. I'd like to be able to just run through the gutter icon...
    IntelliJ IDEA 2021.1.1 (Ultimate Edition)
    Build #IU-211.7142.45, built on April 30, 2021
    
    Runtime version: 11.0.10+9-b1341.41 amd64
    VM: Dynamic Code Evolution 64-Bit Server VM by JetBrains s.r.o.
    Linux 5.11.0-7614-generic
    GC: G1 Young Generation, G1 Old Generation
    Memory: 2048M
    Cores: 16
    Registry: ide.balloon.shadow.size=0
    Non-Bundled Plugins: org.jetbrains.kotlin (211-1.4.32-release-IJ7142.27)
    Kotlin: 211-1.4.32-release-IJ7142.27
    Current Desktop: pop:GNOME
    n
    • 2
    • 1
  • b

    Ben Madore

    06/02/2021, 6:29 PM
    man, it is really gd difficult to write a precompiled script plugin that uses a later version of kotlin than is bundled in gradle.
    m
    j
    +2
    • 5
    • 9
  • b

    Ben Madore

    06/02/2021, 7:13 PM
    i’m not even actually trying to write the precompiled plugins with any kotlin 1.5 features, i’m trying to automatically add kotlin 1.5 to the runtime path of apps that apply my plugins.
    c
    e
    g
    • 4
    • 6
  • b

    Benjamin Charais

    06/02/2021, 8:03 PM
    Hopefully tossing out a line here for some insight… I am making a
    java-gradle-plugin
    and I need it to have reference to some of the classes inside of the
    multiplatform
    plugin. I have the plugin working 100% if I use the
    kotlin("jvm")
    plugin, but as soon as I switch to
    multiplatform
    I get class implementation not found in the plugin, and unzipping the output jar in the gradle cache, has none of the java components, just meta data. Is anyone aware of how I can override the publishing of the multiplatform targets (atleast one is required) so that it can use the plugin output rather than the multiplatform output? I Only need access to the classes from the multiplatform plugin, no outputs from it itself (or publishing for that matter)
    t
    • 2
    • 8
  • u

    ursus

    06/03/2021, 2:13 AM
    How can I externalize this
    plugins {
      id 'com.squareup.anvil' version "${latest_version}"
    }
    to something like
    plugins {
       ext.plugins.anvil
    }
    v
    • 2
    • 4
  • m

    Mr.NiceGuy

    06/03/2021, 9:12 AM
    I'm working with custom jfrog-artifactory maven repo, when trying to fetch a dependency from it via gradle, it's not resolving the dependency dependencies, I don't think it's even searching for them, what could be the cause? I did defined my custom repo in the buildscript block and on the allprojects block
    a
    v
    +2
    • 5
    • 31
  • d

    dave08

    06/07/2021, 11:42 AM
    Is it a known problem that I have a bunch of red lines in AS with cannot find
    java.net.URI
    or other basic things like that in my build.gradle.kts? It still seems to work, just the IDE seems to not like something...
    e
    • 2
    • 3
  • p

    Piyush Kukadiya

    06/08/2021, 3:16 PM
    I am using VERSION-CATALOG FEATURE but while declaring dependency autocomplete feature is not working. Is this expected behavior?
    b
    v
    a
    • 4
    • 19
  • e

    efemoney

    06/10/2021, 10:18 AM
    What is the best way to specify module wide opt-in requirements in gradle scripts for it to be applied properly in Android Studio. This was broken before (https://kotlinlang.slack.com/archives/C0922A726/p1560260538220700), fixed at some point and, unfortunately, broken again now (for me). I have tried combinations of • AS [4.2.1, ArcticFox-beta03, Bumblebee-alpha02] • AGP [4.2.1, 7.0-beta03, 7.1-alpha02] • KGP [1.5.10], cant downgrade to 1.4.30 Builds fine from command line so its an issue of importing the model into IDE.
    s
    i
    a
    • 4
    • 10
  • r

    rkeazor

    06/10/2021, 1:26 PM
    So I have transitive dependences of older versions of kotlin stdlib leaking into my project. Whats the best way to handle this? Is there a way to completely exclude it from my project?
    e
    • 2
    • 4
  • n

    nuhkoca

    06/10/2021, 4:14 PM
    I have a
    precompiled script
    for child
    Gradle
    scripts. How can I add another plugin in such file?
    apply<LibraryCommonPlugin>()
    
    configure<BaseExtension> {
    
        defaultConfig {
            ...
        }
    }
    What I’ve tried; • to add
    plugins { kotlin("android") }
    on top of file but didn’t work • to configure like
    configure<PluginDependenciesSpecScope> { kotlin("android") }
    on top of file but didn’t work What do I need to do to get it to working?
    v
    • 2
    • 16
  • m

    MSC

    06/10/2021, 11:34 PM
    Is it possible to add a conditional statement when applying a plugin? e.g.:
    id 'com.plugins.my-plugin' version '1.0.0' apply ifEnvVarPresent
    I want to apply this plugin only if an particular env var is present
    t
    • 2
    • 2
  • c

    Christian Dräger

    06/14/2021, 9:27 AM
    are there any good sources on how to write a custom gradle plugin in kotlin? in nearly all of my prjects i am using a bunch of different gradle plugins and corresponding configurations over and over again. now i am curious if it wouldn’t make sense to bundle all this in one opinionated plugin.
    b
    c
    a
    • 4
    • 4
  • l

    Law Gimenez

    06/15/2021, 3:05 AM
    Hi guys, updated to
    classpath 'com.android.tools.build:gradle:7.1.0-alpha02'
    and this error just won’t go away. I’m trying to compile my project to Arctic Fox and it recommended me to upgrade to build tools version > 7.0. Thanks for the help!
    :not-kotlin: 2
    g
    p
    • 3
    • 6
  • m

    mazorius

    06/15/2021, 3:41 PM
    Hi 👋🏼 , as from https://docs.gradle.org/7.1/release-notes.html#easier-source-set-configuration-in-the-kotlin-dsl I see no Kotlin source set support. Is this planned? Because I am using 
    kotlin-dsl
     plugin and have no 
    sourceSets.register("…").kotlin {}
    I already asked that in Gradle and they give me the following input:
    The Groovy plugin (and the other supported ones) now add the source directory set as extension to the source set like
    sourceSet.getExtensions().add(GroovySourceDirectorySet.class, "groovy", groovySourceSet.getGroovy());
    Due to that the accessor generation for Kotlin DSL build scripts and precompiled plugins can generate the 
    groovy
     accessor with which you can configure the source directory set.
    So to support Kotlin, the Kotlin Gradle plugin should do the same and add an according extension.
    👍🏼 1
    👍 2
    j
    v
    • 3
    • 9
  • b

    Ben Madore

    06/15/2021, 7:52 PM
    i’m really struggling to get the versions of kotlin aligned on my project. i have:
    dependencies {
        implementation(enforcedPlatform("org.jetbrains.kotlin:kotlin-bom:1.5.10"))
        ...
    }
    but when i run
    gradle dependencies
    i see all sorts of nonsense like:
    +--- org.jetbrains.kotlin:kotlin-reflect:1.4.31 (*)
    +--- org.jetbrains.kotlin:kotlin-bom:1.5.10
    |    +--- org.jetbrains.kotlin:kotlin-stdlib:1.5.10 -> 1.4.31 (c)
    |    +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.10 -> 1.5.0 (c)
    |    +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.5.10 -> 1.5.0 (c)
    |    +--- org.jetbrains.kotlin:kotlin-reflect:1.5.10 -> 1.4.31 (c)
    |    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.10 -> 1.5.0 (c)
    any suggestions to make this sane. one would think the BOM would be the appropriate approach.
    e
    t
    +2
    • 5
    • 7
  • d

    dave08

    06/16/2021, 3:25 PM
    Not sure what might be causing the problem... I have a dependency on two modules in my build.gradle.kts, and only the first one of the two seems to get loaded... if I change the order it's always the first one, the second one is ignored.
    implementation(project(":legacy:domain"))
        implementation(project(":domain"))
    v
    • 2
    • 8
  • e

    efemoney

    06/19/2021, 10:30 AM
    👀
    org.jetbrains.kotlin.multiplatform.pm20
    Noticed this new plugin and wondering what it’s for? Can anyone from [JB] please enlighten me (Its okay to mention that its for future features or unsupported)
    j
    l
    • 3
    • 5
  • g

    Gavin Ray

    06/20/2021, 6:59 PM
    Hello all, I'm new to the JVM ecosystem and trying to use Quarkus + their Kotlin plugin with GraalVM
    21.2.0-dev JDK16
    Quarkus has Kotlin version set to
    "1.4.32"
    and haven't yet merged their PR for upgrading to
    1.5
    I'm not sure what this error means -- but what is happening is that on first-load, my app is fine. Then when I save and the in-process recompilation happens, it throws this error:
    java.lang.RuntimeException: Unable to invoke Kotlin compiler. java.lang.ExceptionInInitializerError
    	at com.intellij.pom.java.LanguageLevel.<clinit>(LanguageLevel.java:25)
    	at com.intellij.core.CoreLanguageLevelProjectExtension.<init>(CoreLanguageLevelProjectExtension.java:26)
    	at com.intellij.core.JavaCoreProjectEnvironment.<init>(JavaCoreProjectEnvironment.java:42)
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreProjectEnvironment.<init>(KotlinCoreProjectEnvironment.kt:26)
    Resulted in: java.lang.reflect.InaccessibleObjectException: Unable to make protected void java.util.ResourceBundle.setParent(java.util.ResourceBundle) accessible: module java.base does not "opens java.util" to unnamed module @47d9a273
    	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357)
    	... 23 more
    	at io.quarkus.kotlin.deployment.KotlinCompilationProvider.compile(KotlinCompilationProvider.java:81)
    I have googled for some hours, and tried the following (
    kotlinOptions.jvmTarget
    =
    11
    )
    tasks.withType<JavaCompile> {
        options.fork(mapOf(Pair("jvmArgs", listOf("--add-opens", "java.base/java.util=ALL-UNNAMED"))))
    }
    org.gradle.jvmargs=--illegal-access=permit -Dkotlin.daemon.jvm.options=--illegal-access=permit
    Is there any way to make this work 🤔
    g
    • 2
    • 1
  • s

    spierce7

    06/21/2021, 1:48 PM
    If I wanted to start a server and then run tests against it for CI, all in the same Gradle command, would that be possible?
    m
    c
    v
    • 4
    • 11
  • s

    spierce7

    06/22/2021, 3:25 AM
    So the Shared Build Service seems like what I need, but what would be the best way to execute a task from it? I basically need to 1. Call a task in parallel for the Build Service (to run the
    run
    task of the server), and then kill the running task when the service is closed. 2. Call a command line command from the root project:
    ./gradlew :server:run
    , and then kill it when the service is closed. Which is the best approach? I’m not even sure if #1 is possible.
    g
    v
    • 3
    • 9
  • t

    Tim Schraepen

    06/22/2021, 9:53 PM
    Hi all, long-time lurker, first-time poster. I’m trying to use SpringSecurity’s kotlin DSL to configure my SecurityConfig for my hobby project. Running on Gradle 6.8. Using a clean architecture style multi-module set-up. Where I made shared dependencies (i.e. spring-boot, kotlin) available using a
    buildSrc
    module, with the
    kotlin-dsl
    convention plugin (as is suggested as a best practice according to the Gradle Docs, but I’ve had quite a bit of issues with these convention plugin scripts not compiling in IntelliJ etc). I’m using IntelliJ as my IDE, but a normal
    gradlew clean build
    fails on the same compilation error.
    e: .../SecurityConfig.kt: (15, 9): Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: 
    public operator fun <T, R> DeepRecursiveFunction<TypeVariable(T), TypeVariable(R)>.invoke(value: TypeVariable(T)): TypeVariable(R) defined in kotlin
    The
    http: HttpSecurity
    function argument to my
    WebSecurityConfigurerAdapter
    impl doesn’t seem to support a configuration lambda. Any help is appreciated. 🙏
    k
    • 2
    • 6
  • t

    Timo Gruen

    06/23/2021, 9:37 AM
    Hi everyone, is there any way to invoke
    MyClass::class.qualifiedName
    at compile time? As the gradle plugin might not have the dependency at runtime, its still necessary to set a property correctly
    e
    • 2
    • 1
Powered by Linen
Title
t

Timo Gruen

06/23/2021, 9:37 AM
Hi everyone, is there any way to invoke
MyClass::class.qualifiedName
at compile time? As the gradle plugin might not have the dependency at runtime, its still necessary to set a property correctly
e

ephemient

06/23/2021, 9:43 PM
probably needs to be a new intrinsic un the compiler. https://youtrack.jetbrains.com/issue/KT-34534
View count: 2