Gradle: Use common language/api version (if any) of all modules for project
#KT-26290 Fixed
This commit is contained in:
committed by
Ilya Gorbunov
parent
c6eaaac877
commit
c7a5a7ebd5
+31
@@ -43,6 +43,7 @@ import org.jetbrains.kotlin.config.TargetPlatformKind
|
|||||||
import org.jetbrains.kotlin.extensions.ProjectExtensionDescriptor
|
import org.jetbrains.kotlin.extensions.ProjectExtensionDescriptor
|
||||||
import org.jetbrains.kotlin.gradle.ArgsInfo
|
import org.jetbrains.kotlin.gradle.ArgsInfo
|
||||||
import org.jetbrains.kotlin.gradle.CompilerArgumentsBySourceSet
|
import org.jetbrains.kotlin.gradle.CompilerArgumentsBySourceSet
|
||||||
|
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCommonCompilerArgumentsHolder
|
||||||
import org.jetbrains.kotlin.idea.facet.*
|
import org.jetbrains.kotlin.idea.facet.*
|
||||||
import org.jetbrains.kotlin.idea.framework.CommonLibraryKind
|
import org.jetbrains.kotlin.idea.framework.CommonLibraryKind
|
||||||
import org.jetbrains.kotlin.idea.framework.JSLibraryKind
|
import org.jetbrains.kotlin.idea.framework.JSLibraryKind
|
||||||
@@ -74,6 +75,36 @@ interface GradleProjectImportHandler {
|
|||||||
fun importByModule(facet: KotlinFacet, moduleNode: DataNode<ModuleData>)
|
fun importByModule(facet: KotlinFacet, moduleNode: DataNode<ModuleData>)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class KotlinGradleProjectSettingsDataService : AbstractProjectDataService<ProjectData, Void>() {
|
||||||
|
override fun getTargetDataKey() = ProjectKeys.PROJECT
|
||||||
|
|
||||||
|
override fun postProcess(
|
||||||
|
toImport: MutableCollection<DataNode<ProjectData>>,
|
||||||
|
projectData: ProjectData?,
|
||||||
|
project: Project,
|
||||||
|
modelsProvider: IdeModifiableModelsProvider
|
||||||
|
) {
|
||||||
|
val allSettings = modelsProvider.modules.mapNotNull {
|
||||||
|
val settings = modelsProvider
|
||||||
|
.getModifiableFacetModel(it)
|
||||||
|
.findFacet(KotlinFacetType.TYPE_ID, KotlinFacetType.INSTANCE.defaultFacetName)
|
||||||
|
?.configuration
|
||||||
|
?.settings ?: return@mapNotNull null
|
||||||
|
if (settings.useProjectSettings) null else settings
|
||||||
|
}
|
||||||
|
val languageVersion = allSettings.asSequence().mapNotNullTo(LinkedHashSet()) { it.languageLevel }.singleOrNull()
|
||||||
|
val apiVersion = allSettings.asSequence().mapNotNullTo(LinkedHashSet()) { it.apiLevel}.singleOrNull()
|
||||||
|
KotlinCommonCompilerArgumentsHolder.getInstance(project).update {
|
||||||
|
if (languageVersion != null) {
|
||||||
|
this.languageVersion = languageVersion.versionString
|
||||||
|
}
|
||||||
|
if (apiVersion != null) {
|
||||||
|
this.apiVersion = apiVersion.versionString
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class KotlinGradleSourceSetDataService : AbstractProjectDataService<GradleSourceSetData, Void>() {
|
class KotlinGradleSourceSetDataService : AbstractProjectDataService<GradleSourceSetData, Void>() {
|
||||||
override fun getTargetDataKey() = GradleSourceSetData.KEY
|
override fun getTargetDataKey() = GradleSourceSetData.KEY
|
||||||
|
|
||||||
|
|||||||
+217
@@ -25,6 +25,7 @@ import com.intellij.openapi.roots.LibraryOrderEntry
|
|||||||
import com.intellij.openapi.roots.ModuleRootManager
|
import com.intellij.openapi.roots.ModuleRootManager
|
||||||
import com.intellij.openapi.roots.OrderRootType
|
import com.intellij.openapi.roots.OrderRootType
|
||||||
import com.intellij.openapi.roots.impl.libraries.LibraryEx
|
import com.intellij.openapi.roots.impl.libraries.LibraryEx
|
||||||
|
import junit.framework.TestCase
|
||||||
import org.jetbrains.jps.model.java.JavaResourceRootType
|
import org.jetbrains.jps.model.java.JavaResourceRootType
|
||||||
import org.jetbrains.jps.model.java.JavaSourceRootType
|
import org.jetbrains.jps.model.java.JavaSourceRootType
|
||||||
import org.jetbrains.jps.model.module.JpsModuleSourceRootType
|
import org.jetbrains.jps.model.module.JpsModuleSourceRootType
|
||||||
@@ -2273,6 +2274,222 @@ compileTestKotlin {
|
|||||||
assertAllModulesConfigured()
|
assertAllModulesConfigured()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testSharedLanguageVersion() {
|
||||||
|
createProjectSubFile(
|
||||||
|
"build.gradle",
|
||||||
|
"""
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.60")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin-platform-common'
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib-common:1.2.60"
|
||||||
|
}
|
||||||
|
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
createProjectSubFile(
|
||||||
|
"settings.gradle",
|
||||||
|
"""
|
||||||
|
rootProject.name = 'MultiTest'
|
||||||
|
include 'MultiTest-jvm', 'MultiTest-js'
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
createProjectSubFile(
|
||||||
|
"MultiTest-js/build.gradle",
|
||||||
|
"""
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.60")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin-platform-js'
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
myMain {
|
||||||
|
kotlin {
|
||||||
|
srcDir 'src'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
myTest {
|
||||||
|
kotlin {
|
||||||
|
srcDir 'test'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib-js:1.2.60"
|
||||||
|
implement project(":")
|
||||||
|
}
|
||||||
|
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
createProjectSubFile(
|
||||||
|
"MultiTest-jvm/build.gradle",
|
||||||
|
"""
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.60")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin-platform-jvm'
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib:1.2.60"
|
||||||
|
implement project(":")
|
||||||
|
}
|
||||||
|
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
|
||||||
|
val holder = KotlinCommonCompilerArgumentsHolder.getInstance(myProject)
|
||||||
|
|
||||||
|
holder.update { languageVersion = "1.1" }
|
||||||
|
|
||||||
|
importProject()
|
||||||
|
|
||||||
|
TestCase.assertEquals("1.2", holder.settings.languageVersion)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testNonSharedLanguageVersion() {
|
||||||
|
createProjectSubFile(
|
||||||
|
"build.gradle",
|
||||||
|
"""
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.60")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin-platform-common'
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib-common:1.2.60"
|
||||||
|
}
|
||||||
|
|
||||||
|
compileKotlinCommon {
|
||||||
|
kotlinOptions.languageVersion = "1.1"
|
||||||
|
}
|
||||||
|
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
createProjectSubFile(
|
||||||
|
"settings.gradle",
|
||||||
|
"""
|
||||||
|
rootProject.name = 'MultiTest'
|
||||||
|
include 'MultiTest-jvm', 'MultiTest-js'
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
createProjectSubFile(
|
||||||
|
"MultiTest-js/build.gradle",
|
||||||
|
"""
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.60")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin-platform-js'
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib-js:1.2.60"
|
||||||
|
implement project(":")
|
||||||
|
}
|
||||||
|
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
createProjectSubFile(
|
||||||
|
"MultiTest-jvm/build.gradle",
|
||||||
|
"""
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.60")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin-platform-jvm'
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
myMain {
|
||||||
|
kotlin {
|
||||||
|
srcDir 'src'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
myTest {
|
||||||
|
kotlin {
|
||||||
|
srcDir 'test'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib:1.2.60"
|
||||||
|
implement project(":")
|
||||||
|
}
|
||||||
|
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
|
||||||
|
val holder = KotlinCommonCompilerArgumentsHolder.getInstance(myProject)
|
||||||
|
|
||||||
|
holder.update { languageVersion = "1.1" }
|
||||||
|
|
||||||
|
importProject()
|
||||||
|
|
||||||
|
TestCase.assertEquals("1.1", holder.settings.languageVersion)
|
||||||
|
}
|
||||||
|
|
||||||
private fun checkStableModuleName(projectName: String, expectedName: String, platform: TargetPlatform, isProduction: Boolean) {
|
private fun checkStableModuleName(projectName: String, expectedName: String, platform: TargetPlatform, isProduction: Boolean) {
|
||||||
val module = getModule(projectName)
|
val module = getModule(projectName)
|
||||||
val moduleInfo = if (isProduction) module.productionSourceInfo() else module.testSourceInfo()
|
val moduleInfo = if (isProduction) module.productionSourceInfo() else module.testSourceInfo()
|
||||||
|
|||||||
+217
@@ -25,6 +25,7 @@ import com.intellij.openapi.roots.LibraryOrderEntry
|
|||||||
import com.intellij.openapi.roots.ModuleRootManager
|
import com.intellij.openapi.roots.ModuleRootManager
|
||||||
import com.intellij.openapi.roots.OrderRootType
|
import com.intellij.openapi.roots.OrderRootType
|
||||||
import com.intellij.openapi.roots.impl.libraries.LibraryEx
|
import com.intellij.openapi.roots.impl.libraries.LibraryEx
|
||||||
|
import junit.framework.TestCase
|
||||||
import org.jetbrains.kotlin.caches.resolve.KotlinCacheService
|
import org.jetbrains.kotlin.caches.resolve.KotlinCacheService
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
||||||
@@ -2022,6 +2023,222 @@ compileTestKotlin {
|
|||||||
assertAllModulesConfigured()
|
assertAllModulesConfigured()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testSharedLanguageVersion() {
|
||||||
|
createProjectSubFile(
|
||||||
|
"build.gradle",
|
||||||
|
"""
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.60")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin-platform-common'
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib-common:1.2.60"
|
||||||
|
}
|
||||||
|
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
createProjectSubFile(
|
||||||
|
"settings.gradle",
|
||||||
|
"""
|
||||||
|
rootProject.name = 'MultiTest'
|
||||||
|
include 'MultiTest-jvm', 'MultiTest-js'
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
createProjectSubFile(
|
||||||
|
"MultiTest-js/build.gradle",
|
||||||
|
"""
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.60")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin-platform-js'
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
myMain {
|
||||||
|
kotlin {
|
||||||
|
srcDir 'src'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
myTest {
|
||||||
|
kotlin {
|
||||||
|
srcDir 'test'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib-js:1.2.60"
|
||||||
|
implement project(":")
|
||||||
|
}
|
||||||
|
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
createProjectSubFile(
|
||||||
|
"MultiTest-jvm/build.gradle",
|
||||||
|
"""
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.60")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin-platform-jvm'
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib:1.2.60"
|
||||||
|
implement project(":")
|
||||||
|
}
|
||||||
|
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
|
||||||
|
val holder = KotlinCommonCompilerArgumentsHolder.getInstance(myProject)
|
||||||
|
|
||||||
|
holder.update { languageVersion = "1.1" }
|
||||||
|
|
||||||
|
importProject()
|
||||||
|
|
||||||
|
TestCase.assertEquals("1.2", holder.settings.languageVersion)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testNonSharedLanguageVersion() {
|
||||||
|
createProjectSubFile(
|
||||||
|
"build.gradle",
|
||||||
|
"""
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.60")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin-platform-common'
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib-common:1.2.60"
|
||||||
|
}
|
||||||
|
|
||||||
|
compileKotlinCommon {
|
||||||
|
kotlinOptions.languageVersion = "1.1"
|
||||||
|
}
|
||||||
|
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
createProjectSubFile(
|
||||||
|
"settings.gradle",
|
||||||
|
"""
|
||||||
|
rootProject.name = 'MultiTest'
|
||||||
|
include 'MultiTest-jvm', 'MultiTest-js'
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
createProjectSubFile(
|
||||||
|
"MultiTest-js/build.gradle",
|
||||||
|
"""
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.60")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin-platform-js'
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib-js:1.2.60"
|
||||||
|
implement project(":")
|
||||||
|
}
|
||||||
|
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
createProjectSubFile(
|
||||||
|
"MultiTest-jvm/build.gradle",
|
||||||
|
"""
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.60")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin-platform-jvm'
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
myMain {
|
||||||
|
kotlin {
|
||||||
|
srcDir 'src'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
myTest {
|
||||||
|
kotlin {
|
||||||
|
srcDir 'test'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib:1.2.60"
|
||||||
|
implement project(":")
|
||||||
|
}
|
||||||
|
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
|
||||||
|
val holder = KotlinCommonCompilerArgumentsHolder.getInstance(myProject)
|
||||||
|
|
||||||
|
holder.update { languageVersion = "1.1" }
|
||||||
|
|
||||||
|
importProject()
|
||||||
|
|
||||||
|
TestCase.assertEquals("1.1", holder.settings.languageVersion)
|
||||||
|
}
|
||||||
|
|
||||||
private fun checkStableModuleName(projectName: String, expectedName: String, platform: TargetPlatform, isProduction: Boolean) {
|
private fun checkStableModuleName(projectName: String, expectedName: String, platform: TargetPlatform, isProduction: Boolean) {
|
||||||
val module = getModule(projectName)
|
val module = getModule(projectName)
|
||||||
val moduleInfo = if (isProduction) module.productionSourceInfo() else module.testSourceInfo()
|
val moduleInfo = if (isProduction) module.productionSourceInfo() else module.testSourceInfo()
|
||||||
|
|||||||
+217
@@ -25,6 +25,7 @@ import com.intellij.openapi.roots.LibraryOrderEntry
|
|||||||
import com.intellij.openapi.roots.ModuleRootManager
|
import com.intellij.openapi.roots.ModuleRootManager
|
||||||
import com.intellij.openapi.roots.OrderRootType
|
import com.intellij.openapi.roots.OrderRootType
|
||||||
import com.intellij.openapi.roots.impl.libraries.LibraryEx
|
import com.intellij.openapi.roots.impl.libraries.LibraryEx
|
||||||
|
import junit.framework.TestCase
|
||||||
import org.jetbrains.kotlin.caches.resolve.KotlinCacheService
|
import org.jetbrains.kotlin.caches.resolve.KotlinCacheService
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
||||||
@@ -2022,6 +2023,222 @@ compileTestKotlin {
|
|||||||
assertAllModulesConfigured()
|
assertAllModulesConfigured()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testSharedLanguageVersion() {
|
||||||
|
createProjectSubFile(
|
||||||
|
"build.gradle",
|
||||||
|
"""
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.60")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin-platform-common'
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib-common:1.2.60"
|
||||||
|
}
|
||||||
|
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
createProjectSubFile(
|
||||||
|
"settings.gradle",
|
||||||
|
"""
|
||||||
|
rootProject.name = 'MultiTest'
|
||||||
|
include 'MultiTest-jvm', 'MultiTest-js'
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
createProjectSubFile(
|
||||||
|
"MultiTest-js/build.gradle",
|
||||||
|
"""
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.60")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin-platform-js'
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
myMain {
|
||||||
|
kotlin {
|
||||||
|
srcDir 'src'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
myTest {
|
||||||
|
kotlin {
|
||||||
|
srcDir 'test'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib-js:1.2.60"
|
||||||
|
implement project(":")
|
||||||
|
}
|
||||||
|
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
createProjectSubFile(
|
||||||
|
"MultiTest-jvm/build.gradle",
|
||||||
|
"""
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.60")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin-platform-jvm'
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib:1.2.60"
|
||||||
|
implement project(":")
|
||||||
|
}
|
||||||
|
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
|
||||||
|
val holder = KotlinCommonCompilerArgumentsHolder.getInstance(myProject)
|
||||||
|
|
||||||
|
holder.update { languageVersion = "1.1" }
|
||||||
|
|
||||||
|
importProject()
|
||||||
|
|
||||||
|
TestCase.assertEquals("1.2", holder.settings.languageVersion)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testNonSharedLanguageVersion() {
|
||||||
|
createProjectSubFile(
|
||||||
|
"build.gradle",
|
||||||
|
"""
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.60")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin-platform-common'
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib-common:1.2.60"
|
||||||
|
}
|
||||||
|
|
||||||
|
compileKotlinCommon {
|
||||||
|
kotlinOptions.languageVersion = "1.1"
|
||||||
|
}
|
||||||
|
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
createProjectSubFile(
|
||||||
|
"settings.gradle",
|
||||||
|
"""
|
||||||
|
rootProject.name = 'MultiTest'
|
||||||
|
include 'MultiTest-jvm', 'MultiTest-js'
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
createProjectSubFile(
|
||||||
|
"MultiTest-js/build.gradle",
|
||||||
|
"""
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.60")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin-platform-js'
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib-js:1.2.60"
|
||||||
|
implement project(":")
|
||||||
|
}
|
||||||
|
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
createProjectSubFile(
|
||||||
|
"MultiTest-jvm/build.gradle",
|
||||||
|
"""
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.60")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin-platform-jvm'
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
myMain {
|
||||||
|
kotlin {
|
||||||
|
srcDir 'src'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
myTest {
|
||||||
|
kotlin {
|
||||||
|
srcDir 'test'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib:1.2.60"
|
||||||
|
implement project(":")
|
||||||
|
}
|
||||||
|
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
|
||||||
|
val holder = KotlinCommonCompilerArgumentsHolder.getInstance(myProject)
|
||||||
|
|
||||||
|
holder.update { languageVersion = "1.1" }
|
||||||
|
|
||||||
|
importProject()
|
||||||
|
|
||||||
|
TestCase.assertEquals("1.1", holder.settings.languageVersion)
|
||||||
|
}
|
||||||
|
|
||||||
private fun checkStableModuleName(projectName: String, expectedName: String, platform: TargetPlatform, isProduction: Boolean) {
|
private fun checkStableModuleName(projectName: String, expectedName: String, platform: TargetPlatform, isProduction: Boolean) {
|
||||||
val module = getModule(projectName)
|
val module = getModule(projectName)
|
||||||
val moduleInfo = if (isProduction) module.productionSourceInfo() else module.testSourceInfo()
|
val moduleInfo = if (isProduction) module.productionSourceInfo() else module.testSourceInfo()
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleLibraryDataService"/>
|
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleLibraryDataService"/>
|
||||||
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinSourceSetDataService"/>
|
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinSourceSetDataService"/>
|
||||||
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinTargetDataService"/>
|
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinTargetDataService"/>
|
||||||
|
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleProjectSettingsDataService"/>
|
||||||
<externalSystemTaskNotificationListener implementation="org.jetbrains.kotlin.idea.core.script.ReloadGradleTemplatesOnSync"/>
|
<externalSystemTaskNotificationListener implementation="org.jetbrains.kotlin.idea.core.script.ReloadGradleTemplatesOnSync"/>
|
||||||
|
|
||||||
<localInspection
|
<localInspection
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleSourceSetDataService"/>
|
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleSourceSetDataService"/>
|
||||||
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleProjectDataService"/>
|
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleProjectDataService"/>
|
||||||
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleLibraryDataService"/>
|
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleLibraryDataService"/>
|
||||||
|
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleProjectSettingsDataService"/>
|
||||||
<externalSystemTaskNotificationListener implementation="org.jetbrains.kotlin.idea.core.script.ReloadGradleTemplatesOnSync"/>
|
<externalSystemTaskNotificationListener implementation="org.jetbrains.kotlin.idea.core.script.ReloadGradleTemplatesOnSync"/>
|
||||||
|
|
||||||
<localInspection
|
<localInspection
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleLibraryDataService"/>
|
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleLibraryDataService"/>
|
||||||
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinSourceSetDataService"/>
|
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinSourceSetDataService"/>
|
||||||
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinTargetDataService"/>
|
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinTargetDataService"/>
|
||||||
|
<externalProjectDataService implementation="org.jetbrains.kotlin.idea.configuration.KotlinGradleProjectSettingsDataService"/>
|
||||||
<externalSystemTaskNotificationListener implementation="org.jetbrains.kotlin.idea.core.script.ReloadGradleTemplatesOnSync"/>
|
<externalSystemTaskNotificationListener implementation="org.jetbrains.kotlin.idea.core.script.ReloadGradleTemplatesOnSync"/>
|
||||||
|
|
||||||
<localInspection
|
<localInspection
|
||||||
|
|||||||
Reference in New Issue
Block a user