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

    iamthevoid

    08/02/2021, 10:58 AM
    Looks like my build src rebuilds on each build (even if i am change nothing inside) and leads whole rebuild of project. Where can i find cause? At the time wrapper is
    distributionUrl=https\:<//services.gradle.org/distributions/gradle-7.0.2-bin.zip>
    , and AGP version is
    7.0.0
    t
    n
    v
    • 4
    • 12
  • t

    Tomasz Krakowiak

    08/02/2021, 11:37 AM
    message has been deleted
    t
    v
    i
    • 4
    • 19
  • j

    jeggy

    08/02/2021, 1:02 PM
    Sorry for negative question 😛 But I again and again have wasted a lot of hours trying to configure Gradle to do (in my mind) basic stuff. I have a Kotlin jvm Project using Kotlin Gradle Script. I would love to have tests configured and report standard xml information about success/failures/ignored and get testcoverage, which then I can pass on to my CI environment. Does anyone know if there exists a straight forward solution to this? I'm fully fine with replacing everything that I currently have with jacoco with something else if that's the prefered way of doing things.
    v
    • 2
    • 8
  • k

    kevindmoore

    08/03/2021, 8:01 PM
    Anyone having any gradle locking issues with Android Studio? Both my work machine and my home machine have been getting the same errors. I can delete the .lock file in the cache to get it to run, but it is a pain
    c
    n
    • 3
    • 5
  • i

    iamthevoid

    08/04/2021, 12:20 PM
    Could anybody explain to me, where are from exceptions like that ? when i run or assemble project build is successful, but when i run
    ./gradlew build
    if fails
    a
    v
    • 3
    • 3
  • p

    PHondogo

    08/05/2021, 8:09 AM
    Hello! I have kotlin multiplatform project with jvm target with 'androidx.appcompat:appcompat' as one of dependencies. The problem is that in my code I can't see elements of this dependency (for example androidx.appcompat.app.AppCompatActivity - unresolved reference). Other dependenies works well (for example 'com.google.android:android'). P.S. if change target type to android it is resolving. But I need exactly jvm target not android.
    t
    • 2
    • 1
  • i

    Iaroslav Postovalov

    08/05/2021, 10:32 AM
    Hello! Is there any specific reason for absence dependency builder functions
    kotlinx
    to add dependencies in group
    org.jetbrains.kotlinx
    ? Possible use cases: 1. Adding dependencies by github.com/Kotlin
    dependencies {
      implementation(kotlinx("coroutines-core", "1.5.1"))
    }
    2. Adding plugins by github.com/Kotlin
    plugins {
      kotlinx("benchmark") version "0.3.1"
    }
    👍 3
    🤔 3
    t
    g
    v
    • 4
    • 5
  • m

    mattinger

    08/05/2021, 6:23 PM
    Have a question about compose in libraries. If i build a library using AGP 7 and compose, can i even bring that library into an app built with AGP 4? This is assuming that all the compose usage is in standalone fragments and activities, and the kotlin and jetpack libraries are compatible.
    v
    • 2
    • 1
  • u

    ursus

    08/06/2021, 12:01 AM
    Anyone seen this warning with gradle 7?
    Execution optimizations have been disabled for task ':radost:user:discount:impl:kspDebugKotlin' to ensure correctness due to the following reasons:
      - Gradle detected a problem with the following location: 'C:\Users\ursus\AndroidStudioProjects\mo2-android\radost\user\discount\impl\build\generated\sqldelight\code\AppDatabase\debug'. Reason: Task ':radost:user:discount:impl:kspDebugKotlin' uses this output of task ':radost:user:discount:impl:generateDebugAppDatabaseInterface' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to <https://docs.gradle.org/7.1.1/userguide/validation_problems.html#implicit_dependency> for more details about this problem.
    m
    v
    • 3
    • 25
  • t

    Tomas Kormanak

    08/06/2021, 10:11 AM
    Hi, does anyone using gradle to build npm packages?
    i
    • 2
    • 2
  • c

    Christopher Elías

    08/06/2021, 6:06 PM
    Hi, I'm getting this problem when building from CI gradle 7.0.0:
    A problem occurred evaluating script.
    > Failed to apply plugin 'com.android.internal.library'.
       > The option 'android.enableR8' is deprecated.
         It was removed in version 7.0 of the Android Gradle plugin.
    Should I just remove it from gradle.properties? how to enable r8 now?
    m
    h
    j
    • 4
    • 4
  • f

    FunkyMuse

    08/07/2021, 12:17 PM
    Hey guys, After updating to compose 1.0.0 and 1.0.1 later on, I can't assemble an apk release, Gradle takes forever, longest running task was 8hs and it ran out of memory 7.0.0 ag plugin, anyone suffering from the same issue?
    m
    • 2
    • 3
  • t

    turansky

    08/07/2021, 11:37 PM
    Is there any standard source folder for generated code?
    src/generated/kotlin
    ?
    ✅ 1
    m
    v
    b
    • 4
    • 8
  • r

    robstoll

    08/08/2021, 12:31 PM
    I would like to move helper functions which I use often across projects into an own artifact. Yet, I cannot find the jar which includes e.g. KotlinSettingsScript which is in package org.gradle.kotlin.dsl. Is this somehow available? it looks like it is incorporated into gradle itself. Any idea? basically this but as jar 🙂 https://gradle.github.io/kotlin-dsl-docs/api/org.gradle.kotlin.dsl/index.html
    v
    • 2
    • 4
  • j

    Jason Ankers

    08/09/2021, 3:34 AM
    Trying to read the proguard manual and they use the term “_a priori”_. Why do build tools make their documentation needlessly more complicated?
    z
    p
    +7
    • 10
    • 26
  • w

    William Reed

    08/09/2021, 1:43 PM
    any suggestions for plugins to detect unused dependencies in a kotlin DSL android project? I have seen https://github.com/Faire/gradle-kotlin-buildozer but I get an error about needing java 16
    Incompatible because this component declares an API of a component compatible with Java 16 and the consumer needed a runtime of a component compatible with Java 11
    any other suggestions to try?
    m
    v
    • 3
    • 15
  • r

    robstoll

    08/10/2021, 11:32 AM
    I hit the following issue: https://stackoverflow.com/questions/67448034/module-was-compiled-with-an-incompatible-version-of-kotlin-the-binary-version I depend on a kotlin library (which I am the author of) which was built with kotiln 1.5.21 and gradle 7.1.1 in a project which uses Kotlin 1.3.72 and gradle 6.7 I guess the problem is gradle and not Kotlin (since updating gradle to 7.1.1 works). Is there a way to workaround this? e.g. set the metadata version somehow to 1.1.5 in the library? I don't want that users of my library are forced to update gradle if they use my library
    v
    • 2
    • 15
  • a

    Aaron Todd

    08/10/2021, 2:16 PM
    The docs on variant matching call out
    guava-jre
    and
    guava-android
    as an example where using attributes would be a better solution. If you wanted to do something like this (publish a regular jvm version and an android specific version of a library) what are the appropriate attributes to set? It vaguely mentions
    org.gradle.jvm.version
    but I'm not seeing any properties specific to android...
    v
    j
    • 3
    • 20
  • r

    robstoll

    08/11/2021, 3:26 PM
    how can you define dependency constraints in a MPP project? I basically have the same question as this guy: https://discuss.kotlinlang.org/t/dependency-constraints-in-gradle-kotlin-multiplatform-plugin/17720
    j
    • 2
    • 2
  • s

    suresh

    08/15/2021, 7:12 PM
    Has anybody tried
    kotlinDaemonJvmArgs
    to open modules on JDK16+ ? I have tried all different options (gradle.properties and in dsl) , nothing seems to work.
    v
    • 2
    • 8
  • a

    Alexandre Brown

    08/16/2021, 11:33 AM
    Hello, we're using Gradle 7.1 and were wondering is there any optimization done for multi-modules projects by default? For instance, if Module A depends on Module B and we make a change to Module A, then would Gradle only recompile Module A? Or should we make sure to enable incremental build (which seems to be at the class level)? Thanks
    d
    • 2
    • 2
  • j

    Justin Yue

    08/18/2021, 5:58 AM
    I'm trying to run a jar file built from a kotlin spring boot project, but I'm getting a
    java.lang.ClassNotFoundException
    . I believe the issue has to do with my build.gradle.kts file, which I'll put in a thread below.
    v
    k
    • 3
    • 12
  • j

    jean

    08/19/2021, 8:29 AM
    I’m trying to add two different custom maven repo like so :
    repositories {
        google()
        mavenCentral()
        maven {
            url = uri("<https://maven.pkg.jetbrains.space/org1/p/dep1/maven>")
            name = "name1"
            credentials(PasswordCredentials::class)
        }
        maven {
            url = uri("<https://maven.pkg.jetbrains.space/org2/p/dep2/maven>")
            name = "name2"
            credentials(PasswordCredentials::class)
        }
    }
    Gradle can resolve one at a time, but if I add both and build, it fails on the second one. Am I missing something here?
    v
    • 2
    • 2
  • j

    JinYong Kim

    08/19/2021, 9:48 AM
    Hi, I have question about dependency substitution. My project is logging library for multiplatform with multi-module project. Recenty, I rewrite project to divide sub-project each dependent library. I require to use different dependency in local and publication between sub-projects. (e.g In local, implementation(project(":ktor")). But In publication, implementation("kr.jadekim:j-logger-ktor:2.0.0-rc1")) So, i try to solve this problem using dependency substitution in gradle. It correctly work in IntelliJ IDE, but fail to build with 'Unresolve error'. How to solve this problem? Dependency Substitution Definition (gradle.build.kts in root project) https://github.com/jdekim43/j-logger/blob/662882bfe47ba2d19be904d030403ab154af824e/build.gradle.kts#L28
    dependencySubstitution {
    //                substitute(module("$group:${rootProject.name}")).using(project(":"))
    
                    all {
                        (requested as? ModuleComponentSelector)?.let {
                            if (it.group != rootProject.group) {
                                return@let
                            }
    
                            val targetProject = if (it.module == rootProject.name) {
                                rootProject
                            } else {
                                findProject(":${it.module}")
                            } ?: return@let
    
                            useTarget(targetProject)
                        }
                    }
                }
    *Dependency Definition (build.gr*adle.kts in sub-project) https://github.com/jdekim43/j-logger/blob/662882bfe47ba2d19be904d030403ab154af824e/coroutine/build.gradle.kts#L24
    implementation("$group:${rootProject.name}:$version")
    // It dependent root project
    v
    • 2
    • 8
  • b

    Ben Madore

    08/20/2021, 3:13 PM
    [INFO] [org.gradle.api.Task] i: starting the daemon as: /Users/ben.madore/dotfiles/sdkman/.sdkman/candidates/java/11.0.11.hs-adpt/bin/java -cp /Users/ben.madore/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-compiler-embeddable/1.5.21/40ddbcae9ff100473f95370c2d589ba3fc48eed5/kotlin-compiler-embeddable-1.5.21.jar:/Users/ben.madore/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-reflect/1.5.21/802f1f39735ae1eb2b75714a40fa19bb2e687e96/kotlin-reflect-1.5.21.jar:/Users/ben.madore/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.21/2f537cad7e9eeb9da73738c8812e1e4cf9b62e4e/kotlin-stdlib-1.5.21.jar:/Users/ben.madore/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-script-runtime/1.5.21/96d49e89873fde985750af354b6eabb60cfa999b/kotlin-script-runtime-1.5.21.jar:/Users/ben.madore/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-daemon-embeddable/1.5.21/17255809e66a940dfdf6289bccbdfb5a09f3145/kotlin-daemon-embeddable-1.5.21.jar:/Users/ben.madore/.gradle/caches/modules-2/files-2.1/org.jetbrains.intellij.deps/trove4j/1.0.20181211/216c2e14b070f334479d800987affe4054cd563f/trove4j-1.0.20181211.jar:/Users/ben.madore/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar:/Users/ben.madore/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.5.21/cc8bf3586fd2ebcf234058b9440bb406e62dfacb/kotlin-stdlib-common-1.5.21.jar -Djava.awt.headless=true -Djava.rmi.server.hostname=127.0.0.1 -Xmx8g -XX:MaxMetaspaceSize=512m -Dkotlin.environment.keepalive -ea org.jetbrains.kotlin.daemon.KotlinCompileDaemon --daemon-runFilesPath /Users/ben.madore/Library/Application Support/kotlin/daemon --daemon-autoshutdownIdleSeconds=7200 --daemon-compilerClasspath /Users/ben.madore/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-compiler-embeddable/1.5.21/40ddbcae9ff100473f95370c2d589ba3fc48eed5/kotlin-compiler-embeddable-1.5.21.jar:/Users/ben.madore/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-reflect/1.5.21/802f1f39735ae1eb2b75714a40fa19bb2e687e96/kotlin-reflect-1.5.21.jar:/Users/ben.madore/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.21/2f537cad7e9eeb9da73738c8812e1e4cf9b62e4e/kotlin-stdlib-1.5.21.jar:/Users/ben.madore/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-script-runtime/1.5.21/96d49e89873fde985750af354b6eabb60cfa999b/kotlin-script-runtime-1.5.21.jar:/Users/ben.madore/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-daemon-embeddable/1.5.21/17255809e66a940dfdf6289bccbdfb5a09f3145/kotlin-daemon-embeddable-1.5.21.jar:/Users/ben.madore/.gradle/caches/modules-2/files-2.1/org.jetbrains.intellij.deps/trove4j/1.0.20181211/216c2e14b070f334479d800987affe4054cd563f/trove4j-1.0.20181211.jar:/Users/ben.madore/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar:/Users/ben.madore/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.5.21/cc8bf3586fd2ebcf234058b9440bb406e62dfacb/kotlin-stdlib-common-1.5.21.jar
    
    [INFO] [org.gradle.api.Task] i: Received the message signalling that the daemon is ready
    [INFO] [org.gradle.api.Task] i: new daemon started, trying to find it
    [INFO] [org.gradle.api.Task] i: found daemon on port 17510 (17 ms old), trying to connect
    [INFO] [org.gradle.api.Task] i: cannot connect to registry: org.jetbrains.kotlin.daemon.common.LoopbackNetworkInterface$ClientLoopbackSocketFactory; local class incompatible: stream classdesc serialVersionUID = -6143155864063642633, local class serialVersionUID = 2267640376242766426
    
    [INFO] [org.gradle.api.Task] i: found fresh run file '/Users/ben.madore/Library/Application Support/kotlin/daemon/kotlin-daemon.2021-08-20T15-08-02.424Z.debbf6008f685b009aa37af9e022bc5e.17510.run' (17 ms old), but no daemon, ignoring it
    which then repeats a few times before pringing the fallback message
    :thread-please: 1
    v
    a
    • 3
    • 6
  • z

    Zac Sweers

    08/20/2021, 4:08 PM
    check your jvm args, especially if you upgraded to Gradle 7.2 recently
    b
    • 2
    • 2
  • e

    eygraber

    08/25/2021, 11:59 PM
    Xposting from the Gradle Slack because I'm not sure whether it's a Gradle or Kotlin solution I'd like add "-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi" to the compiler args for every module I have that uses coroutines in a precompiled script plugin, but I don't want to manually list out all of the modules, nor do I want to do it specifically for each module. Not all of the modules depend on the coroutines library, so I can't add that opt in to all modules. My current solution is to call this for each module, and if it depends on coroutines I add the opt in:
    fun Project.containsDependency(name: String) =
       configurations
         .named("implementation")
         .get()
         .dependencies
         .any { dependency -> name in dependency.name } ||
         project
           .configurations
           .named("api")
           .get()
           .dependencies
           .any { dependency -> name in dependency.name }
    I really don't like this approach. Is there a better one?
    e
    • 2
    • 9
  • h

    hfhbd

    08/26/2021, 8:21 AM
    How do you see the Kotlin Compiler output in Gradle? Using
    compileProductionLibraryKotlinJs --debug -Pkotlin.verbose=true
    does not print any (useful) compiler outputs in Gradle
    m
    • 2
    • 1
  • e

    Eugene

    08/26/2021, 8:48 AM
    Hey from Kotlin team :kotlinnew: Quick question: what DSL do you like more❓ Option #1 - changing a task
    tasks.withType<KotlinCompile>().configureEach {
        kotlinOptions.freeCompilerArgs += "-opt-in=org.mylibrary.OptInAnnotation"
    }
    Option #2 - using sourceSet
    sourceSets {
        all {
            languageSettings.optIn("org.mylibrary.OptInAnnotation")
        }
    }
    Please vote and leave your WHY in thread. Thanks
    🤔 1
    0️⃣ 8
    2️⃣ 6
    1️⃣ 6
    g
    s
    +5
    • 8
    • 20
  • m

    mbonnin

    08/26/2021, 4:06 PM
    Not sure where to put this, I updated to Kotlin 1.5.30 and got hit by:
    'compileJava' task (current target is 11) and 'compileKotlin' task (current target is 1.8) jvm target compatibility should be set to the same Java version.
    Except that I don't have any java source in this project. Can I disable the javaCompile task somehow?
    e
    v
    +2
    • 5
    • 16
