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

    ribesg

    09/27/2018, 10:07 AM
    * What went wrong:
    A problem occurred configuring root project 'myProject'.
    > compileSdkVersion is not specified.
    Since when is
    compileSdkVersion
    required in the root build script?
    ✔️ 1
    g
    • 2
    • 20
  • r

    ribesg

    09/27/2018, 12:04 PM
    So I think I'm close to the end of my converstion from gradle to gradle.kts, but I have an error:
    SigningConfig with name 'releasekey' not found.
    ✔️ 1
    g
    • 2
    • 4
  • r

    ribesg

    09/27/2018, 1:04 PM
    I've got tons of errors like
    error: incompatible types: NonExistentClass cannot be converted to Annotation @error.NonExistentClass()
    . The actual annotation in the files is
    Parcelize
    ✔️ 1
    k
    • 2
    • 5
  • r

    ribesg

    09/27/2018, 1:16 PM
    I'm trying to set the target bytecode version to 8, but I can't seem to find the correct syntax https://kotlinlang.org/docs/reference/using-gradle.html#compiler-options
    ✔️ 1
    g
    • 2
    • 3
  • j

    jmhmccr

    09/28/2018, 4:29 AM
    I keep getting
    Plugin [id: 'org.jetbrains.kotlin.jvm', version: '1.3.0-rc-57'] was not found
    and don't see a whole bunch of docs for specifying the kotlin plugin version via buildscript
    r
    • 2
    • 2
  • a

    ankushg

    09/29/2018, 8:27 PM
    Might not be exactly Kotlin-related, but is there a Gradle plug-in (or maybe just an easy-to-configure Lint plug-in) that lets you mark dependencies as effectively deprecated? Our project has a ton of usages of Apache Commons and Guava from before we introduced Kotlin, and we’re looking for a way to gradually remove those dependencies (and other similar cases)
    c
    • 2
    • 1
  • k

    keturn

    10/01/2018, 12:26 AM
    I'm dusting off a project I haven't touched in a while. I've determined I can upgrade kotlin-gradle-plugin to 1.2.60 and it works, but at 1.2.70 it starts breaking with "Unable to load class 'org.gradle.api.attributes.HasAttributes'"
    o
    • 2
    • 5
  • i

    igor.wojda

    10/03/2018, 10:41 AM
    Is it possible to extract gradle plugin dependencies with their versions into separate variables? Now
    //custom objects in gradle buildSrc (to have dependency autocompletion)
    object GradlePluginVersion {
        const val detekt = "1.0.0.RC7"
    }
    
    object GradlePluginId {
        const val detekt = "io.gitlab.arturbosch.detekt"
    }
    //build.gradle
    plugins {
        id(GradlePluginId.detekt) version GradlePluginVersion.detekt
    }
    Want
    //build.gradle
    plugins {
        GradlePluginDependency.detekt
    }
    The issue I have is that
    plugin
    DSL expect
    PluginDependenciesSpec
    with is an interface, not a concrete class 🤔
    s
    • 2
    • 3
  • l

    Lex Luthor

    10/04/2018, 1:32 AM
    Has anyone here used the following plugin:
    "net.researchgate.release"
    within a Kotlin DSL Gradle build? https://github.com/researchgate/gradle-release This project aims to work much like
    maven-release-plugin
    did with Maven. The problem I'm having is that the DSL relies on Groovy
    propertyMissing
    magic and don't know how to get it to expose the
    GitConfig
    properties of the GitAdapter.. specifically I'd like to be able to set:
    -- Groovy
    git {
        requireBranch = 'master|develop'
    }
    • 1
    • 1
  • i

    igor.wojda

    10/04/2018, 1:20 PM
    I want to wrote custom grade taks that “will be running” all of the static analysis checks at once - in my case it is
    detect
    ,
    ktlint
    ,
    android lint
    . These translates to below grade tasks:
    ./gradlew detektCheck
    ./gradlew ktlintCheck
    ./gradlew lint (this task does not exist gradle will select task from app module :app:lint)
    As far I I know grade task can’t run another grade task and it can jus depend on another task (with makes perfect sense). Now I was able to write simple task (Kotlin Grade script) that runs
    detekt
    and
    ktlint
    checks (by using dependency mechanizm)
    task("staticCheck") {
        dependsOn("detekt", "ktlintCheck")
    }
    Now I am struggling with adding the (Android)
    lint
    . I can’t simply add
    lint
    to dependencies (
    dependsOn("detekt", "ktlintCheck", "lint")
    ) because
    lint
    task does not exists in configuration phase:
    task("staticCheck") {
        val lintDependencies = subprojects.mapNotNull { it.tasks.findByName("lint") } //empty list
    
        doLast {
            val lintDependencies = subprojects.mapNotNull { it.tasks.findByName("lint") } //list containing few modules, however I can't use dependsOn here
        }
    }
    What is the best way of running all static analysis checks in single task?
    c
    • 2
    • 2
  • i

    igor.wojda

    10/05/2018, 4:19 PM
    Hi small problem here. I have this standard Android gradle configuration:
    //build.gradle
    
    import org.gradle.internal.impldep.com.amazonaws.PredefinedClientConfigurations.defaultConfig
    import org.gradle.internal.impldep.org.junit.experimental.categories.Categories.CategoryFilter.include
    import org.jlleitschuh.gradle.ktlint.KtlintExtension
    
    plugins {
        id("com.android.feature")
        id("org.jetbrains.kotlin.android")
    }
    
    android {
        compileSdkVersion(28)
    
        defaultConfig {
            minSdkVersion(28)
            targetSdkVersion(28)
            buildToolsVersion("28.0.2")
    
            versionCode = 1
            versionName = "1.0"
            testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
        }
    
        buildTypes {
            getByName("release") {
                isMinifyEnabled = false
                proguardFiles("proguard-android.txt", "<http://proguard-rules.pro|proguard-rules.pro>")
    
            }
        }
    }
    
    dependencies {
        implementation(LibraryDependency.kotlin)
    
        //...
    }
    I want to extract above configuration into separate grade file, so I can easily reuse it in feature modules. I moved the code int one file and added it to build gradle files in feature modules:
    //build.gradle.kts mosule1
    
    apply(from = "${rootProject.file("common_feature.gradle.kts")}")
    //build.gradle.kts mosule2
    
    apply(from = "${rootProject.file("common_feature.gradle.kts")}")
    //common_feature.gradle.kts
    //Basicly all the above configuration that was initially in above build.gradle file and few delegates for configurations
    
    import org.gradle.internal.impldep.com.amazonaws.PredefinedClientConfigurations.defaultConfig
    import org.gradle.internal.impldep.org.junit.experimental.categories.Categories.CategoryFilter.include
    
    val implementation by configurations
    val testImplementation by configurations
    val androidTestImplementation by configurations
    
    plugins {
        id(GradlePluginId.androidFeature)
        id(GradlePluginId.kotlinAndroid)
    }
    
    android {
        compileSdkVersion(28)
    
        defaultConfig {
            minSdkVersion(28)
            targetSdkVersion(28)
            buildToolsVersion("28.0.2")
    
            versionCode = 1
            versionName = "1.0"
            testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
        }
    
        buildTypes {
            getByName("release") {
                isMinifyEnabled = false
                proguardFiles("proguard-android.txt", "<http://proguard-rules.pro|proguard-rules.pro>")
    
            }
    
            getByName("debug") {
                isMinifyEnabled = false
            }
        }
    }
    
    dependencies {
        implementation(LibraryDependency.kotlin)
    }
    The problem with extracting the code into separate gradle file is that KTS compiler throws
    Unresolved reference: android
    error. Does someone know how to fix it?
    g
    e
    • 3
    • 2
  • h

    Hamza

    10/06/2018, 6:06 AM
    hello, i have been trying to get kotlin 1.3 rc146 to work for a while now, and the project works normally for my friend who has it, but not for me. relevant information can be found here: (attached with log, and picture of script) https://kotlinlang.slack.com/archives/C0922A726/p1538732727000100
    t
    • 2
    • 40
  • n

    Nikky

    10/06/2018, 7:34 AM
    so in a gradle plugin with kotlin-dsl i can do everything, except doing things with the kotlin plugin eg. add kotlin sourceSets
    t
    • 2
    • 22
  • p

    Paul Woitaschek

    10/07/2018, 6:55 AM
    Untitled.kt
    t
    • 2
    • 2
  • l

    Lommelun

    10/09/2018, 12:30 AM
    I can't seem to figure out how to apply the kotlin (jvm) plugin in subprojects. More specifically I want to be able to set up the compile depencendies that are shared between modules in a root module. Anyone know how I can apply the plugin to use the compile dependencies in this way?
    t
    n
    • 3
    • 2
  • h

    Hamza

    10/09/2018, 3:30 AM
    I’ve been getting this error forever. What does this mean?
    g
    m
    i
    • 4
    • 21
  • d

    dwursteisen

    10/09/2018, 8:49 AM
    Hey. We trying to migrate our groovy gradle build to Kotlin DSL. But we get an issue and don’t understand how to deal with it: we have a
    subproject
    block with a
    dependencies
    block inside. We’re trying to call the method
    compile
    in it but IntelliJ don’t find it. We missing something but we don’t see what. Have you got any idea about this?
    subprojects {
       dependencies {
             compile("our dependency")
       }
    }
    I presume that something is missing in our scope so
    compile
    extension method is not available.
    t
    r
    +3
    • 6
    • 62
  • m

    mgrzechocinski

    10/09/2018, 2:41 PM
    Hey guys. I’m trying to migrate my project from Gradle to kotlin-dsl. One issue I’m struggling with is the usage of Gradle’s
    apply from:
    directive. Simplifying, when my
    build.gradle.kts
    file looks like this:
    plugins {
       id("kotlin-android-extensions")
    }
    
    androidExtensions {
      isExperimental = true
    }
    it’s works fine. However, when I try to extract plugin definition to a separated file and apply it from my `build.gradle.kts`:
    apply{
      from("$rootDir/kotlin_shared.gradle.kts") //contains plugins { id("kotlin-android-extensions") }
    }
    
    androidExtensions {
      isExperimental = true
    }
    it fails on
    "Unresolved reference: androidExtensions"
    . In Groovy version I had
    apply from:
    directive on top of my
    build.gradle
    file and it worked pretty well. Seems like kotlin’s
    apply { from () }
    doesn’t work like Gradle’s
    apply from:
    version, or am I missing sth?
    r
    m
    +2
    • 5
    • 56
  • k

    keturn

    10/09/2018, 7:27 PM
    This seems relevant but that answer doesn't feel right. The Gradle docs make it seem like for supported test frameworks it should Just Work by default. https://stackoverflow.com/questions/46490063/test-package-does-not-read-kotlin-classes-defined-in-main-package
    • 1
    • 6
  • t

    tapchicoma

    10/09/2018, 7:31 PM
    where I can find new kotlin multiplatform gradle plugin sources?
    • 1
    • 1
  • t

    tapchicoma

    10/09/2018, 7:40 PM
    or does anyone has any example repo that uses new multiplatform plugin with kotlin dsl?
    l
    • 2
    • 7
  • z

    zachtib

    10/09/2018, 11:20 PM
    I'm having trouble getting my Kotlin Gradle DSL project to build with 1.3. I've added the eap repo, and I'm trying to use the RC version string for Kotlin, but I get
    Plugin [id: 'org.jetbrains.kotlin.jvm', version: '1.3.0-rc-131'] was not found in any of the following sources:
    d
    • 2
    • 3
  • n

    Nikky

    10/10/2018, 1:16 PM
    has anybody here had success with using Klogging through a gradle plugin ? i get plain output but not the usual timetamp, threadname etc
    o
    • 2
    • 4
  • j

    jmfayard

    10/11/2018, 9:00 AM
    Pro-Tip: add a
    Gradle scope
    with the pattern
    file:*.gradle||file:*.kts||file[buildSrc]:*/||file:.gitlab-ci.yml||file:*.properties
    , it's immensly useful when you are messing with your gradle builds. https://youtrack.jetbrains.com/issue/IDEA-200335
    m
    • 2
    • 3
  • r

    ribesg

    10/11/2018, 10:47 AM
    FFS will anyone fix this
    org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'org.gradle.kotlin.kotlin-dsl', version: '1.0-rc-12']
    • 1
    • 1
  • d

    dwursteisen

    10/11/2018, 2:09 PM
    So we updated a bit our Kotlin Script. We get an issue but we don’t know how to locate the issue:
    * What went wrong:
    org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapperKt.getKotlinPluginVersion(Lorg/gradle/api/Project;)Ljava/lang/String;
    This method exist in new kotlin plugin version (1.2.61) but our build depends on the version (1.2.51) where the version doesn’t exist. The thing is: we don’t understand why it depends of the version 1.2.51 because we explicitly ask to use the 1.2.61 version. (maybe we made a mistake somewere, but we never use 1.2.51 anywhere in our build...) When running
    ./gradlew build --debug
    , we get this:
    15:38:05.214 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Resolve kotlin-scripting-gradle.jar (org.jetbrains.kotlin:kotlin-scripting-gradle:1.2.51)' completed
    There is no new version of
    kotlin-scripting-gradle
    . Could you give us a tip to find what trying to use this dependency?
    r
    • 2
    • 6
  • m

    michaelsims

    10/11/2018, 7:17 PM
    I'm writing a custom plugin using
    buildSrc
    and kotlin-dsl. Right now I'm stuck using Gradle 4.4 and Android Studio 3.1.4 and I noticed that I cannot navigate to sources for things in kotlin-stdlib (it takes me to decompiled .class files instead) and documentation is also not available. Is there a workaround for this apart from upgrading to a newer version of Gradle?
    d
    • 2
    • 3
  • i

    ikej

    10/11/2018, 8:57 PM
    After having migrated a larger project (100+ modules) to the Kotlin DSL, my biggest pain point is that when I change something in buildSrc, all scripts have to be recompiled and that takes a very long time. There is an issue that proposes to run the compilation in parallel, that would help quite a bit. But even better would be an incremental mode where scripts are only recompiled if necessary. Is that feasible?
    m
    e
    • 3
    • 3
  • d

    dwursteisen

    10/12/2018, 9:20 AM
    do you have any
    wrapper
    task or something in your build.gradle.kts? Are you using
    gradlew
    or
    gradle
    ? (checks, just in case...)
    r
    • 2
    • 1
  • j

    jmfayard

    10/12/2018, 12:27 PM
    Hello friends. I wrote a bit about the tips that have been useful while refactoring my gradle project to Kotlin https://medium.com/@jm_fayard/android-studio-pro-tips-for-working-with-gradle-8a7aa61a8cc4
    e
    • 2
    • 2
Powered by Linen
Title
j

jmfayard

10/12/2018, 12:27 PM
Hello friends. I wrote a bit about the tips that have been useful while refactoring my gradle project to Kotlin https://medium.com/@jm_fayard/android-studio-pro-tips-for-working-with-gradle-8a7aa61a8cc4
e

egorand

10/13/2018, 3:50 AM
#feed
👍 1
j

jmfayard

10/13/2018, 5:58 AM
Done, thanks
👌 1
View count: 3