Kotlin JPS plugin: add "version" setting
Part of KTIJ-11633
This commit is contained in:
@@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.config
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.cli.common.arguments.Freezable
|
||||||
|
|
||||||
|
class JpsPluginSettings : Freezable() {
|
||||||
|
@Suppress("unused") // Used in Kotlin plugin
|
||||||
|
var version: String by FreezableVar("") // KTIJ-20555 Fix default value?
|
||||||
|
}
|
||||||
@@ -21,6 +21,7 @@ object SettingConstants {
|
|||||||
const val KOTLIN_TO_JS_COMPILER_ARGUMENTS_SECTION = "Kotlin2JsCompilerArguments"
|
const val KOTLIN_TO_JS_COMPILER_ARGUMENTS_SECTION = "Kotlin2JsCompilerArguments"
|
||||||
const val KOTLIN_TO_JVM_COMPILER_ARGUMENTS_SECTION = "Kotlin2JvmCompilerArguments"
|
const val KOTLIN_TO_JVM_COMPILER_ARGUMENTS_SECTION = "Kotlin2JvmCompilerArguments"
|
||||||
const val KOTLIN_COMPILER_SETTINGS_SECTION = "KotlinCompilerSettings"
|
const val KOTLIN_COMPILER_SETTINGS_SECTION = "KotlinCompilerSettings"
|
||||||
|
const val KOTLIN_JPS_PLUGIN_SETTINGS_SECTION = "KotlinJpsPluginSettings"
|
||||||
const val KOTLIN_COMPILER_SETTINGS_FILE = "kotlinc.xml"
|
const val KOTLIN_COMPILER_SETTINGS_FILE = "kotlinc.xml"
|
||||||
const val KOTLIN_COMPILER_REFERENCE_INDEX_BUILDER_ID = "kotlin.compiler.ref.index"
|
const val KOTLIN_COMPILER_REFERENCE_INDEX_BUILDER_ID = "kotlin.compiler.ref.index"
|
||||||
const val KOTLIN_DATA_CONTAINER_ID = "kotlin-data-container"
|
const val KOTLIN_DATA_CONTAINER_ID = "kotlin-data-container"
|
||||||
|
|||||||
@@ -8,11 +8,9 @@ package org.jetbrains.kotlin.jps.model
|
|||||||
import org.jetbrains.jps.model.JpsProject
|
import org.jetbrains.jps.model.JpsProject
|
||||||
import org.jetbrains.jps.model.ex.JpsElementBase
|
import org.jetbrains.jps.model.ex.JpsElementBase
|
||||||
import org.jetbrains.jps.model.ex.JpsElementChildRoleBase
|
import org.jetbrains.jps.model.ex.JpsElementChildRoleBase
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.*
|
||||||
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.CompilerSettings
|
import org.jetbrains.kotlin.config.CompilerSettings
|
||||||
|
import org.jetbrains.kotlin.config.JpsPluginSettings
|
||||||
|
|
||||||
var JpsProject.kotlinCompilerSettings
|
var JpsProject.kotlinCompilerSettings
|
||||||
get() = kotlinCompilerSettingsContainer.compilerSettings
|
get() = kotlinCompilerSettingsContainer.compilerSettings
|
||||||
@@ -20,6 +18,12 @@ var JpsProject.kotlinCompilerSettings
|
|||||||
getOrCreateSettings().compilerSettings = value
|
getOrCreateSettings().compilerSettings = value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var JpsProject.kotlinJpsPluginSettings
|
||||||
|
get() = kotlinCompilerSettingsContainer.jpsPluginSettings
|
||||||
|
internal set(value) {
|
||||||
|
getOrCreateSettings().jpsPluginSettings = value
|
||||||
|
}
|
||||||
|
|
||||||
var JpsProject.kotlinCommonCompilerArguments
|
var JpsProject.kotlinCommonCompilerArguments
|
||||||
get() = kotlinCompilerSettingsContainer.commonCompilerArguments
|
get() = kotlinCompilerSettingsContainer.commonCompilerArguments
|
||||||
internal set(value) {
|
internal set(value) {
|
||||||
@@ -62,6 +66,7 @@ class JpsKotlinCompilerSettings : JpsElementBase<JpsKotlinCompilerSettings>() {
|
|||||||
internal var k2JvmCompilerArguments = K2JVMCompilerArguments()
|
internal var k2JvmCompilerArguments = K2JVMCompilerArguments()
|
||||||
internal var k2JsCompilerArguments = K2JSCompilerArguments()
|
internal var k2JsCompilerArguments = K2JSCompilerArguments()
|
||||||
internal var compilerSettings = CompilerSettings()
|
internal var compilerSettings = CompilerSettings()
|
||||||
|
internal var jpsPluginSettings = JpsPluginSettings()
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
internal operator fun <T : CommonCompilerArguments> get(compilerArgumentsClass: Class<T>): T = when (compilerArgumentsClass) {
|
internal operator fun <T : CommonCompilerArguments> get(compilerArgumentsClass: Class<T>): T = when (compilerArgumentsClass) {
|
||||||
@@ -78,6 +83,7 @@ class JpsKotlinCompilerSettings : JpsElementBase<JpsKotlinCompilerSettings>() {
|
|||||||
copy.k2JvmCompilerArguments = this.k2JvmCompilerArguments
|
copy.k2JvmCompilerArguments = this.k2JvmCompilerArguments
|
||||||
copy.k2JsCompilerArguments = this.k2JsCompilerArguments
|
copy.k2JsCompilerArguments = this.k2JsCompilerArguments
|
||||||
copy.compilerSettings = this.compilerSettings
|
copy.compilerSettings = this.compilerSettings
|
||||||
|
copy.jpsPluginSettings = this.jpsPluginSettings
|
||||||
return copy
|
return copy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ class KotlinModelSerializerService : KotlinCommonJpsModelSerializerExtension() {
|
|||||||
KotlinCommonCompilerArgumentsSerializer(),
|
KotlinCommonCompilerArgumentsSerializer(),
|
||||||
Kotlin2JvmCompilerArgumentsSerializer(),
|
Kotlin2JvmCompilerArgumentsSerializer(),
|
||||||
Kotlin2JsCompilerArgumentsSerializer(),
|
Kotlin2JsCompilerArgumentsSerializer(),
|
||||||
KotlinCompilerSettingsSerializer()
|
KotlinCompilerSettingsSerializer(),
|
||||||
|
KotlinJpsPluginSettingsSerializer()
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun getFacetConfigurationSerializers() = listOf(JpsKotlinFacetConfigurationSerializer)
|
override fun getFacetConfigurationSerializers() = listOf(JpsKotlinFacetConfigurationSerializer)
|
||||||
@@ -81,6 +82,14 @@ internal class KotlinCompilerSettingsSerializer : BaseJpsCompilerSettingsSeriali
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal class KotlinJpsPluginSettingsSerializer : BaseJpsCompilerSettingsSerializer<JpsPluginSettings>(
|
||||||
|
SettingConstants.KOTLIN_JPS_PLUGIN_SETTINGS_SECTION, ::JpsPluginSettings
|
||||||
|
) {
|
||||||
|
override fun onLoad(project: JpsProject, settings: JpsPluginSettings) {
|
||||||
|
project.kotlinJpsPluginSettings = settings
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal class KotlinCommonCompilerArgumentsSerializer : BaseJpsCompilerSettingsSerializer<CommonCompilerArguments.DummyImpl>(
|
internal class KotlinCommonCompilerArgumentsSerializer : BaseJpsCompilerSettingsSerializer<CommonCompilerArguments.DummyImpl>(
|
||||||
SettingConstants.KOTLIN_COMMON_COMPILER_ARGUMENTS_SECTION, CommonCompilerArguments::DummyImpl
|
SettingConstants.KOTLIN_COMMON_COMPILER_ARGUMENTS_SECTION, CommonCompilerArguments::DummyImpl
|
||||||
) {
|
) {
|
||||||
|
|||||||
Reference in New Issue
Block a user