https://kotlinlang.org logo
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
benchmarks
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
confetti
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
lincheck
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
Title
d

dwursteisen

10/09/2018, 8:49 AM
Hey. We trying to migrate our groovy gradle build to Kotlin DSL. But we get an issue and don’t understand how to deal with it: we have a
subproject
block with a
dependencies
block inside. We’re trying to call the method
compile
in it but IntelliJ don’t find it. We missing something but we don’t see what. Have you got any idea about this?
subprojects {
   dependencies {
         compile("our dependency")
   }
}
I presume that something is missing in our scope so
compile
extension method is not available.
t

tapchicoma

10/09/2018, 8:56 AM
try
"compile"("our dependency")
d

dwursteisen

10/09/2018, 9:03 AM
yeah. it works but we’re not “super super” happy about that: sometime, we’re using
compile
, and so in other part we may use
"compile"
😫
r

ribesg

10/09/2018, 9:07 AM
I'm not a pro in Gradle, but aren't you supposed to use
implementation
?
Maybe
compile
does not work properly in kotlin-dsl because kotlin-dsl is new, and
compile
is an old, long-time deprecated thing
t

tapchicoma

10/09/2018, 9:10 AM
I think migrating to new plugin dsl should solve this issue
using
classpath
approach leads that you have to use either
"compile"
or
"implementation"
c

Czar

10/09/2018, 9:11 AM
Can you show us more of the build file?
compile
should be there if you have
java
or
java-library
plugin properly applied
d

dwursteisen

10/09/2018, 9:22 AM
yes I can. I just updated some dependencies name.
buildscript {
    val commit by extra { Git.commit() }

    repositories {
        mavenLocal()
        maven { url = uri("<https://plugins.gradle.org/m2/>") }
        maven { url = uri("<https://repo.spring.io/libs-milestone>") }
    }

    dependencies {
        classpath("org.unbroken-dome.gradle-plugins:gradle-testsets-plugin:${Versions.test_sets}")
        classpath("com.internal.plugins.OurPlugin:1.2.3")
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${Versions.springboot}")
        classpath("com.google.protobuf:protobuf-gradle-plugin:${Versions.protobuf_plugin}")
    }
}

subprojects {
    apply(plugin = "OurPlugin")

    tasks.withType(Test::class).configureEach {
        reports {
            html.isEnabled = false
            junitXml.isEnabled = false
        }
        val processors = Runtime.getRuntime().availableProcessors()
        maxParallelForks = when {
            (project.name == "web") -> 1
            (processors <= 1) -> 1
            else -> processors / 2
        }
    }

    dependencies {
        "compile"("a_dependency:${Versions.margo_commons}")
    }
}
(for information:
OurPlugin
apply the plugin
kotlin
and other plugin but not
java
or
java-library
)
t

tapchicoma

10/09/2018, 9:24 AM
Try to migrate this:
dependencies {
        classpath("org.unbroken-dome.gradle-plugins:gradle-testsets-plugin:${Versions.test_sets}")
        classpath("com.internal.plugins.OurPlugin:1.2.3")
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${Versions.springboot}")
        classpath("com.google.protobuf:protobuf-gradle-plugin:${Versions.protobuf_plugin}")
    }
}
to new plugin api: https://docs.gradle.org/current/userguide/plugins.html#sec:plugins_block
c

Czar

10/09/2018, 9:29 AM
buildscript
is deprecated in kotlin-dsl as a plugins configuration mechanism, you have to declare plugins in
plugins {}
block for static accessors to be generated.
g

gildor

10/09/2018, 10:03 AM
I would recommend to read official migration guide: https://guides.gradle.org/migrating-build-logic-from-groovy-to-kotlin/ It covers exactly this topic (see “Configurations and dependencies” part)
👍 2
Note that if you do not use the plugins {} block to apply your plugins, then you won’t be able to configure the dependency configurations provided by those plugins in the usual way. Instead, you will have to use string literals for the configuration names, which means you won’t get IDE support
👍 2
d

dwursteisen

10/09/2018, 10:14 AM
We went a bit too quickly on the migration 😁 we will migrate it a bit later. Thanks
n

Nikky

10/09/2018, 10:39 AM
is there any reason to keep using the buildscript + classpath approach ? plugins block and pluginManagement block is much cleaner, and i have yet to find something that forces me to use the classpath stuff
r

ribesg

10/09/2018, 10:40 AM
Android.
g

gildor

10/09/2018, 10:40 AM
Android is not a reason, you can use plugins dsl with Android
n

Nikky

10/09/2018, 10:40 AM
is the android plugin not possible to apply throug the plugins block or is it just on a custom repository ?
g

gildor

10/09/2018, 10:41 AM
Android Plugin is not published to Gradle Plugins portal
n

Nikky

