From 8e282e8aad9cbfe44903d446f39496cf090dc7fb Mon Sep 17 00:00:00 2001 From: Ilya Goncharov Date: Wed, 22 Apr 2020 12:14:20 +0300 Subject: [PATCH] [Gradle, JS] Change byArgument on byArgumentOrNull #KT-38485 fixed --- .../gradle/plugin/KotlinJsCompilerType.kt | 2 +- .../kotlin/gradle/dsl/KotlinProjectExtension.kt | 2 +- ...otlinTargetContainerWithJsPresetFunctions.kt | 7 ++++++- .../kotlin/gradle/plugin/KotlinProperties.kt | 17 +++-------------- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin-api/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType.kt b/libraries/tools/kotlin-gradle-plugin-api/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType.kt index 96db89e9a9a..6a843c4c4ed 100644 --- a/libraries/tools/kotlin-gradle-plugin-api/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType.kt +++ b/libraries/tools/kotlin-gradle-plugin-api/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType.kt @@ -13,7 +13,7 @@ enum class KotlinJsCompilerType { companion object { const val jsCompilerProperty = "kotlin.js.compiler" - fun byArgument(argument: String): KotlinJsCompilerType? = + fun byArgumentOrNull(argument: String): KotlinJsCompilerType? = values().firstOrNull { it.name.equals(argument, ignoreCase = true) } } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinProjectExtension.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinProjectExtension.kt index 822d26b15c7..fcd4c67180c 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinProjectExtension.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinProjectExtension.kt @@ -166,7 +166,7 @@ open class KotlinJsProjectExtension : compiler: String, body: KotlinJsTargetDsl.() -> Unit = { } ): KotlinJsTargetDsl = js( - KotlinJsCompilerType.byArgument(compiler) + KotlinJsCompilerType.byArgumentOrNull(compiler) ?: throw IllegalArgumentException( "Unable to find $compiler setting. Use [${KotlinJsCompilerType.values().toList().joinToString()}]" ), diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinTargetContainerWithJsPresetFunctions.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinTargetContainerWithJsPresetFunctions.kt index 9b9d0462ac6..e3d920c096b 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinTargetContainerWithJsPresetFunctions.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinTargetContainerWithJsPresetFunctions.kt @@ -1,3 +1,8 @@ +/* + * Copyright 2010-2020 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.gradle.dsl import groovy.lang.Closure @@ -26,7 +31,7 @@ interface KotlinTargetContainerWithJsPresetFunctions : configure: KotlinJsTargetDsl.() -> Unit = { } ) = js( name = name, - compiler = KotlinJsCompilerType.byArgument(compiler) + compiler = KotlinJsCompilerType.byArgumentOrNull(compiler) ?: throw IllegalArgumentException( "Unable to find $compiler setting. Use [${KotlinJsCompilerType.values().toList().joinToString()}]" ), diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinProperties.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinProperties.kt index 8d90307d862..1576b5004fb 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinProperties.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinProperties.kt @@ -1,17 +1,6 @@ /* - * 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. + * Copyright 2010-2020 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.gradle.plugin @@ -206,7 +195,7 @@ internal class PropertiesProvider private constructor(private val project: Proje * Use Kotlin/JS backend compiler type */ val jsCompiler: KotlinJsCompilerType - get() = property(jsCompilerProperty)?.let { KotlinJsCompilerType.byArgument(it) } ?: KotlinJsCompilerType.LEGACY + get() = property(jsCompilerProperty)?.let { KotlinJsCompilerType.byArgumentOrNull(it) } ?: KotlinJsCompilerType.LEGACY private fun propertyWithDeprecatedVariant(propName: String, deprecatedPropName: String): String? { val deprecatedProperty = property(deprecatedPropName)