diff --git a/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/GradleFacetImportTest.kt b/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/GradleFacetImportTest.kt index 70c6d7199f3..68b5aa9dd29 100644 --- a/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/GradleFacetImportTest.kt +++ b/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/GradleFacetImportTest.kt @@ -28,6 +28,7 @@ import com.intellij.openapi.roots.impl.libraries.LibraryEx import com.intellij.openapi.util.text.StringUtil import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments +import org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments import org.jetbrains.kotlin.config.* import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCommonCompilerArgumentsHolder import org.jetbrains.kotlin.idea.configuration.ConfigureKotlinStatus @@ -1656,6 +1657,80 @@ compileTestKotlin { assertAllModulesConfigured() } + @Test + fun testCommonArgumentsImport() { + createProjectSubFile("build.gradle", """ + group 'Again' + version '1.0-SNAPSHOT' + + buildscript { + repositories { + mavenCentral() + maven { + url 'http://dl.bintray.com/kotlin/kotlin-eap-1.2' + } + } + + dependencies { + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.0-rc-39") + } + } + + apply plugin: 'kotlin-platform-common' + + repositories { + mavenCentral() + maven { + url 'http://dl.bintray.com/kotlin/kotlin-eap-1.2' + } + } + + dependencies { + compile "org.jetbrains.kotlin:kotlin-stdlib-common:1.2.0-rc-39" + } + + compileKotlinCommon{ + kotlinOptions { + languageVersion = 1.1 + apiVersion = 1.0 + freeCompilerArgs += ["-cp", "my/classpath"] + freeCompilerArgs += ["-d", "my/destination"] + } + } + + compileTestKotlinCommon{ + kotlinOptions { + languageVersion = 1.1 + apiVersion = 1.0 + freeCompilerArgs += ["-cp", "my/test/classpath"] + freeCompilerArgs += ["-d", "my/test/destination"] + } + } + + """) + importProject() + + with (facetSettings) { + Assert.assertEquals("1.1", languageLevel!!.versionString) + Assert.assertEquals("1.0", apiLevel!!.versionString) + Assert.assertEquals(TargetPlatformKind.Common, targetPlatformKind) + Assert.assertEquals("my/classpath", (compilerArguments as K2MetadataCompilerArguments).classpath) + Assert.assertEquals("my/destination", (compilerArguments as K2MetadataCompilerArguments).destination) + } + + with (facetSettings("project_test")) { + Assert.assertEquals("1.1", languageLevel!!.versionString) + Assert.assertEquals("1.0", apiLevel!!.versionString) + Assert.assertEquals(TargetPlatformKind.Common, targetPlatformKind) + Assert.assertEquals("my/test/classpath", (compilerArguments as K2MetadataCompilerArguments).classpath) + Assert.assertEquals("my/test/destination", (compilerArguments as K2MetadataCompilerArguments).destination) + } + + val rootManager = ModuleRootManager.getInstance(getModule("project_main")) + val stdlib = rootManager.orderEntries.filterIsInstance().single().library + assertEquals(CommonLibraryKind, (stdlib as LibraryEx).kind) + } + private fun assertAllModulesConfigured() { runReadAction { for (moduleGroup in ModuleSourceRootMap(myProject).groupByBaseModules(myProject.allModules())) { diff --git a/idea/kotlin-gradle-tooling/src/KotlinGradleModelBuilder.kt b/idea/kotlin-gradle-tooling/src/KotlinGradleModelBuilder.kt index 1527715171f..f9eda649bbf 100644 --- a/idea/kotlin-gradle-tooling/src/KotlinGradleModelBuilder.kt +++ b/idea/kotlin-gradle-tooling/src/KotlinGradleModelBuilder.kt @@ -62,7 +62,8 @@ class KotlinGradleModelImpl( abstract class AbstractKotlinGradleModelBuilder : ModelBuilderService { companion object { val kotlinCompileTaskClasses = listOf("org.jetbrains.kotlin.gradle.tasks.KotlinCompile_Decorated", - "org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile_Decorated") + "org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile_Decorated", + "org.jetbrains.kotlin.gradle.tasks.KotlinCompileCommon_Decorated") val platformPluginIds = listOf("kotlin-platform-jvm", "kotlin-platform-js", "kotlin-platform-common") val pluginToPlatform = linkedMapOf( "kotlin" to "kotlin-platform-jvm", diff --git a/idea/src/org/jetbrains/kotlin/idea/facet/KotlinFacetEditorGeneralTab.kt b/idea/src/org/jetbrains/kotlin/idea/facet/KotlinFacetEditorGeneralTab.kt index fc2205555fe..41070fa3641 100644 --- a/idea/src/org/jetbrains/kotlin/idea/facet/KotlinFacetEditorGeneralTab.kt +++ b/idea/src/org/jetbrains/kotlin/idea/facet/KotlinFacetEditorGeneralTab.kt @@ -170,6 +170,7 @@ class KotlinFacetEditorGeneralTab( val fieldNamesToCheck = when (platform) { is TargetPlatformKind.Jvm -> jvmUIExposedFields is TargetPlatformKind.JavaScript -> jsUIExposedFields + is TargetPlatformKind.Common-> metadataUIExposedFields else -> commonUIExposedFields } diff --git a/idea/src/org/jetbrains/kotlin/idea/facet/facetUtils.kt b/idea/src/org/jetbrains/kotlin/idea/facet/facetUtils.kt index 229c27e6248..04ae7da78d3 100644 --- a/idea/src/org/jetbrains/kotlin/idea/facet/facetUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/facet/facetUtils.kt @@ -252,10 +252,16 @@ private val jsSpecificUIExposedFields = listOf(K2JSCompilerArguments::sourceMap. val jsUIExposedFields = commonUIExposedFields + jsSpecificUIExposedFields private val jsPrimaryFields = commonPrimaryFields + jsSpecificUIExposedFields +private val metadataSpecificUIExposedFields = listOf(K2MetadataCompilerArguments::destination.name, + K2MetadataCompilerArguments::classpath.name) +val metadataUIExposedFields = commonUIExposedFields + metadataSpecificUIExposedFields +private val metadataPrimaryFields = commonPrimaryFields + metadataSpecificUIExposedFields + private val CommonCompilerArguments.primaryFields: List get() = when (this) { is K2JVMCompilerArguments -> jvmPrimaryFields is K2JSCompilerArguments -> jsPrimaryFields + is K2MetadataCompilerArguments -> metadataPrimaryFields else -> commonPrimaryFields }