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

    Smallville7123

    03/31/2019, 12:56 AM
    for example, one that ONLY prints "Hello World!" and NOTHING ELSE
    t
    • 2
    • 2
  • s

    Shan

    03/31/2019, 3:26 PM
    Is there any documentation anywhere about how to add an environment variable from a
    local.properties
    file into a buildscript with the gradle kotlin dsl? I can only find really old posts that don't seem to work anymore. For context, I'm trying to load a GPG user/pass/keyring into my buildscript for publishing a release version of my project to sonatype.. if anyone knows a better way to do this I am all ears.
    t
    • 2
    • 12
  • s

    Smallville7123

    04/02/2019, 9:52 PM
    how do i import a kotlin script from a kotlin build script as i have a 1.6k line kotlin build script (
    build.gradle.kts
    ) that i want to split into smaller files
    g
    e
    • 3
    • 291
  • s

    svenjacobs

    04/03/2019, 7:09 AM
    Good morning from Germany, I have a complex multi-module project that I want to convert from Gradle to Gradle Kotlin DSL. In Gradle I moved common module configuration into separate Gradle files and applied/imported them in each module. With Kotlin DSL this does not seem to work properly. Please see https://gist.github.com/svenjacobs/3643a1ba83def5edf8a07f1d209158ef. It seems that Kotlin scripts applied via
    apply(from = "...")
    do not evaluate plugins. For instance in
    common.gradle.kts
    I get an error because
    implementation()
    is not found. I know that in this case I can use
    "implementation"()
    but that doesn't solve the actual problem. In other base modules where I load the Android plugin for instance suddenly
    android { ... }
    is not found. How do I solve this with Kotlin DSL?
    g
    n
    • 3
    • 17
  • s

    Smallville7123

    04/03/2019, 10:10 PM
    how can i abort a build from a plugin, as GradleException does not work
    g
    • 2
    • 1
  • s

    Smallville7123

    04/05/2019, 12:46 AM
    how do i make a task execute before compileDebugKotlin
    Could not get unknown property 'compileDebugKotlin' for project ':app' of type org.gradle.api.Project.
    compileDebugKotlin.dependsOn MyTask
    g
    • 2
    • 15
  • m

    mingkangpan

    04/06/2019, 9:25 PM
    what am I doing wrong here?
    g
    n
    • 3
    • 4
  • h

    hmole

    04/07/2019, 12:49 PM
    Any gradle plugin devs know if there is a way to generate plugin descriptors with some kind of annotation on the plugin?
    gradlePlugin
    dsl forces you to write same thing twice
    g
    • 2
    • 5
  • p

    palaiokostas

    04/07/2019, 4:55 PM
    • 1
    • 3
  • a

    Alowaniak

    04/08/2019, 12:40 PM
    How can I specify different java version for main and test? As in https://stackoverflow.com/questions/28513789/gradle-different-jdk-version-for-source-and-test
    g
    • 2
    • 3
  • p

    Paulius Ruminas

    04/09/2019, 6:21 AM
    Hello, how does one configure test dependencies between two modules in kotlin gradle dsl. With groovy i used to do: ModuleA build.gradle:
    task jarTest(type: Jar) {
        from sourceSets.test.output
        classifier = 'test'
    }
    
    configurations {
        testOutput
    }
    
    artifacts {
        testOutput jarTest
    }
    ModuleB build.gradle:
    testImplementation project(path: ':ModuleA', configuration: 'testOutput')
    t
    • 2
    • 3
  • r

    Robert

    04/09/2019, 7:49 PM
    gradle build
    seems to work, but when I click to run a specific test in the editor, it fails with the error above
    s
    • 2
    • 2
  • t

    thana

    04/10/2019, 8:15 AM
    we are developing an application consisting of a frontend and a backend part. the frontend aprt is started via
    npm start
    and the backend part can be startet via
    ./gradlew bootRun
    . to ease start of the whole application i'd like to provide a gradle task which would start both. while starting each part alone is wasy, is there a way to start both in parallel with a single task? How would this tasks look like?
    t
    • 2
    • 12
  • t

    thana

    04/10/2019, 11:46 AM
    meh 😉
    t
    • 2
    • 5
  • s

    Smallville7123

    04/10/2019, 1:48 PM
    also how do i convert a gradle plugin into a stand alone kotlin compilable package, as i get
    [macropreprocessor@macro-pc kotlin]$ kotlinc-jvm -include-runtime -d main.jar main.kt -classpath ./
    main.kt:1:26: error: unresolved reference: globalVariables
    import preprocessor.base.globalVariables
                             ^
    main.kt:2:27: error: unresolved reference: Sync
    import preprocessor.utils.Sync
                              ^
    main.kt:3:32: error: unresolved reference: abort
    import preprocessor.utils.core.abort
                                   ^
    main.kt:7:5: error: unresolved reference: globalVariables
        globalVariables.abortOnComplete = false
        ^
    main.kt:8:5: error: unresolved reference: globalVariables
        globalVariables.abortAsGradle = false
        ^
    main.kt:11:5: error: unresolved reference: globalVariables
        globalVariables.initGlobals(root, proj)
        ^
    main.kt:12:5: error: unresolved reference: Sync
        Sync().findSourceFilesOrNull(globalVariables.projectDirectory)
        ^
    main.kt:12:34: error: unresolved reference: globalVariables
        Sync().findSourceFilesOrNull(globalVariables.projectDirectory)
                                     ^
    main.kt:14:9: error: unresolved reference: globalVariables
        if (globalVariables.abortOnComplete) abort()
            ^
    main.kt:14:42: error: unresolved reference: abort
        if (globalVariables.abortOnComplete) abort()
                                             ^
    [macropreprocessor@macro-pc kotlin]$ pwd
    /home/macropreprocessor/AndroidStudioProjects/kppmaster/buildSrc/src/main/kotlin
    import preprocessor.base.globalVariables
    import preprocessor.utils.Sync
    import preprocessor.utils.core.abort
    
    fun main() {
        println("starting KOTLIN_PRE_PROCESSOR")
        globalVariables.abortOnComplete = false
        globalVariables.abortAsGradle = false
        val root = "/home/macropreprocessor/AndroidStudioProjects/kppmaster"
        val proj = "/home/macropreprocessor/AndroidStudioProjects/kppmaster/app"
        globalVariables.initGlobals(root, proj)
        Sync().findSourceFilesOrNull(globalVariables.projectDirectory)
        println("KOTLIN_PRE_PROCESSOR finished")
        if (globalVariables.abortOnComplete) abort()
    }
    d
    • 2
    • 5
  • d

    Davor Maric

    04/10/2019, 1:53 PM
    Hi.. anyone experiencing an issues when it comes to applying
    kotlin-dsl
    +
    buildSrc
    to fresh multi-module android project? Gradle: 4.10.1 AS: 3.3 Kotlin: 1.3.21 OS: macOS latest When submitting the project to git, I am unable to rebuild it properly. It yells at me that the project is unlinked, and there are no runconfigurations set up
    s
    • 2
    • 3
  • j

    janvladimirmostert

    04/10/2019, 6:44 PM
    what is the official way of building fat jars with Gradle 5+? The docs says one should do this:
    tasks.register<Jar>("uberJar") {
    	archiveClassifier.set("uber")
    
    	from(sourceSets.main.get().output)
    
    	dependsOn(configurations.runtimeClasspath)
    	from({
    		configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) }
    	})
    }
    but i'm not seeing a fat jar in build/libs when doing
    gradle build
    ` https://docs.gradle.org/current/userguide/working_with_files.html#sec:creating_uber_jar_example
    g
    • 2
    • 3
  • d

    dwursteisen

    04/10/2019, 6:46 PM
    can you run ./gradlew uberJar to invoke the task?
    🤘 1
    🎉 1
    👍 1
    n
    • 2
    • 2
  • d

    dwursteisen

    04/11/2019, 8:35 AM
    hum. what you’re doing now it’s updating all jar task to build an uberjar (not sure of what i’m saying…). My opinion whould be more to tell gradle : ok, the task build will depends of the task uberJar (ie: build will have to run uberJar before executing). to do so:
    tasks.withName("build").dependsOn("uberJar")
    (I’m not sure of my code, but it should be something like that: getting the task
    build
    and adding
    uberJar
    as a dependent task
    j
    • 2
    • 1
  • s

    Smallville7123

    04/11/2019, 9:45 AM
    anyone?
    ❓ 2
    r
    • 2
    • 2
  • d

    Davide Giuseppe Farella

    04/11/2019, 4:20 PM
    I’m trying to figure out how to set the name of my
    apk
    output with
    gradle-dsl
    g
    • 2
    • 9
  • x

    x80486

    04/11/2019, 6:42 PM
    Hello everyone! Hey, I’m about to migrate some Gradle script to Kotlin DSL, but I just realized that Kotlin doesn’t support octals, so I’m wondering if somebody have solved this before (I can’t find anything so far). I would need to convert this task as part of the process:
    task distribution(type: Zip) {
      archiveName = "${project.name}.zip"
      dependsOn assemble
    
      dirMode 0755
      fileMode 0644
    
      from compileJava
      from processResources
      into("lib") {
        from configurations.runtimeClasspath
      }
    }
    t
    • 2
    • 1
  • s

    snowe

    04/11/2019, 7:45 PM
    what is the 'type' of the
    publishing
    plugin? e.g.
    class PublishingPlugin : Plugin<Project> {
        override fun apply(project: Project): Unit = project.run {
            plugins.apply(org.gradle.api.publish.maven.plugins.MavenPublishPlugin::class)
            tasks.named("publishing") {
                // have task here, but not publishing task. what is the publishing task type?
                repositories {
                    maven {
                    }
                }
            }
        }
    }
    ✅ 1
    o
    • 2
    • 12
  • s

    Slackbot

    04/11/2019, 8:27 PM
    This message was deleted.
    o
    s
    • 3
    • 4
  • s

    snowe

    04/11/2019, 8:35 PM
    omg... just discovered https://docs.gradle.org/current/userguide/kotlin_dsl.html#kotdsl:precompiled_plugins... this might be what I've wanted this whole time 😭
    • 1
    • 2
  • s

    Smallville7123

    04/12/2019, 2:27 AM
    how do i convert this into a valid kotlin compilable package (
    A.A.kt
    so it can be imported in
    build.gradle.kts
    via
    import A.A
    so i can test if it actually compiled in gradle as to how it should be converted from gradle to a
    kotlinc-jvm
    compilable package) A/A.kt
    package A
    import A.B.B
    
    fun main() {
        B().main()
    }
    A/B/B.kt
    package A.B
    
    class B {
        fun main() {
            println("hello")
        }
    }
    $ kotlinc-jvm -include-runtime -d main.jar A/A.kt -classpath ./
    A/A.kt:2:12: error: unresolved reference: B
    import A.B.B
               ^
    A/A.kt:6:9: error: unresolved reference: B
            B().main()
            ^
    i
    • 2
    • 5
  • s

    Smallville7123

    04/12/2019, 5:14 AM
    how do i get konan to work
    g
    • 2
    • 1
  • s

    Smallville7123

    04/12/2019, 5:19 AM
    as im trying to get my plugin to compile for kotlin-native
    g
    • 2
    • 15
  • s

    Smallville7123

    04/12/2019, 6:42 AM
    how do i compile my plugin with kotlin multiplatform as i get
    > Plugin with id 'kpp' not found.
    my
    buildSrc/build.gradle.kts
    is
    plugins {
        kotlin("multiplatform") version "1.3.21"
    }
    
    repositories {
        jcenter()
        mavenCentral()
    }
    
    kotlin {
        jvm {
            val main by compilations.getting {
                kotlinOptions {
                    // Setup the Kotlin compiler options for the 'main' compilation:
                    jvmTarget = "1.8"
                }
    
                compileKotlinTask // get the Kotlin task 'compileKotlinJvm'
                output // get the main compilation output
            }
    
            compilations["test"].runtimeDependencyFiles // get the test runtime classpath
        }
    
        // Configure all compilations of all targets:
        targets.all {
            compilations.all {
                kotlinOptions {
                    allWarningsAsErrors = true
                }
            }
        }
    }
    g
    • 2
    • 1
  • s

    Smallville7123

    04/12/2019, 7:01 AM
    apparently
    build.gradle
    and
    build.gradle.kts
    cannot coexist
    g
    • 2
    • 2
Powered by Linen
Title
s

Smallville7123

04/12/2019, 7:01 AM
apparently
build.gradle
and
build.gradle.kts
cannot coexist
g

gildor

04/12/2019, 7:04 AM
sure
build.gradle is selected by default
View count: 5