not sure if this is more gradle or not, but will t...
# gradle
r
not sure if this is more gradle or not, but will try here first 🙂 please feel free to redirect me if this is the wrong place in a gradle multiproject setup, I'm trying to make some shared configurations for the
kotlin
block, but it seems I cannot use it in the
subprojects
(or
allprojects
) block for some reason one of the things I'm trying to do is: /build.gradle.kts
Copy code
subprojects {
    kotlin {
        publishing {
            // ... removed for readability
        }
    }
}
I tried adding the
_kotlin_("multiplatform") _version_ kotlinVersion
in /build.gradle.kts in the
plugins
section both with and without applying it to no avail how do I make a shared configuration?
v
It's not really the right place, not, as this is just for usage of Kotlin in Kotlin DSL build scripts. 🙂 But anyway, any usage of
allprojects { ... }
or
subprojects { ... }
is a code smell for various reasons and should be avoided. You should instead use convention plugins to share build logic.
a
aside from
subprojects {}
being a difficult + problem-laden way of sharing build config, something that looks unusual to me is nesting the
publishing {}
block inside of the
kotlin {}
block. The publishing config isn’t connected to the Kotlin config, so it doesn’t make sense to put one inside the other.
r
@Vampire ok, will look at that, I'm always up for better ways, thanks a lot 🙂
a
this q&a might be what you’re after? https://stackoverflow.com/q/71883613/4161471
r
@Adam S true, I cannot help to agree with you there - it's just what I've seen on the pages I found - which as usual means that too much of the posted stuff out there it to be taken with a grain of salt 😞 thanks, that's another pitfall to avoid in the future 😉
a
yeah, it’s not fun trying to find out the best Gradle config… there’s a lot of hacks and workarounds floating around!
r
tell me about it, took quite a lot to get even where I am now, and I'm far from happy even though it's working 😞 hopefully, I'll get one step closer with what you provided
a
you can also ask all things Gradle in the Gradle Slack channel, if you’re not there already https://gradle.org/slack-invite
r
will remember that, it's probably not the last question I'll want to ask (I hope not 😉 ) and of course it's inheritance... for some reason I never considered that - shame on me 😉