Powered by Linen
Title
m

mbonnin

08/26/2021, 4:06 PM
Not sure where to put this, I updated to Kotlin 1.5.30 and got hit by:
'compileJava' task (current target is 11) and 'compileKotlin' task (current target is 1.8) jvm target compatibility should be set to the same Java version.
Except that I don't have any java source in this project. Can I disable the javaCompile task somehow?
e

edrd

08/26/2021, 4:27 PM
It can be skipped with:
tasks.withType<JavaCompile> {
  onlyIf { false }
}
m

mbonnin

08/26/2021, 4:29 PM
I thought about that but I wouldn't expect that to silence the warning. Let me check
e

edrd

08/26/2021, 4:30 PM
Yeah, from the message it seems like some task consistency check is going on, not an error from the task per se. But anyway, worth trying...
m

mbonnin

08/26/2021, 4:31 PM
Yep, same warning
I can set
targetCompatibility = 1.8
in my gradle script but that feels kind of misleading since there's no java to be found
e

edrd

08/26/2021, 4:34 PM
Or set the Kotlin target to 11, if that's not a problem for you
m

mbonnin

08/26/2021, 4:36 PM
It's for a lib so the more compatibility the better
v

Vampire

08/27/2021, 10:42 AM
Maybe set the Java toolchain? The Kotlin plugin should fully support it now afair and then it should also match. btw.
enabled = false
over
onlyIf { false }
:-)
👍 2
💯 1
e

