Thread
#multiplatform
    m

    Marc Reichelt

    7 months ago
    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…
    Grégory Lureau

    Grégory Lureau

    7 months ago
    Yes, using this
    import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
    and
    fun Project.defaultKMPConfig() {
        val kotlin = project.extensions.getByName<KotlinMultiplatformExtension>("kotlin")
        kotlin.apply { ...
    m

    Marc Reichelt

    7 months ago
    That would be nice - but already the import fails on my machine
    My
    buildSrc/build.gradle.kts
    looks like this:
    plugins {
        `kotlin-dsl`
    }
    
    repositories {
        mavenCentral()
    }
    
    dependencies {
        implementation(gradleApi())
    }
    Grégory Lureau

    Grégory Lureau

    7 months ago
    oh yes, I forget to mention this:
    dependencies {
        implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
        ....
    I also have
    `java-gradle-plugin`
    in plugins, not sure it's relevant here
    m

    Marc Reichelt

    7 months ago
    in which file do you have the dependency @Grégory Lureau?
    If I add that in
    buildSrc/build.gradle.kts
    , I’ll get:
    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 😕
    Grégory Lureau

    Grégory Lureau

    7 months ago
    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

    Marc Reichelt

    7 months ago
    it seems so (I’m on Arctic Fox right now, have to try Bumblebee next)
    Grégory Lureau

    Grégory Lureau

    7 months ago
    good luck!
    m

    Marc Reichelt

    7 months ago
    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! 👏