jps: minor: refine kotlin.jps.model package
(cherry picked from commit 2a31e78)
This commit is contained in:
@@ -40,7 +40,6 @@ import org.jetbrains.jps.cmdline.ProjectDescriptor
|
||||
import org.jetbrains.jps.incremental.*
|
||||
import org.jetbrains.jps.incremental.messages.BuildMessage
|
||||
import org.jetbrains.jps.model.JpsModuleRootModificationUtil
|
||||
import org.jetbrains.jps.model.java.JpsJavaDependencyScope
|
||||
import org.jetbrains.jps.model.java.JpsJavaExtensionService
|
||||
import org.jetbrains.jps.util.JpsPathUtil
|
||||
import org.jetbrains.kotlin.config.IncrementalCompilation
|
||||
@@ -51,8 +50,6 @@ import org.jetbrains.kotlin.incremental.testingUtils.*
|
||||
import org.jetbrains.kotlin.jps.incremental.getKotlinCache
|
||||
import org.jetbrains.kotlin.jps.incremental.withLookupStorage
|
||||
import org.jetbrains.kotlin.jps.model.JpsKotlinFacetModuleExtension
|
||||
import org.jetbrains.kotlin.jps.model.kotlinFacetExtension
|
||||
import org.jetbrains.kotlin.jps.platforms.clearKotlinModuleBuildTargetDataBindings
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
import org.jetbrains.kotlin.utils.keysToMap
|
||||
|
||||
@@ -60,7 +60,7 @@ import org.jetbrains.kotlin.config.KotlinCompilerVersion.TEST_IS_PRE_RELEASE_SYS
|
||||
import org.jetbrains.kotlin.incremental.CacheVersion
|
||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
import org.jetbrains.kotlin.incremental.withIC
|
||||
import org.jetbrains.kotlin.jps.JpsKotlinCompilerSettings
|
||||
import org.jetbrains.kotlin.jps.model.JpsKotlinCompilerSettings
|
||||
import org.jetbrains.kotlin.jps.build.KotlinJpsBuildTest.LibraryDependency.*
|
||||
import org.jetbrains.kotlin.jps.platforms.KotlinJsModuleBuildTarget
|
||||
import org.jetbrains.kotlin.jps.platforms.clearKotlinModuleBuildTargetDataBindings
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ import org.jetbrains.jps.builders.JpsBuildTestCase
|
||||
import org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner
|
||||
import org.jetbrains.kotlin.config.IncrementalCompilation
|
||||
import org.jetbrains.kotlin.config.LanguageVersion
|
||||
import org.jetbrains.kotlin.jps.JpsKotlinCompilerSettings
|
||||
import org.jetbrains.kotlin.jps.model.JpsKotlinCompilerSettings
|
||||
import kotlin.reflect.KMutableProperty1
|
||||
import org.jetbrains.kotlin.daemon.common.COMPILE_DAEMON_CUSTOM_RUN_FILES_PATH_FOR_TESTS
|
||||
import org.jetbrains.kotlin.daemon.common.COMPILE_DAEMON_ENABLED_PROPERTY
|
||||
|
||||
@@ -27,8 +27,7 @@ import org.jetbrains.jps.model.library.JpsLibraryRoot;
|
||||
import org.jetbrains.jps.model.library.JpsOrderRootType;
|
||||
import org.jetbrains.jps.util.JpsPathUtil;
|
||||
import org.jetbrains.kotlin.config.TargetPlatformKind;
|
||||
import org.jetbrains.kotlin.jps.ModuleSettingsKt;
|
||||
import org.jetbrains.kotlin.jps.ProjectSettingsKt;
|
||||
import org.jetbrains.kotlin.jps.model.ModuleSettingsKt;
|
||||
import org.jetbrains.kotlin.utils.LibraryUtils;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -54,7 +54,7 @@ import org.jetbrains.kotlin.config.CompilerRunnerConstants.INTERNAL_ERROR_PREFIX
|
||||
import org.jetbrains.kotlin.daemon.common.isDaemonEnabled
|
||||
import org.jetbrains.kotlin.incremental.*
|
||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
import org.jetbrains.kotlin.jps.kotlinCompilerArguments
|
||||
import org.jetbrains.kotlin.jps.model.kotlinCompilerArguments
|
||||
import org.jetbrains.kotlin.jps.incremental.*
|
||||
import org.jetbrains.kotlin.jps.platforms.KotlinJsModuleBuildTarget
|
||||
import org.jetbrains.kotlin.jps.platforms.kotlinData
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.jps.model
|
||||
|
||||
import com.intellij.util.xmlb.XmlSerializer
|
||||
import org.jdom.Element
|
||||
import org.jetbrains.jps.model.JpsProject
|
||||
import org.jetbrains.jps.model.serialization.JpsProjectExtensionSerializer
|
||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||
import org.jetbrains.kotlin.config.SettingConstants
|
||||
|
||||
abstract class BaseJpsCompilerSettingsSerializer<T : Any>(
|
||||
componentName: String,
|
||||
private val settingsFactory: () -> T
|
||||
) : JpsProjectExtensionSerializer(SettingConstants.KOTLIN_COMPILER_SETTINGS_FILE, componentName) {
|
||||
protected abstract fun onLoad(project: JpsProject, settings: T)
|
||||
|
||||
override fun loadExtension(project: JpsProject, componentTag: Element) {
|
||||
val settings = settingsFactory().apply {
|
||||
if (this is CommonCompilerArguments) {
|
||||
freeArgs = ArrayList()
|
||||
}
|
||||
}
|
||||
XmlSerializer.deserializeInto(settings, componentTag)
|
||||
onLoad(project, settings)
|
||||
}
|
||||
|
||||
override fun saveExtension(project: JpsProject, componentTag: Element) {
|
||||
}
|
||||
}
|
||||
-47
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.jps.model
|
||||
|
||||
import org.jdom.Element
|
||||
import org.jetbrains.jps.model.JpsElement
|
||||
import org.jetbrains.jps.model.module.JpsModule
|
||||
import org.jetbrains.jps.model.serialization.facet.JpsFacetConfigurationSerializer
|
||||
import org.jetbrains.kotlin.config.deserializeFacetSettings
|
||||
import org.jetbrains.kotlin.config.serializeFacetSettings
|
||||
|
||||
object JpsKotlinFacetConfigurationSerializer : JpsFacetConfigurationSerializer<JpsKotlinFacetModuleExtension>(
|
||||
JpsKotlinFacetModuleExtension.KIND,
|
||||
JpsKotlinFacetModuleExtension.FACET_TYPE_ID,
|
||||
JpsKotlinFacetModuleExtension.FACET_NAME
|
||||
) {
|
||||
override fun loadExtension(
|
||||
facetConfigurationElement: Element,
|
||||
name: String,
|
||||
parent: JpsElement?,
|
||||
module: JpsModule
|
||||
): JpsKotlinFacetModuleExtension {
|
||||
return JpsKotlinFacetModuleExtension(deserializeFacetSettings(facetConfigurationElement))
|
||||
}
|
||||
|
||||
override fun saveExtension(
|
||||
extension: JpsKotlinFacetModuleExtension?,
|
||||
facetConfigurationTag: Element,
|
||||
module: JpsModule
|
||||
) {
|
||||
(extension as JpsKotlinFacetModuleExtension).settings.serializeFacetSettings(facetConfigurationTag)
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.jps.model
|
||||
|
||||
import org.jetbrains.jps.model.ex.JpsElementBase
|
||||
import org.jetbrains.jps.model.ex.JpsElementChildRoleBase
|
||||
import org.jetbrains.jps.model.module.JpsModule
|
||||
import org.jetbrains.kotlin.config.KotlinFacetSettings
|
||||
|
||||
class JpsKotlinFacetModuleExtension(settings: KotlinFacetSettings) : JpsElementBase<JpsKotlinFacetModuleExtension>() {
|
||||
var settings = settings
|
||||
private set
|
||||
|
||||
companion object {
|
||||
val KIND = JpsElementChildRoleBase.create<JpsKotlinFacetModuleExtension>("kotlin facet extension")
|
||||
// These must be changed in sync with KotlinFacetType.TYPE_ID and KotlinFacetType.NAME
|
||||
val FACET_TYPE_ID = "kotlin-language"
|
||||
val FACET_NAME = "Kotlin"
|
||||
}
|
||||
|
||||
override fun createCopy() = JpsKotlinFacetModuleExtension(settings)
|
||||
|
||||
override fun applyChanges(modified: JpsKotlinFacetModuleExtension) {
|
||||
this.settings = modified.settings
|
||||
}
|
||||
}
|
||||
|
||||
val JpsModule.kotlinFacetExtension: JpsKotlinFacetModuleExtension?
|
||||
get() = container.getChild(JpsKotlinFacetModuleExtension.KIND)
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.jps.model
|
||||
|
||||
import org.jetbrains.jps.model.JpsProject
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
|
||||
import org.jetbrains.kotlin.config.SettingConstants.KOTLIN_TO_JS_COMPILER_ARGUMENTS_SECTION
|
||||
import org.jetbrains.kotlin.jps.JpsKotlinCompilerSettings
|
||||
import org.jetbrains.kotlin.jps.k2JsCompilerArguments
|
||||
|
||||
internal class Kotlin2JsCompilerArgumentsSerializer : BaseJpsCompilerSettingsSerializer<K2JSCompilerArguments>(
|
||||
KOTLIN_TO_JS_COMPILER_ARGUMENTS_SECTION, ::K2JSCompilerArguments
|
||||
) {
|
||||
override fun onLoad(project: JpsProject, settings: K2JSCompilerArguments) {
|
||||
project.k2JsCompilerArguments = settings
|
||||
}
|
||||
}
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.jps.model
|
||||
|
||||
import org.jetbrains.jps.model.JpsProject
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
||||
import org.jetbrains.kotlin.config.SettingConstants.KOTLIN_TO_JVM_COMPILER_ARGUMENTS_SECTION
|
||||
import org.jetbrains.kotlin.jps.JpsKotlinCompilerSettings
|
||||
import org.jetbrains.kotlin.jps.k2JvmCompilerArguments
|
||||
|
||||
internal class Kotlin2JvmCompilerArgumentsSerializer : BaseJpsCompilerSettingsSerializer<K2JVMCompilerArguments>(
|
||||
KOTLIN_TO_JVM_COMPILER_ARGUMENTS_SECTION, ::K2JVMCompilerArguments
|
||||
) {
|
||||
override fun onLoad(project: JpsProject, settings: K2JVMCompilerArguments) {
|
||||
project.k2JvmCompilerArguments = settings
|
||||
}
|
||||
}
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.jps.model
|
||||
|
||||
import com.intellij.util.text.VersionComparatorUtil
|
||||
import org.jetbrains.jps.model.JpsProject
|
||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||
import org.jetbrains.kotlin.cli.common.arguments.setApiVersionToLanguageVersionIfNeeded
|
||||
import org.jetbrains.kotlin.config.SettingConstants.KOTLIN_COMMON_COMPILER_ARGUMENTS_SECTION
|
||||
import org.jetbrains.kotlin.jps.JpsKotlinCompilerSettings
|
||||
import org.jetbrains.kotlin.jps.kotlinCommonCompilerArguments
|
||||
|
||||
internal class KotlinCommonCompilerArgumentsSerializer : BaseJpsCompilerSettingsSerializer<CommonCompilerArguments.DummyImpl>(
|
||||
KOTLIN_COMMON_COMPILER_ARGUMENTS_SECTION, CommonCompilerArguments::DummyImpl
|
||||
) {
|
||||
override fun onLoad(project: JpsProject, settings: CommonCompilerArguments.DummyImpl) {
|
||||
settings.setApiVersionToLanguageVersionIfNeeded()
|
||||
project.kotlinCommonCompilerArguments = settings
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.jps.model
|
||||
|
||||
import org.jetbrains.jps.model.JpsProject
|
||||
import org.jetbrains.kotlin.config.CompilerSettings
|
||||
import org.jetbrains.kotlin.config.SettingConstants.KOTLIN_COMPILER_SETTINGS_SECTION
|
||||
import org.jetbrains.kotlin.jps.JpsKotlinCompilerSettings
|
||||
import org.jetbrains.kotlin.jps.kotlinCompilerSettings
|
||||
|
||||
internal class KotlinCompilerSettingsSerializer : BaseJpsCompilerSettingsSerializer<CompilerSettings>(
|
||||
KOTLIN_COMPILER_SETTINGS_SECTION, ::CompilerSettings
|
||||
) {
|
||||
override fun onLoad(project: JpsProject, settings: CompilerSettings) {
|
||||
project.kotlinCompilerSettings = settings
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.jps.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.serialization.JpsModelSerializerExtension;
|
||||
import org.jetbrains.jps.model.serialization.JpsProjectExtensionSerializer;
|
||||
import org.jetbrains.jps.model.serialization.facet.JpsFacetConfigurationSerializer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class KotlinModelSerializerService extends JpsModelSerializerExtension {
|
||||
@NotNull
|
||||
@Override
|
||||
public List<? extends JpsProjectExtensionSerializer> getProjectExtensionSerializers() {
|
||||
return Arrays.asList(new KotlinCommonCompilerArgumentsSerializer(),
|
||||
new Kotlin2JvmCompilerArgumentsSerializer(),
|
||||
new Kotlin2JsCompilerArgumentsSerializer(),
|
||||
new KotlinCompilerSettingsSerializer());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<? extends JpsFacetConfigurationSerializer<?>> getFacetConfigurationSerializers() {
|
||||
return Collections.singletonList(JpsKotlinFacetConfigurationSerializer.INSTANCE);
|
||||
}
|
||||
}
|
||||
+30
-7
@@ -3,27 +3,32 @@
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.jps
|
||||
package org.jetbrains.kotlin.jps.model
|
||||
|
||||
import org.jetbrains.jps.model.ex.JpsElementBase
|
||||
import org.jetbrains.jps.model.ex.JpsElementChildRoleBase
|
||||
import org.jetbrains.jps.model.module.JpsModule
|
||||
import org.jetbrains.kotlin.cli.common.arguments.*
|
||||
import org.jetbrains.kotlin.config.CompilerSettings
|
||||
import org.jetbrains.kotlin.config.KotlinFacetSettings
|
||||
import org.jetbrains.kotlin.config.TargetPlatformKind
|
||||
import org.jetbrains.kotlin.jps.model.kotlinFacetExtension
|
||||
|
||||
val JpsModule.kotlinFacet: JpsKotlinFacetModuleExtension?
|
||||
get() = container.getChild(JpsKotlinFacetModuleExtension.KIND)
|
||||
|
||||
val JpsModule.targetPlatform: TargetPlatformKind<*>?
|
||||
get() = kotlinFacetExtension?.settings?.targetPlatformKind
|
||||
get() = kotlinFacet?.settings?.targetPlatformKind
|
||||
|
||||
val JpsModule.productionOutputFilePath: String?
|
||||
get() {
|
||||
val facetSettings = kotlinFacetExtension?.settings ?: return null
|
||||
val facetSettings = kotlinFacet?.settings ?: return null
|
||||
if (facetSettings.useProjectSettings) return null
|
||||
return facetSettings.productionOutputPath
|
||||
}
|
||||
|
||||
val JpsModule.testOutputFilePath: String?
|
||||
get() {
|
||||
val facetSettings = kotlinFacetExtension?.settings ?: return null
|
||||
val facetSettings = kotlinFacet?.settings ?: return null
|
||||
if (facetSettings.useProjectSettings) return null
|
||||
return facetSettings.testOutputPath
|
||||
}
|
||||
@@ -31,7 +36,7 @@ val JpsModule.testOutputFilePath: String?
|
||||
val JpsModule.kotlinCompilerSettings: CompilerSettings
|
||||
get() {
|
||||
val defaultSettings = copyBean(project.kotlinCompilerSettings)
|
||||
val facetSettings = kotlinFacetExtension?.settings ?: return defaultSettings
|
||||
val facetSettings = kotlinFacet?.settings ?: return defaultSettings
|
||||
if (facetSettings.useProjectSettings) return defaultSettings
|
||||
return facetSettings.compilerSettings ?: defaultSettings
|
||||
}
|
||||
@@ -52,7 +57,25 @@ private inline fun <reified T : CommonCompilerArguments> JpsModule.getCompilerAr
|
||||
val projectSettings = project.kotlinCompilerSettingsContainer[T::class.java]
|
||||
val projectSettingsCopy = copyBean(projectSettings)
|
||||
|
||||
val facetSettings = kotlinFacetExtension?.settings ?: return projectSettingsCopy
|
||||
val facetSettings = kotlinFacet?.settings ?: return projectSettingsCopy
|
||||
if (facetSettings.useProjectSettings) return projectSettingsCopy
|
||||
return facetSettings.compilerArguments as? T ?: projectSettingsCopy
|
||||
}
|
||||
|
||||
class JpsKotlinFacetModuleExtension(settings: KotlinFacetSettings) : JpsElementBase<JpsKotlinFacetModuleExtension>() {
|
||||
var settings = settings
|
||||
private set
|
||||
|
||||
companion object {
|
||||
val KIND = JpsElementChildRoleBase.create<JpsKotlinFacetModuleExtension>("kotlin facet extension")
|
||||
// These must be changed in sync with KotlinFacetType.TYPE_ID and KotlinFacetType.NAME
|
||||
val FACET_TYPE_ID = "kotlin-language"
|
||||
val FACET_NAME = "Kotlin"
|
||||
}
|
||||
|
||||
override fun createCopy() = JpsKotlinFacetModuleExtension(settings)
|
||||
|
||||
override fun applyChanges(modified: JpsKotlinFacetModuleExtension) {
|
||||
this.settings = modified.settings
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.jps
|
||||
package org.jetbrains.kotlin.jps.model
|
||||
|
||||
import org.jetbrains.jps.model.JpsProject
|
||||
import org.jetbrains.jps.model.ex.JpsElementBase
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. 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.jps.model
|
||||
|
||||
import com.intellij.util.xmlb.XmlSerializer
|
||||
import org.jdom.Element
|
||||
import org.jetbrains.jps.model.JpsElement
|
||||
import org.jetbrains.jps.model.JpsProject
|
||||
import org.jetbrains.jps.model.module.JpsModule
|
||||
import org.jetbrains.jps.model.serialization.JpsModelSerializerExtension
|
||||
import org.jetbrains.jps.model.serialization.JpsProjectExtensionSerializer
|
||||
import org.jetbrains.jps.model.serialization.facet.JpsFacetConfigurationSerializer
|
||||
import org.jetbrains.kotlin.cli.common.arguments.*
|
||||
import org.jetbrains.kotlin.config.CompilerSettings
|
||||
import org.jetbrains.kotlin.config.SettingConstants
|
||||
import org.jetbrains.kotlin.config.deserializeFacetSettings
|
||||
import org.jetbrains.kotlin.config.serializeFacetSettings
|
||||
import java.util.*
|
||||
|
||||
class KotlinModelSerializerService : JpsModelSerializerExtension() {
|
||||
override fun getProjectExtensionSerializers() = listOf(
|
||||
KotlinCommonCompilerArgumentsSerializer(),
|
||||
Kotlin2JvmCompilerArgumentsSerializer(),
|
||||
Kotlin2JsCompilerArgumentsSerializer(),
|
||||
KotlinCompilerSettingsSerializer()
|
||||
)
|
||||
|
||||
override fun getFacetConfigurationSerializers() = listOf(JpsKotlinFacetConfigurationSerializer)
|
||||
}
|
||||
|
||||
object JpsKotlinFacetConfigurationSerializer : JpsFacetConfigurationSerializer<JpsKotlinFacetModuleExtension>(
|
||||
JpsKotlinFacetModuleExtension.KIND,
|
||||
JpsKotlinFacetModuleExtension.FACET_TYPE_ID,
|
||||
JpsKotlinFacetModuleExtension.FACET_NAME
|
||||
) {
|
||||
override fun loadExtension(
|
||||
facetConfigurationElement: Element,
|
||||
name: String,
|
||||
parent: JpsElement?,
|
||||
module: JpsModule
|
||||
): JpsKotlinFacetModuleExtension {
|
||||
return JpsKotlinFacetModuleExtension(deserializeFacetSettings(facetConfigurationElement))
|
||||
}
|
||||
|
||||
override fun saveExtension(
|
||||
extension: JpsKotlinFacetModuleExtension?,
|
||||
facetConfigurationTag: Element,
|
||||
module: JpsModule
|
||||
) {
|
||||
(extension as JpsKotlinFacetModuleExtension).settings.serializeFacetSettings(facetConfigurationTag)
|
||||
}
|
||||
}
|
||||
|
||||
abstract class BaseJpsCompilerSettingsSerializer<in T : Any>(
|
||||
componentName: String,
|
||||
private val settingsFactory: () -> T
|
||||
) : JpsProjectExtensionSerializer(SettingConstants.KOTLIN_COMPILER_SETTINGS_FILE, componentName) {
|
||||
protected abstract fun onLoad(project: JpsProject, settings: T)
|
||||
|
||||
override fun loadExtension(project: JpsProject, componentTag: Element) {
|
||||
val settings = settingsFactory().apply {
|
||||
if (this is CommonCompilerArguments) {
|
||||
freeArgs = ArrayList()
|
||||
}
|
||||
}
|
||||
XmlSerializer.deserializeInto(settings, componentTag)
|
||||
onLoad(project, settings)
|
||||
}
|
||||
|
||||
override fun saveExtension(project: JpsProject, componentTag: Element) {
|
||||
}
|
||||
}
|
||||
|
||||
internal class KotlinCompilerSettingsSerializer : BaseJpsCompilerSettingsSerializer<CompilerSettings>(
|
||||
SettingConstants.KOTLIN_COMPILER_SETTINGS_SECTION, ::CompilerSettings
|
||||
) {
|
||||
override fun onLoad(project: JpsProject, settings: CompilerSettings) {
|
||||
project.kotlinCompilerSettings = settings
|
||||
}
|
||||
}
|
||||
|
||||
internal class KotlinCommonCompilerArgumentsSerializer : BaseJpsCompilerSettingsSerializer<CommonCompilerArguments.DummyImpl>(
|
||||
SettingConstants.KOTLIN_COMMON_COMPILER_ARGUMENTS_SECTION, CommonCompilerArguments::DummyImpl
|
||||
) {
|
||||
override fun onLoad(project: JpsProject, settings: CommonCompilerArguments.DummyImpl) {
|
||||
settings.setApiVersionToLanguageVersionIfNeeded()
|
||||
project.kotlinCommonCompilerArguments = settings
|
||||
}
|
||||
}
|
||||
|
||||
internal class Kotlin2JsCompilerArgumentsSerializer : BaseJpsCompilerSettingsSerializer<K2JSCompilerArguments>(
|
||||
SettingConstants.KOTLIN_TO_JS_COMPILER_ARGUMENTS_SECTION, ::K2JSCompilerArguments
|
||||
) {
|
||||
override fun onLoad(project: JpsProject, settings: K2JSCompilerArguments) {
|
||||
project.k2JsCompilerArguments = settings
|
||||
}
|
||||
}
|
||||
|
||||
internal class Kotlin2JvmCompilerArgumentsSerializer : BaseJpsCompilerSettingsSerializer<K2JVMCompilerArguments>(
|
||||
SettingConstants.KOTLIN_TO_JVM_COMPILER_ARGUMENTS_SECTION, ::K2JVMCompilerArguments
|
||||
) {
|
||||
override fun onLoad(project: JpsProject, settings: K2JVMCompilerArguments) {
|
||||
project.k2JvmCompilerArguments = settings
|
||||
}
|
||||
}
|
||||
@@ -14,8 +14,8 @@ import org.jetbrains.jps.incremental.ModuleBuildTarget
|
||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||
import org.jetbrains.kotlin.compilerRunner.JpsCompilerEnvironment
|
||||
import org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner
|
||||
import org.jetbrains.kotlin.jps.k2MetadataCompilerArguments
|
||||
import org.jetbrains.kotlin.jps.kotlinCompilerSettings
|
||||
import org.jetbrains.kotlin.jps.model.k2MetadataCompilerArguments
|
||||
import org.jetbrains.kotlin.jps.model.kotlinCompilerSettings
|
||||
import java.io.File
|
||||
|
||||
class KotlinCommonModuleBuildTarget(jpsModuleBuildTarget: ModuleBuildTarget) :
|
||||
|
||||
@@ -17,7 +17,10 @@ import org.jetbrains.jps.util.JpsPathUtil
|
||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||
import org.jetbrains.kotlin.compilerRunner.JpsCompilerEnvironment
|
||||
import org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner
|
||||
import org.jetbrains.kotlin.jps.*
|
||||
import org.jetbrains.kotlin.jps.model.k2JsCompilerArguments
|
||||
import org.jetbrains.kotlin.jps.model.kotlinCompilerSettings
|
||||
import org.jetbrains.kotlin.jps.model.productionOutputFilePath
|
||||
import org.jetbrains.kotlin.jps.model.testOutputFilePath
|
||||
import org.jetbrains.kotlin.utils.JsLibraryUtils
|
||||
import org.jetbrains.kotlin.utils.KotlinJavascriptMetadataUtils.JS_EXT
|
||||
import org.jetbrains.kotlin.utils.KotlinJavascriptMetadataUtils.META_JS_SUFFIX
|
||||
|
||||
@@ -25,8 +25,8 @@ import org.jetbrains.kotlin.compilerRunner.JpsCompilerEnvironment
|
||||
import org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner
|
||||
import org.jetbrains.kotlin.config.IncrementalCompilation
|
||||
import org.jetbrains.kotlin.jps.build.*
|
||||
import org.jetbrains.kotlin.jps.k2JvmCompilerArguments
|
||||
import org.jetbrains.kotlin.jps.kotlinCompilerSettings
|
||||
import org.jetbrains.kotlin.jps.model.k2JvmCompilerArguments
|
||||
import org.jetbrains.kotlin.jps.model.kotlinCompilerSettings
|
||||
import org.jetbrains.kotlin.modules.KotlinModuleXmlBuilder
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
|
||||
@@ -21,12 +21,10 @@ import org.jetbrains.jps.util.JpsPathUtil
|
||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
||||
import org.jetbrains.kotlin.compilerRunner.JpsCompilerEnvironment
|
||||
import org.jetbrains.kotlin.jps.JpsKotlinCompilerSettings
|
||||
import org.jetbrains.kotlin.jps.build.KotlinSourceFileCollector
|
||||
import org.jetbrains.kotlin.jps.kotlinCompilerSettings
|
||||
import org.jetbrains.kotlin.jps.model.kotlinFacetExtension
|
||||
import org.jetbrains.kotlin.jps.productionOutputFilePath
|
||||
import org.jetbrains.kotlin.jps.testOutputFilePath
|
||||
import org.jetbrains.kotlin.jps.model.kotlinFacet
|
||||
import org.jetbrains.kotlin.jps.model.productionOutputFilePath
|
||||
import org.jetbrains.kotlin.jps.model.testOutputFilePath
|
||||
import org.jetbrains.kotlin.modules.TargetId
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import java.io.File
|
||||
@@ -88,7 +86,7 @@ abstract class KotlinModuleBuilderTarget(val jpsModuleBuildTarget: ModuleBuildTa
|
||||
val expectedBy by lazy(::findExpectedBy)
|
||||
|
||||
private fun findExpectedBy(): List<KotlinModuleBuilderTarget> {
|
||||
val kotlinFacetExtension = module.kotlinFacetExtension
|
||||
val kotlinFacetExtension = module.kotlinFacet
|
||||
val implementedModuleNames = kotlinFacetExtension?.settings?.implementedModuleNames ?: return listOf()
|
||||
if (implementedModuleNames.isEmpty()) return listOf()
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.jetbrains.jps.model.library.JpsOrderRootType
|
||||
import org.jetbrains.jps.model.module.JpsModule
|
||||
import org.jetbrains.jps.util.JpsPathUtil
|
||||
import org.jetbrains.kotlin.config.TargetPlatformKind
|
||||
import org.jetbrains.kotlin.jps.targetPlatform
|
||||
import org.jetbrains.kotlin.jps.model.targetPlatform
|
||||
import org.jetbrains.kotlin.utils.LibraryUtils
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
|
||||
Reference in New Issue
Block a user