edrd

08/27/2021, 12:10 PM
Cool, didn't know about
enabled
d

Dariusz Kuc

08/27/2021, 10:11 PM
just hit the same thing with
1.5.30
(multi module pure kotlin project)... I'm using SDKMAN and got both Java 8 and 11 (default) installed locally - when I set the toolchain version to Java 8 kapt blew up (when processing spring annotation) unable to find
java.lang
packages - without toolchain config it run fine just with the warning above. Might be unrelated but my test android (using Android tools 7.0.1) build also blew up on version update (without setting java toolchain) with
Cannot have abstract method KotlinJavaToolchain.getJdk()
- works fine with
1.5.21
*and yeah it looks like it is not a Gradle issue
t

tapchicoma

09/06/2021, 9:02 AM
The warning comes from Kotlin plugin. Best solution would be to set toolchain, but you could also disable this check by adding
kotlin.jvm.target.validation.mode=ignore
into
gradle.properties
m

mbonnin

09/06/2021, 9:03 AM
My point is that it's a project that doesn't use java at all
Ideally I'd like the Kotlin Plugin to not warn me about Java if there's no Java being compiled
t

tapchicoma

09/06/2021, 9:03 AM
yes, there is a bug that KGP creates java tasks as well when no java sources are available. Let me find it
👀 1
👍 1
Sorry for the delay - here the bug issue: https://youtrack.jetbrains.com/issue/KT-48745
there is a bug that KGP creates java tasks as well when no java sources are available.
Actually KGP apply
java-library
plugin, but should not trigger creation of registered Java tasks when Java sourceset is empty
❤️ 1
:thank-you: 1
View count: 5