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

    Chilli

    04/29/2020, 9:53 AM
    message has been deleted
    b
    • 2
    • 3
  • x

    x80486

    04/29/2020, 2:31 PM
    Similar to the previous question...I do also have a multi-project build in Kotlin DSL; I'm looking for ways to apply the
    detekt
    plugin in the
    subprojects
    block. This is what I have so far: https://gist.github.com/x80486/52d5b8f1d584f90732e7d1881df423a7, but Gradle tells me that
    detekt
    is not recognizable. I would like to avoid to configure
    detekt
    in all subprojects, that's what I'm really trying to do. Anyone have done this before?
    a
    • 2
    • 4
  • o

    Ola Adolfsson

    04/30/2020, 6:06 AM
    Hi all, is there a way to set the npm registry? I would like to use our private instead of the official (npmjs)?
    s
    • 2
    • 3
  • a

    Ananiya

    04/30/2020, 3:46 PM
    does any one can help me solving out this problem my gradle version 5.2.1 my ide version intellij Idea 2020.1 and my kotlin version 3.7.1
    plugins {
        id 'java'
        id 'org.jetbrains.kotlin.jvm' version '1.3.71'
        id "org.jetbrains.kotlin.kapt" version "1.3.71"
    }
    
    group 'org.example'
    version '1.0-SNAPSHOT'
    
    repositories {
        mavenCentral()
    }
    
    dependencies {
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
        testCompile group: 'junit', name: 'junit', version: '4.12'
        implementation "com.squareup.retrofit2:converter-gson:2.3.0"
        implementation "io.reactivex.rxjava2:rxandroid:2.0.1"
    
        compile 'org.jsoup:jsoup:1.13.1'
        testImplementation "com.squareup.okhttp3:mockwebserver:4.5.0"
        implementation "com.squareup.okhttp3:okhttp:4.5.0"
        implementation 'com.squareup.retrofit2:retrofit:2.3.0'
        implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
    
    
        implementation("com.squareup.moshi:moshi-kotlin:1.9.2")
        kapt("com.squareup.moshi:moshi-kotlin-codegen:1.9.2")
        implementation("com.squareup.moshi:moshi:1.9.2")
    }
    
    
    compileKotlin {
        kotlinOptions.jvmTarget = "1.8"
    }
    compileTestKotlin {
        kotlinOptions.jvmTarget = "1.8"
    }
    r
    d
    i
    • 4
    • 5
  • o

    Omar Mainegra

    05/01/2020, 1:56 PM
    Hello everyone, I don't know if this is the right place to ask this, also probably this was asked before many times, but I can't find any answer. After updating to Kotlin
    1.3.7x
    I could finally run iOS and JS tests from Idea, but now it doesn't show the option to run android (but still works if I add the task to the Run Configuration)
    s
    • 2
    • 14
  • i

    Ilya Muradyan

    05/02/2020, 6:00 PM
    Hello, guys! There is a function
    fun DependencyHandler.kotlin(module: String, version: String? = null): Any =
        "org.jetbrains.kotlin:kotlin-$module${version?.let { ":$version" } ?: ""}"
    Why does it return Any? It becomes a problem when I use this overload of
    implementation
    :
    implementation(kotlin("...")) { isTransitive = false }
    In this variant,
    implementation
    takes
    String
    as a first argument and I need to explicitely cast return value to
    String
    o
    g
    • 3
    • 4
  • j

    Javier

    05/03/2020, 11:23 PM
    This snippet from the following link doesn’t let me use artifactId: https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#experimental-metadata-publishing-mode I tried gradle 6.4-rc-4 too.
    e
    • 2
    • 1
  • d

    Dariusz Kuc

    05/05/2020, 7:27 PM
    hello! I got a requirement to create dependency bundle for my project that can be fetched from s3 instead of downloading dependencies from internet (i.e. build happens on containers that won’t have shared maven/gradle cache). I’m trying to create archive as
    register<Zip>("createS3DependencyBundle") {
            archiveFileName.set("${project.name}-dependencies.zip")
            destinationDirectory.set(file("$buildDir/dist"))
    
            from(fileTree(File(gradle.gradleHomeDir, "caches/modules-2/files-2.1")))
        }
    but no zip archive is created - any ideas?
    o
    r
    • 3
    • 33
  • d

    Dariusz Kuc

    05/06/2020, 5:32 AM
    hello! is there a way to finalize root module task AFTER all child modules finish their tasks? e.g. would like to finalize
    publish
    with
    closeAndReleaseRepository
    (from
    gradle-nexus-staging-plugin
    ) but it needs to run after ALL modules finish publishing their artifacts. Currently I’m explicitly running
    gradle publish closeAndReleaseRepository
    but wondering whether there is a better way
    c
    • 2
    • 13
  • d

    Dariusz Kuc

    05/07/2020, 4:47 PM
    hello! I’m trying to publish multi module project and it looks like Gradle automatically created an extra project for what normally would be some maven parent project, e.g. -> https://github.com/ExpediaGroup/graphql-kotlin/blob/master/settings.gradle.kts#L29
    - project1
    - project2
    - directory // nothing in this project -> its just for logically grouping project3 and project4 together
      |- project3
      |- project4
    Any idea how to instrument Gradle to skip processing
    directory
    module from the above?
    • 1
    • 2
  • d

    Dariusz Kuc

    05/07/2020, 6:36 PM
    hello! I’m trying to publish my custom gradle plugin to Maven central and currently it blows up on the auto generated plugin marker
    pom.xml
    . So my question is a) I’m publishing to both Maven central and Gradle plugin portal - should this plugin marker
    pom.xml
    actually be published to Central? b) If its not needed -> how do I exclude it from publications c) If it is needed -> how do I configure it to add required fields for sonatype validation d) its a multi-module project where other libs are published to Maven central -> how do I disable Gradle plugin from publishing to Maven central?
    • 1
    • 2
  • p

    PHondogo

    05/07/2020, 7:59 PM
    Hello! I want to try kotlin-1.4-M1 but with kotlin-dsl plugin gradle complains of different versions of kotlin libs on classpath. Please advice me how to solve this issue.
    o
    • 2
    • 9
  • x

    x80486

    05/09/2020, 2:53 PM
    Hello everyone! I'm trying to setup a Micronaut project with Gradle
    6.4.0
    , there are a lot of dependencies on different configurations (e.g.:
    implementation
    ,
    kapt
    , etc.)...my question: is there a way to just include a BOM without the need to include it in all configurations? This is what I have:
    implementation(enforcedPlatform("io.micronaut:micronaut-bom:${project.property("micronaut.version")}"))
    
      kapt(enforcedPlatform("io.micronaut:micronaut-bom:${project.property("micronaut.version")}"))
      kaptTest(enforcedPlatform("io.micronaut:micronaut-bom:${project.property("micronaut.version")}"))
    
      testImplementation(enforcedPlatform("io.micronaut:micronaut-bom:${project.property("micronaut.version")}"))
    ...I would like just to have one of those applied to the entire project, if that's possible.
    o
    c
    • 3
    • 11
  • r

    rkeazor

    05/10/2020, 3:36 PM
    is it possible to set kotlin options in a gradle Plugin<Project>
    o
    g
    • 3
    • 30
  • d

    Dariusz Kuc

    05/11/2020, 3:28 PM
    hello! I’m trying to split up our protobuf module to produce two separate artifacts - Java+Reactor and Kotlin specific (currently it builds single artifact with optional dependencies for both). My project setup
    - build.gradle.kts // [1] root builds java artifact
    - src
      - main/java - some common utils here
      - main/resources - some common resources
      - main/proto
    - kotlin-specific
      - build.gradle.kts [2] builds kotlin artfiact with some sources from [1]
      - src/main/kotlin - kotlin specific utils
    Whats the proper way to reference sources/resources from root [1] in my kotlin specific build [2]? e.g. I could do something like
    sourceSets {
        main {
            java.srcDir("${rootProject.java}/src/main/java")
        }
    }
    but wondering if there is a better way
    a
    • 2
    • 13
  • d

    Dariusz Kuc

    05/13/2020, 3:43 AM
    Hello, whats the proper way to introduce task ordering in multi module project? e.g. based on the docs (https://docs.gradle.org/current/userguide/more_about_tasks.html#sec:finalizer_tasks)
    finalizedBy
    always executes regardless whether finalized task succeeded or not - is there a way to ensure
    taskB
    runs after
    taskA
    only if
    taskA
    is successful? I’m trying to put ordering in publishing artifacts to maven central and Gradle plugin portal, was hoping I could order the tasks so that when I run
    ./gradlew publish
    it will 1) initialize sonatype staging repo before publishing - [ok] root publish depends on intialize staging repo) 2) all subprojects attempt to publish their lib to maven central - [ok] 3) after publish is complete i need to close the staging repo - finalize doesn’t work as I don’t want to close the sonatype repo if publish failed 4) after this is complete I then want to publish my plugin to Gradle portal - was going to use
    publishPlugins
    depends on
    closeStaging
    and
    publish
    is finalized by
    publishPlugins
    but hit the same problem that I do not want to publish if it previous steps fail Guess I should just stick to explicit tasks from command line? e.g.
    ./gradlew :initializeSonatypeStagingRepository publish :closeAndReleaseRepository publishPlugins
    a
    • 2
    • 4
  • t

    tim

    05/13/2020, 8:55 AM
    Hi folks, whats the difference in my kotlin-based gradle dsl between
    implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
    and
    implementation(kotlin("stdlib"))
    Both seem to work fine for my project so i'd like to understand what each is doing?
    s
    c
    o
    • 4
    • 5
  • c

    Chilli

    05/13/2020, 12:06 PM
    When compiling for JVM through Gradle, I get the thing below:
    > Task :compileTestKotlinJvm
    Could not perform incremental compilation: Could not connect to Kotlin compile daemon
    Could not connect to kotlin daemon. Using fallback strategy.
    And I think it's making building slower. Any way to fix it?
    s
    • 2
    • 1
  • g

    Gopal S Akshintala

    05/14/2020, 2:25 PM
    How to configure default gradle wrapper version to be used by Intellij, when creating new gradle project? (Currently it is using 6.1.1 and downloading it, although I have the latest version 6.3 on my machine)
    d
    a
    g
    • 4
    • 7
  • r

    rrva

    05/16/2020, 11:18 AM
    is there a way to enable gradle build cache in IntelliJ without modifying
    gradle.properties
    ?
    b
    r
    +2
    • 5
    • 6
  • r

    rrva

    05/18/2020, 10:03 AM
    is there a good way to enforce a certain jdk version for building a gradle project?
    a
    n
    • 3
    • 9
  • m

    MSC

    05/18/2020, 9:14 PM
    What’s the best practice for creating a library with all the dependencies necessary for implementation in the consumer project? e.g.: I’m generating gPRC service classes via
    protobuf
    plugin and packaging into a jar, then in the consumer project I want to add this library(jar file) as a dependency in the gradle file and be ready to create a blocking stub, which requires the
    io.grpc
    library to be present? 🤔
    o
    c
    • 3
    • 7
  • t

    Tomas Pekarek

    05/19/2020, 7:34 AM
    This is taken from build.gradle.kts
    tasks{   
     "bootJar"(BootJar::class) {
            archiveFileName.set("imps.jar")
        }}
    I was wondering what kind of language construct allows me to write string followed by (). I mean "bootJar"(BootJar::class). What is that? -- I found that string boot initializer uses
    withType<Test> {
            useJUnitPlatform()
        }
    What is the preferred way to modify tasks?
    o
    n
    • 3
    • 5
  • m

    Martin Westman

    05/19/2020, 8:47 AM
    When building a modular gradle project with openjdk14 as build environment, is it neccessary to specify a java module structure with java9 modules (module-info.java) as well or can you just use a plain jar? When doing a module-info.java with the line “requires kotlin.stdlib” we get the following error when building:
    module-info.java:2: error: module not found: kotlin.stdlib
        requires kotlin.stdlib;
                       ^
    • 1
    • 2
  • d

    Dariusz Kuc

    05/19/2020, 8:59 PM
    hello! any idea why publish to sonatype would not include my custom plugin.jar? I’m publishing to both Maven Central and Plugin Portal and while last publish was successful I only got pom, javadoc and sources (from default maven publication) but no jar. My root project config: https://github.com/ExpediaGroup/graphql-kotlin/blob/master/build.gradle.kts#L172 <- I’m explicitly configuring
    mavenJava
    publication for all projects except Gradle plugin as it explicitly creates its own
    pluginMaven
    publication. Gradle plugin config: https://github.com/ExpediaGroup/graphql-kotlin/blob/master/plugins/graphql-kotlin-gradle-plugin/build.gradle.kts
    publishToMavenLocal
    correctly publishes the plugin jar so it would appear that
    pluginMaven
    publication already contains the jar -> any ideas? ~Should I just add
    from(jarComponent)
    to all MavenPublications~(doesn’t work - fails with Maven publication ‘pluginMaven’ cannot include multiple components)~?~
    • 1
    • 2
  • h

    Harun

    05/23/2020, 1:32 PM
    Since accessing buildSrc project and its dependencies in settings script is deprecated, is there a way to still access them, or does one have to use Strings instead. Am avoiding to keep using strings while they're already defined in a object inside the buildSrc directory. With gradle below v 6.0 this was working fine but with 6.0 its bringing errors.
    c
    • 2
    • 5
  • u

    ursus

    05/24/2020, 3:57 PM
    ˛gradlew testDebugUnitTest
    is not picking up tests from
    :app
    module since I have flavors, what gives? Wasnt it supposed to run everything?
    g
    • 2
    • 8
  • s

    Slackbot

    05/25/2020, 1:06 AM
    This message was deleted.
    g
    • 2
    • 2
  • d

    Dylan

    05/25/2020, 1:21 PM
    Hi there, is it possible to create a Kotlin gradle plugin without using Kotlin DSL? I tried using Kotlin DSL. It works, but I need to use the basic build.gradle file instead. Unfortunately, I'm not able to figure out how my .gradle should looks like. Here's how it looks:
    buildscript {
        repositories {
            google()
            jcenter()
        }
    
        dependencies {
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72"
        }
    }
    
    repositories {
        google()
        jcenter()
    }
    
    dependencies {
        implementation("com.squareup:kotlinpoet:1.5.0")
    }
    With that configuration, after trying to build my project, I have the following exception:
    Caused by: org.gradle.api.plugins.InvalidPluginException: Could not find implementation class 'com.example.gradle.MyPlugin' for plugin 'MyPlugin' specified in [Path to buildSrc jar]
    After looking into the Jar itself, it looks like
    MyPlugin.properties
    is here, but not the class
    MyPlugin
    . Do you have any idea?
    g
    n
    +2
    • 5
    • 73
  • d

    Dariusz Kuc

    05/26/2020, 6:49 PM
    [cmd line parameters] Hello! Is there a way to specify list of values for a parameter using command line? e.g. something like
    gradle myTask -PcustomParam=abc -PcustomParam=xyz
    that would result in
    customParam=[abc, xyz]
    ?
    • 1
    • 2
Powered by Linen
Title
d

Dariusz Kuc

05/26/2020, 6:49 PM
[cmd line parameters] Hello! Is there a way to specify list of values for a parameter using command line? e.g. something like
gradle myTask -PcustomParam=abc -PcustomParam=xyz
that would result in
customParam=[abc, xyz]
?
or even better to specify tuples for each param that would result in a map
guess can only do that through explicit configuration in
build.gradle
View count: 3