Kotlin Facet: Support compileKotlinCommon tasks in Gradle importer
#KT-21187 Fixed
This commit is contained in:
+75
@@ -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<LibraryOrderEntry>().single().library
|
||||
assertEquals(CommonLibraryKind, (stdlib as LibraryEx).kind)
|
||||
}
|
||||
|
||||
private fun assertAllModulesConfigured() {
|
||||
runReadAction {
|
||||
for (moduleGroup in ModuleSourceRootMap(myProject).groupByBaseModules(myProject.allModules())) {
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -170,6 +170,7 @@ class KotlinFacetEditorGeneralTab(
|
||||
val fieldNamesToCheck = when (platform) {
|
||||
is TargetPlatformKind.Jvm -> jvmUIExposedFields
|
||||
is TargetPlatformKind.JavaScript -> jsUIExposedFields
|
||||
is TargetPlatformKind.Common-> metadataUIExposedFields
|
||||
else -> commonUIExposedFields
|
||||
}
|
||||
|
||||
|
||||
@@ -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<String>
|
||||
get() = when (this) {
|
||||
is K2JVMCompilerArguments -> jvmPrimaryFields
|
||||
is K2JSCompilerArguments -> jsPrimaryFields
|
||||
is K2MetadataCompilerArguments -> metadataPrimaryFields
|
||||
else -> commonPrimaryFields
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user