Kotlin / kotlin-frontend-plugin

Gradle Kotlin (http://kotlinlang.org) plugin for frontend development
Apache License 2.0
564 stars 69 forks source link

Multi-platform builds fail with kotlin-platform-js #20

Open jan-auer opened 7 years ago

jan-auer commented 7 years ago

When used together with kotlin-platform-js in a multi-platform build setup, this plugin causes a build error:

A problem occurred evaluating project ':frontend'.
> Platform project project ':frontend' implements non-common project project ':common' (`apply plugin 'kotlin-platform-kotlin'`)

Our configuration of the frontend submodule:

buildscript {
    ext.kotlin_version = '1.1.4-3'

    repositories {
        mavenCentral()
        maven {
            url "https://dl.bintray.com/kotlin/kotlin-eap"
        }
        maven {
            url "https://repo.gradle.org/gradle/libs-releases-local"
        }
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.kotlin:kotlin-frontend-plugin:0.0.21"
    }
}

apply plugin: 'org.jetbrains.kotlin.frontend'
apply plugin: 'kotlin-platform-js'

repositories {
    mavenCentral()
}

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
    implement project(":common")
}

For reference, here are the top frames of the exception stacktrace:

Caused by: org.gradle.api.GradleException: Platform project project ':frontend' implements non-common project project ':common' (`apply plugin 'kotlin-platform-kotlin'`)
        at org.jetbrains.kotlin.gradle.plugin.KotlinPlatformImplementationPluginBase$addCommonProject$1.invoke(KotlinMultiplatformPlugin.kt:69)
        at org.jetbrains.kotlin.gradle.plugin.KotlinPlatformImplementationPluginBase$addCommonProject$1.invoke(KotlinMultiplatformPlugin.kt:38)
        at org.jetbrains.kotlin.gradle.plugin.KotlinMultiplatformPluginKt.whenEvaluated(KotlinMultiplatformPlugin.kt:103)
        at org.jetbrains.kotlin.gradle.plugin.KotlinMultiplatformPluginKt.access$whenEvaluated(KotlinMultiplatformPlugin.kt:1)
        at org.jetbrains.kotlin.gradle.plugin.KotlinPlatformImplementationPluginBase.addCommonProject(KotlinMultiplatformPlugin.kt:67)
        at org.jetbrains.kotlin.gradle.plugin.KotlinPlatformImplementationPluginBase.access$addCommonProject(KotlinMultiplatformPlugin.kt:38)
        at org.jetbrains.kotlin.gradle.plugin.KotlinPlatformImplementationPluginBase$apply$3.execute(KotlinMultiplatformPlugin.kt:53)
        at org.jetbrains.kotlin.gradle.plugin.KotlinPlatformImplementationPluginBase$apply$3.execute(KotlinMultiplatformPlugin.kt:38)
        ...
jan-auer commented 7 years ago

Looks like this issue is not related to kotlin-frontend-plugin but rather to kotlin-platform-js. Moving all buildscript code to the root gradle file seems to solve this issue.