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

    Javier

    03/25/2020, 3:10 PM
    Hello, I am trying to add to my buildSrc file the dependency for
    org.gradle.kotlin.dsl
    but I can't find it.
    e
    15 replies · 2 participants
  • g

    Gunslingor

    03/26/2020, 12:13 AM
    Really wish these gradle plugins had better docs describing what each is really doing under the hood, the sequence of events, and all the configuration options, which there should probably be more of.
    t
    1 reply · 2 participants
  • m

    mbonnin

    03/26/2020, 4:48 PM
    Maybe try
    ./gradlew buildEnvironment
    ?
    n
    1 reply · 2 participants
  • t

    turansky

    03/27/2020, 11:35 AM
    Is there
    kotllin-dsl
    version compatible with kotlin plugin
    1.4-M1
    ?
    e
    r
    +1
    27 replies · 4 participants
  • c

    cpe

    03/27/2020, 11:53 AM
    Hi, I’d like to create a Gradle Task for my Spring Boot App that allows me to start it with a property set:
    tasks.register("bootRunDev") {
      System.setProperty("spring.profiles.active", "dev")
      finalizedBy(tasks.bootRun)
    }
    However, this is not working - the property is not recognized. I also tried to extend the
    BootRun
    Profile:
    task<BootRun>("bootRunDev") {
      systemProperties["spring.profiles.active"] = "dev"
      dependsOn("bootRun")
    }
    Both approaches don’t work. Is there a way to do it?
    l
    1 reply · 2 participants
  • b

    bjonnh

    03/27/2020, 4:29 PM
    What are the different ways to handle version numbers? For now I'm defining a variable twice, in my root of build.gradle.kts and in plugins
    f
    14 replies · 2 participants
  • b

    bjonnh

    03/27/2020, 4:29 PM
    Is there any other way? I've seen ways with people making a buildSrc and a kotlin file that has the versions
    s
    2 replies · 2 participants
  • s

    sanogueralorenzo

    03/29/2020, 2:16 AM
    Hello everyone. What is the equivalent of this groovy snippet in
    .kts
    ?
    task all(type: GradleBuild) { tasks = ["independentTask1", "independentTask2"] }
    o
    2 replies · 2 participants
  • s

    Stephan Schroeder

    03/29/2020, 10:59 AM
    so I have a Kotlin project using Gradle 6.2 with the Kotlin DSL. I want to add a second sourceset main2 and than use the
    internal
    modifier to mutually hide classes inbetween main and main2. So this is the expected folder structure:
    src/main/kotlin
    src/main2/kotlin
    src/test/kotlin
    I've come pretty far by add this to my build.gradle.kts
    sourceSets {
        val mainSourceSet: SourceSet = sourceSets["main"]
        val testSourceSet: SourceSet = sourceSets["test"]
    
        val main2SourceSet: SourceSet = create("main2") {
            compileClasspath += mainSourceSet.output
            runtimeClasspath += mainSourceSet.output
        }
    
        mainSourceSet.compileClasspath += main2SourceSet.output
        mainSourceSet.runtimeClasspath += main2SourceSet.output
        testSourceSet.compileClasspath += main2SourceSet.output
        testSourceSet.runtimeClasspath += main2SourceSet.output
    }
    now • code in main can see all the public classes from main2 but not the internal ones • code in main2 can see all the public classes from main but not the internal ones • code in test can see all the public and internal classes from main • code in test can only see the public classes from main2 How do I make the internal classes from main2 accessible to test?
    2 replies · 1 participant
  • a

    Ahmed Ibrahim

    04/02/2020, 11:28 AM
    How can I do this notation but in
    buildSrc
    instead?
    implementation(group = "", name = "facebook-login-6.3.0-jetified", ext = "aar")
    In buildSrc I can't access the
    implementation
    function, and I can only do
    add("implementation", "put-the-local-aar-here")
    , the question is how can I include the local aar through the add function which is only available under only the
    buildSrc
    ?
    o
    j
    17 replies · 3 participants
  • l

    LastExceed

    04/04/2020, 9:33 AM
    I am trying to publish my first library to MavenCentral, but i have trouble figuring out how to do it. I followed this guide: https://central.sonatype.org/pages/ossrh-guide.html to create whatever this is: https://issues.sonatype.org/browse/OSSRH-56105 then i tried to configure Gradle with these instructions: https://central.sonatype.org/pages/gradle.html which turn out to be outdated according to this documentation: https://docs.gradle.org/current/userguide/publishing_setup.html so i'm trying to follow that instead, but this documentation isn't very helpful. It suggests using the
    publishing {}
    block which isn't even possible (workaround here: https://stackoverflow.com/questions/54654376/why-is-publishing-function-not-being-found-in-my-custom-gradle-kts-file-within ) and doesn't give me any information on how to configure it for a kotlin project. can someone help me? maybe someone has a working project setup that i can look at ? I am completely lost
    d
    m
    4 replies · 3 participants
  • d

    Dariusz Kuc

    04/04/2020, 8:58 PM
    hello! whats the proper way to combine custom
    maven-publish
    pom.xml
    and the one that is generated by
    java-gradle-plugin
    ?, e.g. I got multi module project where I create
    pom.xml
    for all subprojects so it includes same license info, etc (https://github.com/dariuszkuc/graphql-kotlin/blob/plugin/build.gradle.kts#L132). It looks like
    java-gradle-plugin
    creates its own (very limited one) and ignores the generated pom (https://github.com/dariuszkuc/graphql-kotlin/blob/plugin/plugins/graphql-kotlin-gradle-plugin/build.gradle.kts#L11). Any suggestions? Thanks!
    2 replies · 1 participant
  • j

    JP

    04/08/2020, 12:04 PM
    A noob question: I just added new dependency in
    build.gradle.kts
    after the prior build, like
    dependencies {
        // ...
        implementation("org.springframework.boot:spring-boot-starter-security")
        implementation("org.springframework.security:spring-security-test")
    }
    , but when I build in IntelliJ, the new dependencies doesn’t get installed: I can’t see them in the External Libraries, and I can’t import them. Am I missing something here? Or is there a certain other way to update the dependencies?
    s
    7 replies · 2 participants
  • h

    Holger Steinhauer [Mod]

    04/08/2020, 4:34 PM
    Hey ya. In one of my current projects someone decided to use terraform and docker-compose via Gradle. I am currently struggling with a dependency. I have a task defined like that:
    tasks {
    
        val waitServer by creating {
            group = "Docker"
            description = "Spin-up fresh builds via Docker"
            dependsOn (":reconciliation:dockerBuildImage")
            dependsOn(composeUp)
        }
    }
    So I would expect that
    ./gradlew waitServer
    would call
    dockerBuildImage
    on the
    reconciliation
    module first and then run
    composeUp
    . But it goes straight into
    composeUp
    which fails because the docker image from the
    reconciliation
    module isn’t built yet. Any ideas?
    a
    4 replies · 2 participants
  • r

    rolgalan

    04/09/2020, 3:42 PM
    Hi all! Maybe this is impossible, but I wanted to ask: Is it possible to share code between
    buildSrc/build.gradle.kts
    file and the rest of buildSrc files? I have some configuration that I use in some of my plugins that I also would like to reuse in the build.gradle file. However, this file is used to build the buildSrc, so I cannot reference to any of my buildSrc helper classes. I don’t know if I’m missing something or this just is not achievable. Any help?
    t
    t
    6 replies · 3 participants
  • d

    Dariusz Kuc

    04/09/2020, 8:06 PM
    [solved] hello! I'm writing custom gradle plugin and trying to figure out proper configuration for tasks and plugin extension • I have 2 tasks (
    A
    and
    B
    ) that can be executed independently of each other • task
    B
    can optionally take an input from task
    A
    output (or just read file from a file system) • [works] I would like to provide an option for end users to either configure tasks directly in their build scripts
    // build.gradle.kts
    val a by tasks.getting(TaskA::class) {
      propA.set("whatever")
    }
    tasks.withType(TaskB::class) {
      propB.set("xyz")
      input.set(a.output)
      dependsOn("taskA")
    }
    • [doesn't work] I would also like to provide an option to to automatically create those tasks and their dependencies if project extension is configured, e.g.
    // build.gradle.kts
    myExtension {
      propA = "whatever"
      propB = "xyz"
    }
    Is that even possible?
    3 replies · 1 participant
  • j

    Joffrey

    04/12/2020, 5:01 PM
    Hi guys, I’m publishing a multi-platform library (mainly JVM, browser and nodejs), but I also want several artifacts (flavors) per platform, because I want users to be able to pick different modules to avoid unnecessary 3rd party deps. My current approach is having multiple subprojects, some of which are pure JS, some pure JVM, and some multiplatform, with inter-dependencies, but it’s a bit of a hassle. I wonder if there is a better way using many Gradle source sets instead. Maybe just declaring several times the same target with different names for different “flavors” and different sets of deps, but I can’t find any example online, any pointers? If you need more details, here’s my project: https://github.com/joffrey-bion/krossbow
    e
    2 replies · 2 participants
  • u

    ursus

    04/15/2020, 9:58 PM
    then why do I still see it, if the lib includes the gson via
    implementation
    anyways?
    o
    18 replies · 2 participants
  • b

    bjonnh

    04/17/2020, 2:53 PM
    The code completion has been almost inexistent for me lately i was blaming the 1.4-M1 plugin for that
    y
    1 reply · 2 participants
  • e

    EyeCon

    04/19/2020, 12:54 PM
    Hello, I'm very new to Gradle. I adapted an existing Maven project via
    gradle init
    . It seems to work — it downloads dependencies, builds etc. Now I'm trying to navigate around in the source and it doesn't seem to work with this project. It used to run previously (in other projects), but this is the first time I'm starting a project with Gradle. I just updated IntelliJ too, I hope this isn't some very recent bug. Basically I can't navigate to Gradle-downloaded definitions. Anyone have any ideas? I did invalidate the cache and restart.
    y
    2 replies · 2 participants
  • j

    Javier

    04/19/2020, 3:08 PM
    I am trying to publish a multiplatform library to bintray with only
    maven-publish
    plugin but for some reason, there are multiple versions uploaded.
    1 reply · 1 participant
  • j

    John Peña

    04/20/2020, 10:45 PM
    because
    DiagnosticControllerTest
    doesn't have 151 lines
    o
    3 replies · 2 participants
  • j

    John Peña

    04/21/2020, 5:25 PM
    i recently removed some classpath dependencies from my buildscript section, maybe that's the issue?
    o
    23 replies · 2 participants
  • j

    juro

    04/21/2020, 5:48 PM
    hello, im bit stuck on how to define "aar" or "zip" dependency with dependencies constraints (using github/android/plaid -like structure) with
    dependencies { constraints { api("${Libs.LIBRARY}:${version}@aar") } }
    and using
    implementation(Libs.LIBRARY)
    in my :app gradle this dependency fails to resolve im sure there is some parameter which could be used to define extensions, but i cant seem to figure out how to do it
    o
    3 replies · 2 participants
  • p

    Peter

    04/22/2020, 7:10 PM
    hi - new to gradle, using the kotlin DSL, i declare a
    val
    but they don’t appear to be in scope for the
    buildscript
    block right below, though work fine for
    allscripts
    or
    subprojects
    eg:
    val artifactVersion: String by project
    buildscript {
      version = artifactVersion // unresolved reference
    }
    allprojects {
      version = artifactVersion // ok 
    }
    seeing as these constants are dependent on
    project
    it’s not clear how I can move this to
    buildSrc
    and make them available everywhere. if i redeclare them with the
    buildscript
    block it works but that defeats the purpose (i have many of these constants)
    o
    5 replies · 2 participants
  • k

    kevin.cianfarini

    04/22/2020, 8:27 PM
    I'm struggling with gradle right now and would appreciate some help. I've got a MPP whih I'm trying to add a custom build of kotlinx-io (courtesy of @altavir) to. I can't seem to get it to resolve the dependency from bintray.
    repositories {
        jcenter()
        maven { url = uri("<https://dl.bintray.com/mipt-npm/dev>") }
    }
    
    kotlin {
    
        jvm()
        linuxX64("linux")
    
        sourceSets {
    
            val commonMain by getting {
                dependencies {
                    implementation(kotlin("stdlib-common"))
                    implementation("org.jetbrains.kotlinx:kotlinx-io:0.2.0-npm-dev-7")
                }
            }
    a
    8 replies · 2 participants
  • d

    Dustyn

    04/24/2020, 3:24 PM
    Hey at all - i got a question as well. When i run my javafx project in intellij there are no problems - when i run it with "./gradlw run" it complains about me setting up the module system wrong i think
    javafx.graphics does not "opens javafx.scene" to unnamed modul
    . Does anybody spot the problem? https://gist.github.com/deggers/804cb1ffe6853d968ab58683e0f3318f
    x
    2 replies · 2 participants
  • x

    x80486

    04/24/2020, 6:20 PM
    Hello everyone! I have a multi-project using Kotlin DSL: https://gist.github.com/x80486/52d5b8f1d584f90732e7d1881df423a7 I'm trying to understand why there are some tasks that are being applied still to the root project. There is nothing there, no
    src
    , etc. ...so I'm not expecting that Gradle executes anything on it, but on the modules within that umbrella project...any clues? In Maven that's correctly executed, so I think there should be an equivalent in Gradle...thanks in advance!
    a
    10 replies · 2 participants
  • b

    bod

    04/25/2020, 1:22 PM
    Hello, World! I'm migrating to
    kts
    . Let's say I want some globally accessible map for dependency versions (for instance
    "gradle" to "6.3", "kotlin" to "1.3.70"
    and so on) - and I'd like to be able to access it from the root's build.gradle.kts, and also the other module's. What's the simplest way to do this? Currently I have a solution using
    extra
    but is there a way to simply add my own
    object
    to the classpath or something like that?
    p
    m
    9 replies · 3 participants
  • j

    Javier

    04/27/2020, 9:43 PM
    Is there any way to pass
    signing.gnupg.passphrase
    as
    gradle publish
    task param instead of defining it in gradle.properties?
    t
    d
    5 replies · 3 participants
Powered by Linen
Title
j

Javier

04/27/2020, 9:43 PM
Is there any way to pass
signing.gnupg.passphrase
as
gradle publish
task param instead of defining it in gradle.properties?
gradle publish -Psigning.gnupg.keyName=[keyId] -Dsigning.gnupg.passphrase=[passphrase]
The -P instead of -D for keyName was the problem…
t

tddmonkey

04/28/2020, 7:06 AM
you can also store it in
~/.gradle/gradle.properties
j

Javier

04/28/2020, 8:09 AM
I can't, I want to use it with GItHub actions easily. In local works, but I think I have to add the key to the CI to get it working
d

danny

04/28/2020, 3:46 PM
Use environment variables - https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets / https://docs.gradle.org/current/userguide/signing_plugin.html#sec:in-memory-keys
View count: 7