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

    Nezteb

    04/25/2019, 3:29 PM
    so far I have
    jar {
        archiveName = "onboarding.jar"
    
        manifest {
            attributes(
                "Class-Path" to ???
                "Main-Class" to "com.mything.MainKt"
            )
        }
    }
    but
    configurations.compile.collect...
    isn’t a thing in the Kotlin DSL
    e
    8 replies · 2 participants
  • n

    Nezteb

    04/25/2019, 3:39 PM
    What’s the difference between the
    application
    plugin and just using the
    java
    plugin with the
    jar
    task?
    e
    1 reply · 2 participants
  • l

    leonardootto

    04/25/2019, 4:08 PM
    And its also not including the other dependencies packages.
    :thread-please: 1
    g
    10 replies · 2 participants
  • d

    dwursteisen

    04/25/2019, 4:21 PM
    If your dependencies are marked with the
    implementation
    nor
    api
    configuration, those would not be available with
    configurations.compile
    n
    4 replies · 2 participants
  • n

    Nezteb

    04/25/2019, 4:25 PM
    Is it possible to add random print statements to gradle tasks?
    tasks {
        jar {
            archiveName = "onboarding.jar"
            println("Hello world")
            }
        }
    }
    This compiles just fine, but doesn’t print for me, so I assume not.
    c
    7 replies · 2 participants
  • n

    Nezteb

    04/25/2019, 6:00 PM
    Is the order of the various blocks important? ie.
    tasks {...}
    coming before/after
    dependencies {...}
    ?
    o
    g
    7 replies · 3 participants
  • n

    Nezteb

    04/25/2019, 6:43 PM
    I recall there being a way to separate out dependency declarations from
    build.gradle
    into a separate file
    dependencies.gradle
    . Is it as simple as just copy-pasting the entire
    dependencies { ... }
    block into the new file and it just magically works?
    o
    g
    3 replies · 3 participants
  • j

    Justin Ryan

    04/26/2019, 5:51 PM
    Has anyone had luck with writing a kotlin subplugin with Gradle's TestKit? They don't seem to be happy together, because of the ServiceLoader logic that SubpluginEnvironment does with class loaders. I see that even Kotlin's tests don't use TestKit. 😞 I'd love to have a TestKit based test for a compiler plugin I'm writing.
    e
    s
    16 replies · 3 participants
  • s

    snowe

    04/26/2019, 7:44 PM
    Is it not possible to use kotlin in an
    init.gradle
    script? I'm trying to reference a property using
    by project
    but I get the error message
    Line 1: val ptSnapshotsReaderPassword: String by project
                                                       ^ Function invocation 'project(...)' expected
    e
    30 replies · 2 participants
  • p

    pajatopmr

    04/28/2019, 7:03 PM
    I am attempting to revive using Jacoco in a Kotlin multiplatform project. It is worse than pulling teeth, given that 1) there is no Java or Application plugin in use that defines “jacocoTestReport”, 2) I am using Kotlin DSL so creating the task “jacocoTestReport” is non-trivial (for me anyway), 3) I am using Kotlin test (not Junit) which I’m guessing does not support Jacoco, and 4) the GooglePlex, Stack Overflow, Medium, etc. all are coming up empty for a simple example that illustrates what needs to be done. I would not be surprised at all to learn that it is even more complicated. In any case, a link to a project that has worked around the constraints I described would be much appreciated. Additional insight will also likely be invaluable.
    g
    l
    +1
    48 replies · 4 participants
  • j

    janvladimirmostert

    04/29/2019, 8:36 AM
    I'm trying to force a maven package structure with my gradle build script since the new package layout seems to break certain libraries, or at least, it seems they're not picking up configs that's sitting inside src/main/resources The maven package layout basically dumps java, kotlin and resources content directly into the classes directory whereas gradle splits it into classes/kotlin/main, classes/java/main and resources/main
    sourceSets {
    	main {
    		java {
    			setSrcDirs(listOf("src/main/java"))
    			outputDir = File("build/classes")
    		}
    		withConvention(KotlinSourceSet::class) {
    			kotlin.setSrcDirs(listOf("src/main/kotlin"))
    			kotlin.outputDir = File("build/classes")
    		}
    		resources {
    			setSrcDirs(listOf("src/main/resources"))
    			outputDir = File("build/classes")
    		}
    	}
    	test {
    
    	}
    }
    The Java one works perfectly, the resources one doesn't do anything and the Kotlin one i'm not sure how to configure.
    g
    27 replies · 2 participants
  • s

    Stephan Schroeder

    04/29/2019, 11:16 AM
    This is probably a standard newbie question (but the only solution i found so far used [buildSrc](

    https://www.youtube.com/watch?v=mAtrEPeAJSc&t=1710▾

    ) which I couldn’t make to work0, so how can I externalise the version information using KotlinDSL so I don’t have to retype the same String? The naive approach is along the lines of
    val kotlinVersion = "1.3.21"
    
    plugins {
        kotlin("jvm") version kotlinVersion
        ...
    }
    
    dependencies {
        ...
        testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlinVersion")
    }
    But this fails (“String can’t be called from this context by implicit receiver”) for the usage in plugins.
    y
    g
    +1
    11 replies · 4 participants
  • s

    Stephan Schroeder

    04/29/2019, 5:15 PM
    so I got a local plugin that my other project just can’t seem to find (with the local maven repository):
    group = "uk.co.mulecode"
    version = "1.0.0-SNAPSHOT"
    
    ...
    
    gradlePlugin {
        plugins {
            create("easy-scm") {
                id = "uk.co.mulecode.easy-scm"
                implementationClass = "uk.co.mulecode.EasyScm"
            }
        }
    }
    after running
    gradle install
    I can find it in /Users/MDuke/.m2/repository/uk/co/mulecode/easy-scm/1.0.0-SNAPSHOT/easy-scm-1.0.0-SNAPSHOT.jar. Still when trying to use it in another project by importing it locally
    buildscript {
        repositories {
            mavenLocal()
    //        mavenCentral()
        }
        dependencies {
    //        classpath("uk.co.mulecode:easy-scm:1.0.0-SNAPSHOT")
    //        classpath("uk.co.mulecode:uk.co.mulecode.easy-scm:1.0.0-SNAPSHOT")
            classpath(group = "uk.co.mulecode", name="easy-scm", version = "1.0.0-SNAPSHOT")
        }
    }
    
    plugins {
        id("java")
        id("maven")
        id("uk.co.mulecode.easy-scm") version "1.0.0-SNAPSHOT"
    }
    ...
    it isn’t found, as can be seen by running `gradle tasks`:
    FAILURE: Build failed with an exception.
    
    * Where:
    Build file '/Users/SSchrod/progs/progtests/sandbox-project/build.gradle.kts' line: 12
    
    * What went wrong:
    Plugin [id: 'uk.co.mulecode.easy-scm', version: '1.0.0-SNAPSHOT'] was not found in any of the following sources:
    
    - Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
    - Plugin Repositories (could not resolve plugin artifact 'uk.co.mulecode.easy-scm:uk.co.mulecode.easy-scm.gradle.plugin:1.0.0-SNAPSHOT')
      Searched in the following repositories:
        Gradle Central Plugin Repository
    the artifact path looks pretty messed up but I just can’t figure out what the problem is. To add insult to injury importing of the plugin actually works from an equivalent Groovy-DSL gradle project.
    o
    e
    4 replies · 3 participants
  • n

    Nezteb

    05/01/2019, 1:33 AM
    Is there a similar thing in Gradle as Maven’s Archetypes? Basically pre-made project templates with boilerplate?
    t
    3 replies · 2 participants
  • k

    kluck

    05/02/2019, 9:01 AM
    Hi, I'm setting up a simple android app to test the gradle kotlin DSL. I have an app module with this setting (simplified version):
    plugins {
        id("com.android.application")
        id("kotlin-android")
        id("kotlin-android-extensions")
    }
    android {
        [...]
    }
    dependencies {
        implementation(kotlin("stdlib-jdk8"))
        implementation(project(":domain"))
        implementation(project(":presentation"))
        [...]
    }
    I have two other modules: one is
    domain
    which is a basic kotlin module (
    plugins { kotlin("jvm") }
    ), and the other one is
    presentation
    , which is an android library:
    plugins {
        id("com.android.library")
    }
    android {
        [...]
    }
    dependencies {
        implementation(kotlin("stdlib-jdk8"))
        implementation(project(":domain"))
        [...]
    }
    In the IDE, everything works fine. But when I'm trying to launch a build, I get weird
    unresolved reference
    issues only on the
    presentation
    module. Do you know where the problem can come from?
    d
    i
    3 replies · 3 participants
  • w

    wakingrufus

    05/03/2019, 2:09 PM
    heh, i was trying that last week, and gave up (specifically maven central publish)
    s
    s
    +1
    3 replies · 4 participants
  • l

    louiscad

    05/03/2019, 7:03 PM
    @SrSouza @wakingrufus I have an example that publishes to mavenLocal and bintray (for jcenter, which can sync to mavenCentral) for Android, JVM and JS. Should I link it?
    ❤️ 1
    s
    2 replies · 2 participants
  • d

    darkmoon_uk

    05/04/2019, 8:02 AM
    oh come on... why is
    apply { from(...) }
    not available in
    buildscript
    section - obviously I might want to apply some common configuration from a file at the earliest point of evaluation. Are the Gradle authors trying to be awkward?? 😠
    o
    d
    9 replies · 3 participants
  • j

    jdiaz

    05/04/2019, 2:59 PM
    Has anyone seen
    Could not find org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.3.21
    ? I'm just trying to update to Gradle 5.4 (and have a buildSrc project)
    l
    g
    4 replies · 3 participants
  • i

    ianbrandt

    05/06/2019, 4:54 AM
    I'm trying to create a Kotlin convention script plugin similar to the Java one in Example 19 here: https://docs.gradle.org/current/userguide/kotlin_dsl.html#sec:kotlin-dsl_plugin Project: https://github.com/ianbrandt/multi-kotlin-project Code: https://github.com/ianbrandt/multi-kotlin-project/blob/49cdae7f3f782af51d9d511b994b0fb412d9a8d5/buildSrc/src/main/kotlin/kotlin-project.gradle.kts I'm getting the following errors:
    > Task :buildSrc:compileKotlin FAILED
    e: multi-kotlin-project/buildSrc/src/main/kotlin/kotlin-project.gradle.kts: (2, 22): Unresolved reference: kotlin
    e: multi-kotlin-project/buildSrc/src/main/kotlin/kotlin-project.gradle.kts: (9, 2): Unresolved reference: implementation
    e: multi-kotlin-project/buildSrc/src/main/kotlin/kotlin-project.gradle.kts: (13, 11): Unresolved reference: KotlinCompile
    e: multi-kotlin-project/buildSrc/src/main/kotlin/kotlin-project.gradle.kts: (13, 26): Type mismatch: inferred type is () -> TypeVariable(_L) but Class<TypeVariable(S)> was expected
    e: multi-kotlin-project/buildSrc/src/main/kotlin/kotlin-project.gradle.kts: (14, 3): Unresolved reference: kotlinOptions
    The intent is to have a multi-project build where standardized Kotlin, Java, etc. plugins and configuration can be mixed into child projects as needed. Any ideas as to what I'm doing wrong?
    m
    2 replies · 2 participants
  • m

    mkobit

    05/07/2019, 1:00 PM
    is anyone familiar with any open issues to gradle core or on youtrack for intellij freezing on changes to
    buildSrc
    code? im struggling to find anything right now
    l
    s
    +1
    8 replies · 4 participants
  • k

    kevin.cianfarini

    05/08/2019, 3:56 PM
    Can someone point me in the right direction?
    s
    103 replies · 2 participants
  • x

    x80486

    05/09/2019, 10:47 PM
    …but somehow,
    from(compileJava)
    is not working. Any advice?
    c
    g
    21 replies · 3 participants
  • t

    Thomas Oddsund

    05/13/2019, 8:57 AM
    Hello! How can I apply a plugin that is only available through another plugin? The case is one jar containing all plugins, and explanation in comments 👇
    w
    4 replies · 2 participants
  • b

    Bernhard

    05/13/2019, 2:28 PM
    how do I set the main class name when I use spring boot?
    s
    1 reply · 2 participants
  • s

    snowe

    05/14/2019, 5:06 PM
    Looking at the nebula-kotlin project, I can see they do some magic in order to allow you to specify any kotlin version and have it apply that kotlin dependency. what is not obvious to me is if that same logic applies to the
    apply
    of the kotlin plugin. I can't parse whether the apply works because they increment the nebula-kotlin version whenever a new kotlin version is released, or if it works because of the
    configurations
    block that changes the resolution strategy. https://github.com/nebula-plugins/nebula-kotlin-plugin/blob/master/src/main/kotlin/netflix/nebula/NebulaKotlinPlugin.kt
    g
    10 replies · 2 participants
  • b

    Benjamin Charais

    05/15/2019, 5:24 PM
    Hello all, I am working on putting together a project that has at it’s core 2 android apps and an IOS app supported via kotlin native. I have been struggling with the gradle portion, combine with getting the project itself to be nice and clean. Largely the biggest hurdle comes from having 2 android apps living in the same project it seems to mess with gradle. I’ve also been struggling with getting the project itself have a nice structure without 10 top level modules, 1 for each app and common, plus a test for each. I’d love to be able to ask some questions about people’s experience on this front if possible
    s
    c
    7 replies · 3 participants
  • e

    egorand

    05/17/2019, 5:41 PM
    not strictly Kotlin-related, but has anybody noticed any differences in how Gradle metadata handles snapshots? I’ve published a snapshot of a Kotlin multiplatform library two days ago, and my build that depends on that library still can’t pick it up unless I use
    --refresh-dependencies
    m
    b
    4 replies · 3 participants
  • a

    adalbert

    05/17/2019, 8:53 PM
    Have you used JOOQ with Gradle and Kotlin ? Is it possible to generate nullsafety code?
    n
    4 replies · 2 participants
  • m

    mingkangpan

    05/19/2019, 11:51 AM
    allprojects {
        repositories {
            mavenCentral()
            jcenter()
        }
    }
    
    plugins {
        kotlin("jvm") version "1.3.31"
    }
    r
    3 replies · 2 participants
Powered by Linen
Title
m

mingkangpan

05/19/2019, 11:51 AM
allprojects {
    repositories {
        mavenCentral()
        jcenter()
    }
}

plugins {
    kotlin("jvm") version "1.3.31"
}
r

robnik

05/19/2019, 1:24 PM
@mingkangpan I'm struggling with this now too, so I don't know if this is right, but you could try a
buildscript
section. I have this at top level:
buildscript {    
    repositories {
        jcenter()
    }
    dependencies {
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.31")
        classpath("org.jetbrains.kotlin:kotlin-serialization:1.3.31")
    }
}
I think the idea is that the dependencies and repositories of the buildscript itself are handled separately from the dependencies and repositories of your project code.
m

mingkangpan

05/19/2019, 8:54 PM
checkout my repository: https://github.com/willhaben/kotlindsl I got it running, but now I am struggling with setting up an andorid module
View count: 11