[Gradle, JS] Change byArgument on byArgumentOrNull

#KT-38485 fixed
This commit is contained in:
Ilya Goncharov
2020-04-22 12:14:20 +03:00
parent 47c27726b9
commit 8e282e8aad
4 changed files with 11 additions and 17 deletions
@@ -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) }
}
}
@@ -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()}]"
),
@@ -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()}]"
),
@@ -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)