Hi there! Did anyone manage to import `KotlinMulti...
# multiplatform
m
Hi there! Did anyone manage to import
KotlinMultiplatformExtension
into their
buildSrc
folder? I’m trying to write some logic to make it easier for multiple targets to configure ios targets + tests…
1
g
Yes, using this
Copy code
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
and
Copy code
fun Project.defaultKMPConfig() {
    val kotlin = project.extensions.getByName<KotlinMultiplatformExtension>("kotlin")
    kotlin.apply { ...
👀 2
m
That would be nice - but already the import fails on my machine
My
buildSrc/build.gradle.kts
looks like this:
Copy code
plugins {
    `kotlin-dsl`
}

repositories {
    mavenCentral()
}

dependencies {
    implementation(gradleApi())
}
g
oh yes, I forget to mention this:
Copy code
dependencies {
    implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
    ....
I also have
Copy code
`java-gradle-plugin`
in plugins, not sure it's relevant here
m
in which file do you have the dependency @Grégory Lureau?
If I add that in
buildSrc/build.gradle.kts
, I’ll get:
Copy code
org.gradle.internal.exceptions.LocationAwareException: Build file '/Users/username/someproject/build.gradle.kts' line: 18
Error resolving plugin [id: 'org.jetbrains.kotlin.multiplatform', version: '1.5.31']
if I resolve all the errors (by removing the specific
1.5.31
version in the other build gradle files) then it at least syncs, but the import in
buildSrc
still doesn’t work
Oh, damn - I just found out that indeed the code works, but Android Studio shows the import as working (but command line compiles the import successfully)
Tooling is broken 😕
g
My path is
buildSrc/build.gradle.kts
like yours, I don't have this issue, but I'm on IntelliJ Community, so I suppose AS doesn't support this ?!
m
it seems so (I’m on Arctic Fox right now, have to try Bumblebee next)
g
good luck!
m
Actually, you already helped me a lot @Grégory Lureau - the code works, I just didn’t know that it did (because studio was showing errors). Maybe In can get this further in the next weeks., Thank you! 👏
👍 1