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

    sdeleuze

    05/25/2018, 10:46 AM
    Question: why do I have to use
    val shadowJar by tasks.getting(ShadowJar::class) { ... }
    to exclude files with the shadow plugin instead of using
    shadow { ... }
    which provides a useless
    ShadowExtension
    lambda? Is the shadow plugin badly designed ? I see this kind of issue in various plugins so I would like to know what is the rationale behind this and understand that kind of issue and at what level this should be fixed ...
    j
    e
    +2
    • 5
    • 21
  • m

    mkobit

    05/25/2018, 4:11 PM
    @Lucas it unfortunately looks like groovy dynamicness - https://github.com/researchgate/gradle-release/blob/b76fb21cc325f689c154b5674c4c96054cbc6f02/src/main/groovy/net/researchgate/release/ReleaseExtension.groovy#L77-L121
    l
    c
    • 3
    • 4
  • l

    Lex Luthra

    05/28/2018, 1:38 AM
    Recently, I migrated my project's Gradle build script from Groovy to Kotlin DSL. As part of that change, I converted the configuration for the Transmode gradle-docker plugin as follows:
    // Groovy DSL
    task buildDocker(type: Docker) {
        baseImage = 'develar/java:latest'
        push = project.hasProperty('push')
        tag = 'geowarin/sout-chuck-norris'
        addFile {
            from jar
            rename {'app.jar'}
        }
        entryPoint(['java', '-Djava.security.egd=file:/dev/./urandom', '-jar', '/app.jar'])
        exposePort(8080)
    }
    buildDocker.dependsOn(build)
    
    // Kotlin DSL
    import se.transmode.gradle.plugins.docker.DockerTask
    
    buildscript {
        dependencies {
            classpath("se.transmode.gradle:gradle-docker:1.2")
        }
        repositories {
            jcenter()
        }
    }
    
    tasks {
        "buildDocker"(DockerTask::class) {
            val appJarName = "app.jar"
            dependsOn(tasks["build"])
            baseImage = "develar/java:latest"
            push = project.hasProperty("push")
            tag = "geowarin/sout-chuck-norris"
            addFile(closureOf<CopySpec> {
                from(tasks["jar"] as CopySpec)
                rename { appJarName }
            })
            entryPoint(mutableListOf("java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "/$appJarName"))
            exposePort(if (project.hasProperty("server.port")) project.property("server.port") as Int else 8080)
        }
    }
    However, when I run the buildDocker task I receive the following error on the console:
    What went wrong: Execution failed for task ':buildDocker'. se.transmode.gradle.plugins.docker.DockerTask$_createTarArchive_closure3_closure11_closure12 cannot be cast to org.gradle.api.file.CopySpec
    I have worked around it by copying the file using doFirst and then invoking the form of addFile that accepts a path String instead of a Closure but would like to get to the bottom of this issue as it might help others in the future.
    c
    • 2
    • 2
  • j

    jlleitschuh

    05/31/2018, 12:43 PM
    @xenoterracide What you want is the version
    "5.+
    which means "the highest version of
    5.xxxx
    that can be found.
    x
    c
    • 3
    • 5
  • s

    sdeleuze

    05/31/2018, 2:39 PM
    Something more staticaly type than Groovy closure
    j
    • 2
    • 3
  • e

    eskatos

    05/31/2018, 2:58 PM
    Action<T>
    predates the Kotlin DSL and I believe was already the recommended way. But yes, gradle guides will be updated with best practices that work for both DSLs.
    👍 1
    s
    • 2
    • 1
  • m

    mkobit

    05/31/2018, 3:02 PM
    @eskatos might also be helpful if the
    java-gradle-plugin
    did some validation for those kinds of APIs as well
    e
    • 2
    • 3
  • s

    svenjacobs

    06/01/2018, 7:24 AM
    Well, the point is I’m trying to figure out another Kotlin related problem and first I want to fix all warnings/dependency issues to find out whether these are the reasons for my other issue
    c
    g
    • 3
    • 9
  • e

    Ed M

    06/02/2018, 4:39 PM
    looks like you haven't applied either the kotlin or the java plugins
    x
    • 2
    • 11
  • e

    Ed M

    06/04/2018, 3:47 AM
    is there any reason you can’t just do
    xeno.setSourceSets(project.sourceSets.findByName(SourceSet.MAIN_SOURCE_SET_NAME))
    x
    • 2
    • 3
  • g

    gildor

    06/05/2018, 6:34 AM
    I set Kotlin plugin version (usually only on root module or in settings.gradle) and omit version of stdlib
    l
    • 2
    • 25
  • e

    Ed M

    06/05/2018, 8:12 PM
    why do you have
    java-library
    in backticks?
    l
    • 2
    • 3
  • f

    fred.deschenes

    06/05/2018, 8:15 PM
    am I crazy or is it impossible to not apply a built-in plugin (ie:
    application
    ) on the root project?
    m
    • 2
    • 2
  • j

    james_bassett

    06/06/2018, 12:37 AM
    I might try and raise an issue later today when I have more details, but my builds suddenly hang after the composeUp task after upgrading to 4.8 (when using the docker plugin https://github.com/avast/gradle-docker-compose-plugin). It appears to finish the task normally, but then just sits there
    IDLE
    forever.
    --debug
    just shows the daemon collecting memory stats periodically.
    h
    • 2
    • 1
  • f

    Florian Wiesner

    06/06/2018, 8:36 AM
    has anyone of you a working example of a gradle plugin project that uses the Spring or AllOpen Kotlin sub-plugins in TestKit with the Kotlin DSL?
    m
    • 2
    • 6
  • c

    Czar

    06/06/2018, 9:56 PM
    you could also try using
    application
    plugin instead of configuring manifest manually
    ➕ 1
    v
    g
    • 3
    • 2
  • f

    fitzoh

    06/07/2018, 10:52 AM
    https://zeroturnaround.com/rebellabs/using-buildsrc-for-custom-logic-in-gradle-builds/
    g
    • 2
    • 2
  • v

    valerie.turlington

    06/07/2018, 2:16 PM
    “No main manifest attribute” 🤔 I think I’m missing something.
    g
    • 2
    • 2
  • c

    Czar

    06/07/2018, 7:03 PM
    e.g. if you have this in buildSrc:
    object libs {
    	const val kotlinVersion = "1.2.41"
    }
    then you can use it in plugins:
    import libs
    import org.gradle.kotlin.dsl.*
    
    plugins {
        kotlin("jvm") version libs.kotlinVersion
    }
    m
    j
    j
    • 4
    • 6
  • i

    ianbrandt

    06/09/2018, 8:20 AM
    Is there a more up-to-date way to configure the
    wrapper
    task from the Kotlin DSL than this example (https://github.com/gradle/kotlin-dsl/issues/438#issuecomment-318749893)?:
    import org.gradle.api.tasks.wrapper.Wrapper.DistributionType
    task<Wrapper>("wrapper") {
      gradleVersion = "4.8"
      distributionType = DistributionType.ALL
    }
    It works, but results in a deprecation warning:
    $ ./gradlew build --warning-mode=all
    
    > Configure project :
    Creating a custom task named 'wrapper' has been deprecated and is scheduled to be removed in Gradle 5.0. You can configure the existing task using the 'wrapper { }' syntax or create your custom task under a different name.'.
    m
    • 2
    • 3
  • s

    sdeleuze

    06/13/2018, 10:36 AM
    Could it be possible to bundle
    inline fun <reified T : Task> task(noinline configuration: T.() -> Unit) = tasks.creating(T::class, configuration)
    by default ? (from https://github.com/gradle/kotlin-dsl/blob/master/build.gradle.kts#L149 and found in various projects since it is super useful)
    ➕ 3
    👍🏼 1
    t
    • 2
    • 2
  • i

    ilya.gorbunov

    06/15/2018, 12:24 AM
    kotlinOptions.freeCompilerArgs += ["-Xprogressive"]
    :gradle: 1
    👍 1
    g
    • 2
    • 1
  • d

    dsvoronin

    06/15/2018, 3:30 PM
    Is there any way to override embeddedKotlinVersion? Iam using gradle 4,8 (kotlin dsl 0.17.5 , kotlin embedded 1.2.41) and kotlin version 1.2.50 in project
    buildSrc/build.gradle.kts
    contains
    plugins { kotlin-dsl}
    and root build.gradle.kts overrides kotlin plugin version with
    buildscript {
        val kotlinVersion: String by project
        dependencies {
            classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
        }
    }
    getting this warning on kotlin compilation tasks
    Compilation with Kotlin compile daemon was not successful
    java.lang.NoSuchMethodError: org.jetbrains.kotlin.daemon.common.IncrementalCompilationOptions.<init>(ZLjava/util/List;Ljava/util/List;Ljava/io/File;Ljava/lang/String;ILorg/jetbrains/kotlin/daemon/common/CompilerMode;Lorg/jetbrains/kotlin/daemon/common/CompileService$TargetPlatform;[Ljava/lang/Integer;I[Ljava/lang/Integer;ZLjava/util/List;Lorg/jetbrains/kotlin/daemon/common/MultiModuleICSettings;Lorg/jetbrains/kotlin/daemon/common/IncrementalModuleInfo;)V
            at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.incrementalCompilationWithDaemon(GradleKotlinCompilerRunner.kt:264)
    • 1
    • 2
  • b

    bissell

    06/17/2018, 8:56 PM
    is there a canonical list of the available
    freeCompilerArgs
    somewhere?
    kotlinc -help
    doesn't mention '-Xprogressive' for example
    i
    • 2
    • 1
  • b

    bissell

    06/17/2018, 9:19 PM
    Okay so setting up
    KotlinCompile
    and
    Kotlin2JsCompile
    separately helped. I still can't figure out how to get them to take a common config though, if anyone with good Gradle-fu could take a look it would be much appreciated 🙂 :
  • b

    bissell

    06/17/2018, 9:30 PM
    Also, is the
    KotlinCommonCompile
    target broken? Whenever I try to use it in my build script in the same spot as
    KotlinCompile
    and
    Kotlin2JsCompile
    I get:
    > Could not get unknown property 'org' for project ':common' of type org.gradle.api.Project.
    h
    • 2
    • 2
  • i

    ilya.gorbunov

    06/17/2018, 10:03 PM
    @bissell there's no such class, better to use interfaces from `org.jetbrains.kotlin.gradle.dsl`: https://github.com/JetBrains/kotlin/blob/1.2.50/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinCompile.kt
    b
    • 2
    • 3
  • s

    sdeleuze

    06/19/2018, 11:34 AM
    Is there any plan to leverage Kotlin 1.2.50 scripting improvements in Gradle Kotlin DSL and can we expect significant performance improvements?
    👍 4
    e
    • 2
    • 1
  • x

    xenoterracide

    06/19/2018, 1:07 PM
    by any chance does anyone know how to make it so bitbucket pipelines doesn't refetch gradle itself each time?
    g
    x
    • 3
    • 26
  • n

    napperley

    06/20/2018, 3:00 AM
    Is there something in Gradle that will show all imports (based on all applied plugins) that can be included in a build.gradle.kts file? Need this in order to know what to import from the Konan plugin.
    g
    • 2
    • 12
Powered by Linen
Title
n

napperley

06/20/2018, 3:00 AM
Is there something in Gradle that will show all imports (based on all applied plugins) that can be included in a build.gradle.kts file? Need this in order to know what to import from the Konan plugin.
g

gildor

06/20/2018, 3:02 AM
What exactly do you want to know?
This is simple konan config https://github.com/gildor/knel/blob/master/native/build.gradle.kts
No imports
n

napperley

06/20/2018, 3:04 AM
This is what I am trying to automate with Gradle: https://gitlab.com/napperley/openfaas-weather-sample#building-program
g

gildor

06/20/2018, 3:14 AM
You want ti automate libcurl installation?
because you already need JVM to run gradle. You don’t need to install K/N SDK manually, konan plugin does it for you, cinterop can be configured from gradle
No need to import something, pretty straight forward convertation to kotlin-dsl from groovy: https://github.com/JetBrains/kotlin-native/blob/master/samples/libcurl/build.gradle
so what is not available out of the box is installation of libcurl and cjson.
n

napperley

06/20/2018, 3:54 AM
Meant automating steps 2-9 (excl step 4) in the "Building Program" section of the readme file.
g

gildor

06/20/2018, 3:58 AM
2, 5, 8, 9 already automated by konan gradle plugin
4 is not required, probably user already cloned this repo, otherwise you don’t have access to gradle and build.gradle that can automate something
3, 6, 7 is related to native dependencies and can be automated, but only as platform and OS specific solution
View count: 4