https://kotlinlang.org logo
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
  • p

    pablisco

    02/13/2020, 12:31 PM
    What do you all here think of this? https://twitter.com/pablisc0/status/1227933148622860289
    f
    o
    j
    • 4
    • 34
  • n

    Nick Halase

    02/13/2020, 2:52 PM
    So lately I've noticed people using
    buildSrc
    builds to declare plugin dependencies. What is the difference between declaring a dependency in the
    dependencies
    block of
    buildSrc/build.gradle.kts
    and doing it as
    buildscript
    or using the
    plugins
    block?
    m
    • 2
    • 3
  • b

    Brendan Weinstein

    02/13/2020, 10:17 PM
    Has anyone configured buildSrc within an android project to depend on a limited amount of code from your main app module? I have two classes from my main app module that I want to generate code based off. I googled and saw folks mention that you just need to specify the files from your main module in the
    buildSrc
    sourceSet, but I could not find an example of how to do this. I am playing around with
    buildSrc
    sourceSets right now, but would appreciate it if anyone has some code I could reference to save a few cycles
    • 1
    • 4
  • c

    Cyril Scetbon

    02/14/2020, 3:20 PM
    Hey guys, I have
    <dependency>
                <groupId>io.debezium</groupId>
                <artifactId>debezium-core</artifactId>
                <type>test-jar</type>
                <scope>test</scope>
            </dependency>
    I'd like to add it to my gradle with a kotlin project
    f
    • 2
    • 4
  • j

    Javier

    02/15/2020, 12:43 AM
    How can I use
    baseFeature
    in kts?
    o
    c
    • 3
    • 9
  • f

    Fleshgrinder

    02/15/2020, 11:28 AM
    How important would you say is compatibility with Java‘s UUID implementation if Kotlin has one?
    n
    • 2
    • 3
  • m

    Mark

    02/16/2020, 5:09 AM
    Trying to work out how to specify a base gradle KTS file (for things like compile/min/target sdk etc) to be applied by each android library module. Is this still not possible? https://github.com/gradle/kotlin-dsl-samples/issues/1287
    m
    t
    • 3
    • 8
  • n

    napperley

    02/17/2020, 2:29 AM
    Is it possible to run tests only on Common modules via Gradle?
    o
    s
    • 3
    • 8
  • a

    Ahmed Ibrahim

    02/17/2020, 1:53 PM
    I'm trying to setup my Android project to use Junit 5, so in groovy I would usually do
    unitTests.all {
            useJUnitPlatform()
    }
    In Kotlin script though I'm doing
    testOptions {
            unitTests.all(closureOf<Test> {
                useJUnitPlatform()
            } as Closure<Test>)
        }
    However I'm a bit annoyed from the
    as
    clause as without it I get a compile error, so my question is there a way I could do that without explicitly casting to
    Closure<Test>
    ?
    m
    m
    t
    • 4
    • 11
  • j

    John Ballard

    02/18/2020, 2:02 PM
    I am having a problem I know was seen earlier but I cannot find the post in the channels. Idea has been switching JDK from 8 to 11 when I build / refresh the project. It switches to 11 (the jetbrains jdk) which causes all of the build files to show errors. I don’t see a particular error. I am using the kotlin 1.3 (184) EAP, gradle 661, and openjpa jdk 8, and ideaU 2019.3. Please advise.
    g
    n
    • 3
    • 7
  • i

    Ibrahim Ali

    02/18/2020, 4:27 PM
    I'm publishing a plugin BUT it took a lot of time as Pending Approval statue.. Is that OK?
    m
    r
    • 3
    • 2
  • g

    Gabriel Feo

    02/19/2020, 9:27 AM
    Anybody know how to use a bash variable in an
    Exec
    task’s command? Escaping the dollar sign doesn’t seem to work. For example:
    commandLine = listOf("echo", "Declared in env GOOGLE_APPLICATION_CREDENTIALS=\$GOOGLE_APPLICATION_CREDENTIALS")
    Output:
    Declared in env GOOGLE_APPLICATION_CREDENTIALS=$GOOGLE_APPLICATION_CREDENTIALS
    o
    f
    • 3
    • 9
  • s

    Seri

    02/19/2020, 4:21 PM
    https://blog.jetbrains.com/kotlin/2020/02/improved-gradle-kts-ide-support/
    🙌 10
    🎉 6
    n
    • 2
    • 1
  • t

    tylerwilson

    02/19/2020, 4:31 PM
    Any good resources on how to migrate from Groovy Gradle scripts to Kotlin DSL Gradle scripts? How about a converter that auto-converts to Kotlin, like we can with Java source pasted into Kotlin file. 🙂
    m
    a
    +6
    • 9
    • 34
  • j

    jk2018

    02/21/2020, 7:03 PM
    I've got an Android project that I'm building with gradle-5.4.1 . I keep getting this message "Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0. Use '--warning-mode all' to show the individual deprecation warnings." I did use that argument, but I still can't figure out what exactly is deprecated. Anyone got a hint about where exactly to look?
    t
    h
    • 3
    • 13
  • a

    arnaud.giuliani

    02/22/2020, 9:53 AM
    Hi all, I’ve got a gradle task that I would like to distribute. It’s just a task that allow to run a category of test:
    task checkModules(type: Test) {
        testLogging {
            showStandardStreams = true
        }
        useJUnit {
            includeCategories 'org.koin.test.category.CheckModuleTest'
        }
    }
    It’s for a library. Can I distribute it as a Gradle plugin?
    m
    • 2
    • 22
  • k

    Kenneth Andersson

    02/24/2020, 11:12 AM
    Hi, Im involved in a kotlin multiplatform project - and my gradle skills leaves a bit to be desired. Does anybody have a few pointers on how to write a task that executes after another task. For example:```
    task myTask {
        dependsOn(tasks.named("jsMainClasses").get())
        println("A task running after jsMainClasses is done.")
    }
    Our use-case is that I want to copy the js-build artifacts to a different location after they are built
    t
    • 2
    • 3
  • b

    Brais Gabin

    02/24/2020, 12:21 PM
    Hi, I’m trying to define all my dependencies in a BoM platform module so the other modules in my multi-module project can use the same versions. All works fine except the
    kapt
    dependencies. In those I get this error:
    Could not determine the dependencies of task ':app:kaptDebugKotlin'.
    > Could not resolve all task dependencies for configuration ':app:kapt'.
       > Could not find com.google.dagger:dagger-compiler:.
         Required by:
             project :app
    The platform (bom) module:
    plugins {
      id 'java-platform'
    }
    
    dependencies {
      constraints {
        api 'com.google.dagger:dagger:2.25.2'
        api 'com.google.dagger:dagger-compiler:2.25.2'
      }
    }
    The app dependency declaration:
    dependencies {
      implementation platform(project(':bom'))
      implementation 'com.google.dagger:dagger'
      kapt 'com.google.dagger:dagger-compiler'
      // ...
    }
    I’m getting the same error if I use
    annotationProcessor
    . If I set the version like
    kapt 'com.google.dagger:dagger-compiler:2.25.2'
    all works. Any idea?
    l
    • 2
    • 3
  • f

    Fleshgrinder

    02/24/2020, 1:54 PM
    Has anyone ever tried to use GitHub Actions cache as Gradle build cache? I would assume that a simple local cache is all that needs to be configured, no?
    p
    • 2
    • 1
  • r

    René

    02/25/2020, 6:01 AM
    I'm trying to slim down a cli tool (a fat jar), which was about 200kb and now after adding some network features grew up to 16MB. What I have noticed is, that my older jar contained just my own classes, but the new jar had a lot classes with the packages kotlin and kotlinx and I'm wondering why they are there
    o
    g
    • 3
    • 20
  • t

    tim

    02/25/2020, 12:43 PM
    Hey folks, sorry newb here. What's best practice like for managing dependency versions? Coming from JS/yarn i use to run
    yarn upgrade-interactive
    regularly to upgrade all my dependencies to the latest versions (SEM ver'd so I could skip out MAJOR changes as well). Can I specify a package range in the dependencies block i.e.,
    implements("io.github.cdimascio:java-dotenv:>5")
    or is there a grandle command which will update all packages to the latest published version?
    b
    c
    • 3
    • 9
  • t

    tim

    02/25/2020, 3:43 PM
    Is there an easy way to load in enviroment variables before my code runs? Im trying to get dotenv-java to work, but I see that it doesn't actually set env vars on System.getenv() where some of my dependent packages look (mainly google cloud stuff). Is there any way to export env vars inside the build.gradle.kts or its there another approach altogether?
    c
    • 2
    • 14
  • s

    snowe

    02/25/2020, 9:26 PM
    we're encountering this error, https://stackoverflow.com/questions/59303742/gradle-6-migration-settings-gradle-kts it appears that the api changed in 6. https://docs.gradle.org/current/userguide/upgrading_version_5.html
    As part of the change, the SettingsScriptApi interface is no longer implemented by settings scripts and the InitScriptApi interface is no longer implemented by init scripts. They should be replaced with the corresponding model object interfaces, Settings and Gradle.
    but we cannot figure out the new syntax. It doesn't appear that the Settings object has any way to access the gradle.properties variables, like it did before. and it also seems like
    pluginManagement {
        plugins {
    no longer works either. Anyone know what to do here?
    o
    • 2
    • 7
  • d

    Dariusz Kuc

    02/26/2020, 3:46 AM
    hello, I'm writing custom task that accepts as input some file. I'd like to provide an option to pass it through command line (which I guess requires String) and also allow to set the file directly through DSL. Currently I expose those as two separate properties ->
    // set from command line
    @Input
    @Optional
    @Option(option = "targetFileName", description = "target file")
    val targetFileName: Property<String> = project.objects.property(String::class.java)
    
    // set from DSL
    @Input
    @Optional
    val targetFile: RegularFileProperty = project.objects.fileProperty()
    Is there a better way? If not, is there a way to hide
    targetFileName
    from the DSL?
    o
    • 2
    • 3
  • s

    snowe

    02/26/2020, 6:06 PM
    Really weird issue. Converted a project to gradle from maven (it already had kotlin in it), but now when we're calling a certain constructor we're getting a really weird error. error:
    error: constructor ThirdPartyFailedResponse in class ThirdPartyFailedResponse cannot be applied to given types;
                ThirdPartyFailedResponse failedResponse = new ThirdPartyFailedResponse(false,
                                                          ^
      required: String,UUID,UUID,UUID
      found: boolean,String,UUID,UUID,UUID
      reason: actual and formal argument lists differ in length
    class
    class ThirdPartyFailedResponse(
            val success: Boolean = false,
            val message: String,
            override val loanTransactionId: UUID,
            override val loanId: UUID?,
            override val serviceOrderId: UUID
    ) : ThirdPartyResponse
    absolutely nothing has changed in the project besides running
    gradle init
    and then fixing dependencies. I don't see how a dependency could cause an issue like this, it has nothing to do with
    @JvmOverloads
    , or the like.
    f
    m
    • 3
    • 69
  • d

    Dariusz Kuc

    02/27/2020, 6:05 AM
    hello, just a hit a weird error -> I'm writing custom plugin that relies on coroutines 1.3. When I try to apply it on a project and run my custom task I'm getting exception complaining
    Caused by: java.lang.NoSuchMethodError: kotlinx.coroutines.CoroutineScopeKt.cancel(Lkotlinx/coroutines/CoroutineScope;Ljava/lang/String;Ljava/lang/Throwable;)V
    which points to old version of coroutines lib being used. Sure enough by running
    gradle dependencies
    I see
    kotlinCompilerPluginClasspath
    \--- org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.3.61
    ...
         |    \--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.2.1
    any ideaes on how to fix this?
    o
    • 2
    • 17
  • g

    Gus

    02/28/2020, 5:52 PM
    Hello. I'm new to Kotlin and Gradle, and I'm having a problem publishing to Bintray: The version (e.g.,
    0.0.6
    ) gets published properly but a second version named after the artifact id (
    relaynet-core-jvm
    ) gets published along with it. I have no idea what's publishing that second version. Here's my
    publishing
    closure: https://github.com/relaycorp/relaynet-core-jvm/blob/39bc842184c8c35b1a33734c02961270072a478d/build.gradle.kts#L100-L138. Everything else seems to work OK. Any idea what could be happening?
    m
    • 2
    • 1
  • m

    Mohamed Ibrahim

    03/01/2020, 10:03 PM
    Hello, is there any plugin or tool to support autocomplete and code suggestion in gradle files in Android or IntelliJ
    o
    l
    • 3
    • 4
  • a

    Allan Wang

    03/02/2020, 7:15 AM
    More of a gradle question, but when using tasks.findbyname, how are we supposed to deal with tasks that are seemingly lazily created? Android
    assembleRelease
    is null on evaluation, and a bunch of previous posts here simply check for null before actually handling it
    t
    • 2
    • 5
  • d

    Dariusz Kuc

    03/02/2020, 9:13 PM
    hello, I'm writing some custom tasks and would like to use output file from one task as an input to another -> resolved
    m
    • 2
    • 7
Powered by Linen
Title
d

Dariusz Kuc

03/02/2020, 9:13 PM
hello, I'm writing some custom tasks and would like to use output file from one task as an input to another -> resolved
open class MyCustomTask1 : DefaultTask() {

    @Input
    @Option(option = "outputFileName", description = "output file name")
    val outputFileName: Property<String> = project.objects.property(String::class.java)

    @OutputFile
    val outputFile: Provider<RegularFile> = outputFileName.flatMap { name -> project.layout.buildDirectory.file(name) }

    // actual task code omitted for clarity
}

open class MyCustomTask2 : DefaultTask() {

    @Input
    @Optional
    @Option(option = "inputFileName", description = "input file name")
    val inputFileName: Property<String> = project.objects.property(String::class.java)

    @Input
    @Optional
    val inputFile: RegularFileProperty = project.objects.fileProperty()

    // skipping code
}
While individual tasks worked fine I'm trying to configure
task2
to use
task1
output, e.g. in
build.gradle.kts
val firstTask by tasks.getting(MyCustomTask1::class) {
  // configuration
}
val secondTask by tasks.getting(MyCustomTask2::class) {
    inputFile.set(firstTask.outputFile)

    dependsOn("firstTask")
}
unfortunately when run I'm hitting
Unable to store input properties for task .... Property 'inputFile' with value '/valid/path/to/task1/outputFile' cannot be serialized.
Any ideas?
problem was with
task2
using
@Input
on
RegularFileProperty
it works when I updated it to
@InputFile
m

miqbaldc

03/02/2020, 10:29 PM
I might be wrong, but what happened when you prioritize
dependsOn
first then running your
inputFile.set
? does your
outputFile
exist?
d

Dariusz Kuc

03/02/2020, 11:29 PM
It correctly run task1 and generated its output
But faile don task2 with the serialization error
Fix was to use @InputFile instead of @Input
👍 1
m

miqbaldc

03/03/2020, 1:19 AM
nice, thanks for the answer
View count: 3