10/09/2018, 10:41 AM
pluginManagement {
    repositories {
        //        maven { setUrl("<http://dl.bintray.com/kotlin/kotlin-eap>") }
        maven { url = uri("<https://kotlin.bintray.com/kotlinx>") }
        mavenLocal()
        gradlePluginPortal()
    }
    resolutionStrategy {
        eachPlugin {
            if (requested.id.id == "kotlinx-serialization") {
                useModule("org.jetbrains.kotlinx:kotlinx-gradle-serialization-plugin:${requested.version}")
            }
        }
    }
}
g

gildor

10/09/2018, 10:41 AM
but you can use resolutionManagement
yes, exactly
it’s actually shame that they didn’t publish Android Gradle plugin, at least to google repo
1
n

Nikky

10/09/2018, 10:43 AM
this is for kotlinx.serialization which is also not on gradlePluginPortal and does not have the right maven coordinates to be picked up automatically
g

gildor

10/09/2018, 10:44 AM
n

Nikky

10/09/2018, 10:54 AM
also for your internal plugin, gradle supports -SNAPSHOT versions deploying the plugin to mavenLocal and then testing it i na seperate project work really well for my plugin as well as deploying a snapshot version that points at the latest build so i do not have to constantly adjust buildnumbers
g

gildor

10/09/2018, 10:57 AM
For local plugin development I would prefer composite builds than publishing to local maven
1
n

Nikky

10/09/2018, 11:04 AM
composite builds ? i did not hear that term before
n

Nikky

10/09/2018, 11:05 AM
gotta read up on that. seems like my way is needlessly overcomplicated
t

tapchicoma

10/09/2018, 11:05 AM
theoretically you can also use now this new git dependency, so you don't need publish to maven local
n

Nikky

10/09/2018, 11:07 AM
well that only works once its pushed to git.. not for changes on my machine
g

gildor

10/09/2018, 11:09 AM
Yes, source dependencies are very similar to composite builds, but for local development composite builds are just enough and also have features for now
t

tapchicoma

10/09/2018, 11:09 AM
should be possible to use with local git:
gitRepository("/path/to/git/repo/.git")
g

gildor

10/09/2018, 11:10 AM
but why? Composite builds are completely transparent and even do not require config or dependencies changes
t

tapchicoma

10/09/2018, 11:11 AM
I just proposed, personally I am also for composite builds on developing locally, though it may be better to have git dependency when use just consuming plugin without developing it.
g

gildor

10/09/2018, 11:13 AM
yeah, third party plugin is very good use case for source dependenices
Actuall, at the moment source dependencies could be a good solution for some Kotlin/Native or MPP stuff, because allow you to consume common code without tedious publication for all platforms
🤔 1
n

Nikky

10/09/2018, 11:19 AM
do you have any example how i could use compositeBuilds to depend on a subproject of my multiproject setup ?
or do i need to includeBuild the whole subproject and then depend on the subproject ?
g

gildor

10/09/2018, 11:22 AM
You don’t need compositeBuilds for that. if you have regular multimodule project
composite builds make sense only if you want to include another project used as dependency
t

tapchicoma

10/09/2018, 11:25 AM
in one project I've implemented logic that checks: if there is folder under such path - use composite build, otherwise use common dependency. Worked good.
g

gildor

10/09/2018, 11:29 AM
Yes, this will work. We also use another approach. We have
local.settings.gradle
that applied in
settings.gradle
(if local config exists). where you can specify any projects that you want to include also allows to have custom resourceManagement config
n

Nikky

10/09/2018, 11:31 AM
my structure is like so:
root
  - plugin
  - test-plugin
  - libraries + other modules
now i am not sure how i can make test-plugin depend on a plugin registered in plugin..
i think i will stay with completely separate projects and deploying to mavenLocal for now
g

gildor

10/09/2018, 11:38 AM
test-plugin just can use plugin without any publishing, just add it as project dependency
n

Nikky

10/09/2018, 11:39 AM
but that will break when the plugins block in test-plugin gets resolved
g

gildor

10/09/2018, 11:41 AM
Does your test-plugin is subproject or completely separate project?
n

Nikky

10/09/2018, 11:42 AM
it used to be a separate project
now i am trying to integrate it as a subproject
dependencies {
    compile(":plugin")
}

apply {
    plugin("plugin")
}
this seems to not work, cannot find the plugin
ahh you said project dependency.. so that might be where it breaks
i don't quite know how this is supposed to work.. the plugin has to compile between the plugin module getting resolved and the plugin-test module
g

gildor

10/09/2018, 11:53 AM
Yeah, I’m not sure that you can apply one module to another as plugin. If test-plugin is a separate project you can easily use composite builds for that
n

Nikky

10/09/2018, 12:08 PM
thats what i tried at first
in testplugin i did
includeBuild(path to root)
but how do i then compile plugin which is a submodule of root ?
g

gildor

10/09/2018, 4:26 PM
But it will compile all the submodules by default and attach as dependencies