Joost Klitsie
06/15/2020, 7:37 PMfun DependencyHandlerScope.implementKtorServer(flavor: String = "") {
implementation(ktor(Serialization), flavor)
//.... others...
implementation(ktor(AuthJwt), flavor)
}
In this way, I can easily call this from my build.gradle.kts for the backend module
dependencies {
implementKtorServer()
// ... other things
This is because the dependencies in a Gradle file give you a DependencyHandlerScope context. However, with multiplatform, like this:
val commonMain by getting {
dependencies {
// ... stuff
You have a KotlinDependencyHandler
context. So my question is: How can I make an extension function in my buildSrc module on a KotlinDependencyHandler? I tried to pull in some kotlin gradle plugin dependencies in my buildSrc/build.gradle.kts but no luck. For now, it looks like this:
plugins {
`kotlin-dsl`
}
repositories {
jcenter()
}
And KotlinDependencyHandler
is until now unresolved 😞 Does anyone know what I could do here?araqnid
06/15/2020, 7:48 PMdependencies{}
block for multiplatform projects too, using commonMainApi
, commonMainImplementation
etc configurations. But in build.gradle.kts, you need to quote the configuration names as they are not declared early enough for the accessor generationaraqnid
06/15/2020, 7:49 PMJoost Klitsie
06/16/2020, 12:10 PMJoost Klitsie
06/16/2020, 12:10 PMJoost Klitsie
06/16/2020, 12:16 PMdependencies {
implementKtorClientCommon("commonMain")
}
This indeed worksJoost Klitsie
06/16/2020, 12:16 PMprivate fun DependencyHandler.implementation(dependency: Any, flavor: String) {
val configurationName = flavor.takeIf { it.isNotBlank() }?.let {
"${it}Implementation"
} ?: "implementation"
add(configurationName, dependency)
}
Joost Klitsie
06/16/2020, 12:56 PMjvmMainImplementation
and only around the jvmMain
part but it failsaraqnid
06/16/2020, 1:08 PMdependencies{}
to after the kotlin mp configuration in the build fileJoost Klitsie
06/16/2020, 1:19 PM