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

    andylamax

    07/07/2022, 1:30 PM
    x - posting here because I think it is relevant. Is any one here using gradle composite build as dependency substitutors for kotlin multiplatform projects with success? Any workaround is welcomed
    s
    m
    • 3
    • 23
  • g

    Grégory Lureau

    07/08/2022, 9:51 AM
    Hello! I'm trying to define a gradle convention plugin with parameters on a KMP project, and I want to be able to enable platforms on demand, something like:
    plugins {
        id("com.deezer.kmp.convention-plugin") version "0.1.0"
    }
    kmpp {
        platformJvm.set(true)
    }
    but I've a couple of issues: • when I use a Property (from an abstract Extension), the value is accessible only if I use
    afterEvaluate
    • (I think) the multiplatform plugin expects to be configured in the configuration pass , and what I do in the afterEvaluate is too late Is it possible to listen Property changes so that I can apply multiplatform plugin when the value is set? (I suppose it's still the configuration phase) Any help or idea is much appreciated.
    j
    m
    • 3
    • 30
  • e

    eygraber

    07/12/2022, 7:02 PM
    If I add a
    js
    target to my KMP build, I get the following error:
    Build was configured to prefer settings repositories over project repositories
    because I have:
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    in my
    settings.gradle.kts
    . I remember this being reported somewhere (Gradle issues, youtrack, etc...), but I can't find it now. Anyone know where it is?
    🤔 1
    t
    • 2
    • 8
  • e

    eygraber

    07/12/2022, 9:01 PM
    Is there a property to set the output file for
    assembleXCFramework
    task without having to map the
    outputFile
    in a separate copy task?
    t
    • 2
    • 2
  • r

    Ricardo C.

    07/13/2022, 1:43 PM
    Hey! We currently have a chunk of our app on a different repository as a library. App repository is modularized but the library one isn’t. The usage of library is spread through almost all app modules. Since we’re quickly iterating on the library, each time we publish a new version, this implies an almost full rebuild of the app. We’re losing a ton of time on this process. So we’re looking to also modularize the library repository and only depend on the appropriate smaller artifacts on the app. This would also imply that each smaller artifact has its own version number instead of having a general one for the whole library, so it doesn’t invalidate the build cache on the app. But this would make it a huge pain to manage and publish. This library is for internal usage only, so we can manage how we want it as long as it stays on a different repository. Do you folks have any suggestion on how to better handle this? Thank you!
    j
    f
    • 3
    • 4
  • j

    Javier

    07/13/2022, 3:31 PM
    If I add a Kotlin library with no version to the dependencies, for example
    kotlin-test
    , should it get the same version than the KGP version in the classpath? Or the version can depends on other libraries adding
    kotlin-test
    with a higher/lower version?
    m
    • 2
    • 3
  • m

    mkrussel

    07/13/2022, 4:21 PM
    I'm trying to upgrade Kotlin to 1.7.0 and I'm no longer able to get my
    buildSrc
    project to configure. It's breaking on applying the
    kotlin-dsl
    plugin.
    An exception occurred applying plugin request [id: 'org.gradle.kotlin.kotlin-dsl', version: '2.3.3']
    > Failed to apply plugin class 'org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper'.
       > Could not create an instance of type org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension.
          > Companion
    Gradle version: 7.3.3 Kotlin version: 1.7.0 kotlin-dsl version: 2.2 and 2.3.3
    m
    m
    i
    • 4
    • 69
  • k

    Ky

    07/15/2022, 4:53 PM
    Hey Guys, I'm having trouble running Junit tests in the buildSrc test directory. The tests are not even being recognized, there is no run button next to method annotated with @Test. I've been searching for samples that display setting up simple Unit tests in the buildSrc directory. I've been following gradles documentation on this but I'm at a point with no information output that gives me a idea of what i'm doing wrong Any suggestions?
    c
    g
    • 3
    • 11
  • j

    Jeff Lockhart

    07/20/2022, 12:23 AM
    I'm looking for a way to modify a build task, but only when running tests. Specifically, I need to add some additional header definitions in a Kotlin/Native .def file. I have this working, but I only want those definitions to be added when running tests, as they're not needed in production code and I don't want them to leak into the public API. Is there a good way to accomplish this with gradle? Given my gradle task dependency trees, I want to modify (or insert a task after)
    generateDefCocoaPodsLib
    when it's executed from the
    iosX64Test
    task:
    iosX64Test
    +--- ...
         +--- generateDefCocoaPodsLib
         |    +--- ...
         +--- ...
    But I don't want to modify this task, or append the additional definitions when it's executed from any other task tree:
    assemble
    +--- ...
    |    +--- generateDefCocoaPodsLib
    |    |    +--- ...
    |    +--- ...
    +--- ...
    v
    • 2
    • 7
  • s

    sreich

    07/21/2022, 4:08 PM
    is there any kind of interoperability b/w gradle (kotlin script) and maven? particularly if i have a parent library that adds phases and goals and such...that needs to be moved to gradle first before I move the child project, right?
    d
    • 2
    • 3
  • s

    sreich

    07/21/2022, 4:10 PM
    also, is gradle script kotlin considered stable and the preferred mechanism? i have seen it promoted more, but there's definitely a lot of groovy still floating around and I have not seen many people actually using it. The performance issues the gradle docs talk about don't sound too great, particularly on transient CICD, anyone happen to have info on how bad it is though?
    v
    • 2
    • 4
  • u

    ulrikguenther

    07/22/2022, 10:14 AM
    hi everyone! i have a question relating to intellij and gradle integration. i have some examples in my project that are run via a main() routine (no unit test), intellij registers them as type "Kotlin" in the run configurations. i need to set some VM args for them, and would like to do directly in the gradle build file. is that possible? so far i have succeeded to create gradle tasks for all the examples, but intellij still likes to use its own run type it seems. any ideas? and sorry if this is the wrong place, i was a bit torn between posting this here or in #intellij
    v
    • 2
    • 2
  • s

    sreich

    07/22/2022, 3:27 PM
    how do people handle versioning in gradle in CICD? i saw somebody throwing around the idea of not having the version embedded in a file but rather a part of the CICD system, like as a variable that it pulls in. Which I don't think would even work? What are your thoughts, what are some standards?
    b
    j
    w
    • 4
    • 24
  • o

    Ola Adolfsson

    07/24/2022, 8:30 AM
    Hi! I’m trying to use kotlin.serialiazation in a gradle task in order to read a json file, modify it and save the file again. Open for other suggestions 🙂. It was working with groovy using JsonSluper. Is that possible? Existing and working code in Groovy.
    def file = new File(path)
    def data = new JsonSlurper().parse(file)
    data.types = "my new value"
    def json = JsonOutput.prettyPrint(JsonOutput.toJson(data))
    :yes: 2
    c
    • 2
    • 3
  • s

    Slackbot

    07/25/2022, 5:10 PM
    This message was deleted.
    c
    v
    • 3
    • 4
  • e

    Emirhan Emmez

    07/26/2022, 7:09 AM
    message has been deleted
    v
    • 2
    • 2
  • g

    Guilherme Delgado

    07/27/2022, 10:03 PM
    Hello, What are the advantages and disadvantages from declaring the versions catalog in a .toml file vs “in-gradle”:
    [versions]
    some = "123"
    
    [libraries]
    my-lib = { group = "com.mycompany", name="mylib", version.ref="some" }
    +
    dependencyResolutionManagement {
        versionCatalogs {
            create("libs") {
                from(files("../gradle/libs.versions.toml"))
            }
        }
    }
    versus:
    dependencyResolutionManagement {
        versionCatalogs {
            create("libs") {
                library("my-lib", "com.mycompany", "mylib").versionRef("123")
            }
        }
    }
    Personally I prefer separating in a .toml file and the “simpler” syntax, but other than that I couldn’t figure it out by reading this doc. Thanks!
    m
    m
    +2
    • 5
    • 7
  • s

    Slackbot

    07/28/2022, 12:06 PM
    This message was deleted.
  • m

    mikehearn

    07/28/2022, 1:52 PM
    Is anyone else suddenly experiencing failures like
    Unable to find a variant of org.jetbrains.kotlin:kotlin-test:1.6.10
    ? This just started now so I'm wondering if someone accidentally yanked an artifact from some repository. Not sure what the best channel to ask about this is.
    t
    m
    +4
    • 7
    • 18
  • c

    charleskorn

    07/25/2022, 6:46 AM
    Has anyone seen an error like this before? This only occurs on GitHub Actions - it works fine locally. (sample failing build: https://github.com/kotest/kotest/runs/7494593098?check_suite_focus=true#step:5:53)
    Could not determine the dependencies of task ':kotest-framework:kotest-framework-multiplatform-plugin-gradle:test'.
    > Could not resolve all task dependencies for configuration ':kotest-framework:kotest-framework-multiplatform-plugin-gradle:testRuntimeClasspath'.
       > Could not resolve project :kotest-assertions:kotest-assertions-core.
         Required by:
             project :kotest-framework:kotest-framework-multiplatform-plugin-gradle
          > The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm'. However we cannot choose between the following variants of project :kotest-assertions:kotest-assertions-core:
              - jvmRuntimeElements
              - runtimeElements
    (full error in thread)
    v
    e
    • 3
    • 9
  • t

    Tianyu Zhu

    08/01/2022, 11:23 PM
    Hi! I'm using the venerable jengelman.shadow plugin to create a fat jar containing a bunch of kotlin code I wrote. When I use this fat jar as a dependency in subsequent kotlin projects the code compiles fine but IntelliJ doesn't recognize any of the kotlin code in the fat jar! 1. Is this related the fact that my fat jar does not merge the
    META-INF/*.kotlin_module
    files together? 2. If so, is there a gradle plugin that will help me with that? 3. Otherwise, why doesn't IntelliJ understand kotlin code that's been put into fat jars?
    m
    t
    • 3
    • 17
  • a

    andylamax

    08/08/2022, 2:06 AM
    I have a custom gradle that I'd like to run before executing any KMP task (i.e. compileKotlinJvm, compileKotlinJs, compileKotlinLinuxX64, e.t.c) is there a common task that all of these platform specific task do depend on that I can hook my custom task there?
    e
    v
    • 3
    • 10
  • b

    Brandon Martin

    08/08/2022, 9:13 PM
    I have no idea if this is the right channel. I am brand new to Kotlin. I am mucking around in an existing Kotlin/Quarkus app. I am trying to build a docker image with a jar in it so using this. When I build the project
    ./gradlew build -x test
    I don't see a
    build/qaurkus-app
    folder at all.
    k
    • 2
    • 1
  • a

    Adam S

    08/09/2022, 5:53 PM
    I'm trying to figure out how to recreate a MockK issue that only happens with Java 17. I've got a unit test, that fails when I manually set
    kotlin.jvmToolchain.languageVersion.set(JavaLanguageVersion.of(17))
    . It's a bit frustrating because in CI/CD it tests using JDK 11/17/18 - but they all pass because Gradle sets the tests to use the same as the main code - JDK 11. But I would like to automate this, so I don't have to manually set the version for test code. How can I set the Java language level to 11/17/18 based on a Gradle property for compile test code in
    src/jvmTest
    ? I'm using Kotlin Multiplatform 1.7.10, Gradle 7.5.1.
  • e

    eygraber

    08/09/2022, 7:18 PM
    Is it possible to clear out an opt in I set using
    languageSettings.optIn
    ?
    e
    • 2
    • 1
  • h

    hfhbd

    08/10/2022, 4:54 AM
    How can you apply the serialization plugin in the buildSrc? This results into an error:
    plugins {
        `kotlin-dsl`
        kotlin("plugin.serialization") version "1.7.0"
    }
    
    repositories {
        gradlePluginPortal()
        mavenCentral()
    }
    e
    f
    +2
    • 5
    • 9
  • j

    Jakob K

    08/13/2022, 10:38 PM
    Is it possible to use a library which itself used
    -Xcontext-receivers
    ? I know that it leads to the project being compiled as a pre-release binary, but is it really not possible to use that libraries pre-release binary in another project (which will also be compiled to a pre-release binary then)?
    v
    • 2
    • 1
  • d

    darkmoon_uk

    08/15/2022, 3:29 AM
    I want to programmatically pick a version from a Version Catalog from within the
    plugins
    block, but it seems like Gradles API is juuuust about designed to make this impossible!? Is there some way that I'm missing? • A function to choose a string key for the version can be made available from
    buildSrc
    ✅ • The type-unsafe accessors needed to select a version by key, cannot be accessed from within
    plugins {}
    because a handle on
    project
    is not available. : •
    libs
    can be accessed through (apparently) some Gradle 'black magic' but,
    libs
    does not re-expose the type-unsafe accessor either from the generated
    LibrariesForLibs
    type or its
    AbstractExternalDependencyFactory
    supertype.
    v
    • 2
    • 1
  • d

    dvdandroid

    08/15/2022, 7:16 AM
    i'm using gradle version catalogs and to remove the warning about libs accessors in build.gradle.kts i use
    @Suppress("DSL_SCOPE_VIOLATION")
    (issue KTIJ-19369), but after sync project it errors with:
    Line 1: @Suppress("DSL_SCOPE_VIOLATION")
                                              ^ Expecting an expression
    ScriptCompilationException(errors=[ScriptCompilationError(message=Expecting an expression, location=C:\Users\me\.gradle\.tmp\gradle-kotlin-dsl-2485107686268774832.tmp\build.gradle.kts (1:33))])
    how to fix this issue? cannot always reproduce
    v
    c
    • 3
    • 7
  • d

    dvdandroid

    08/15/2022, 9:50 AM
    is there an equivalent workaround for
    projects
    accessors (from precompiled scripts/plugins) instead of
    libs
    like: https://github.com/gradle/gradle/issues/15383#issuecomment-779893192 ? i tried
    implementation(files(projects.javaClass.superclass.protectionDomain.codeSource.location))
    but it does not take the
    rootProject
    org.gradle.accessors.dm.RootProjectAccessor
    (obviously)
    v
    • 2
    • 1
Powered by Linen
Title
d

dvdandroid

08/15/2022, 9:50 AM
is there an equivalent workaround for
projects
accessors (from precompiled scripts/plugins) instead of
libs
like: https://github.com/gradle/gradle/issues/15383#issuecomment-779893192 ? i tried
implementation(files(projects.javaClass.superclass.protectionDomain.codeSource.location))
but it does not take the
rootProject
org.gradle.accessors.dm.RootProjectAccessor
(obviously)
v

Vampire

08/19/2022, 9:35 AM
An important part of my hack-around is, that the build logic project has the same accessors as the main project. So a similar one cannot be fine with the projects
View count: 26