Drop compileOnly dependency on :kotlin-gradle-compiler-types in compiler
This dependency was only required for compiler options Gradle DSL generation, but was leaking into runtime not-accessible classes. ^KT-54602 Fixed
This commit is contained in:
committed by
Yahor Berdnikau
parent
80b50bcd21
commit
a7e1d36528
@@ -14,7 +14,6 @@ dependencies {
|
||||
compileOnly(intellijCore())
|
||||
compileOnly(commonDependency("com.google.guava:guava"))
|
||||
compileOnly(commonDependency("org.jetbrains.intellij.deps:asm-all"))
|
||||
compileOnly(project(":kotlin-gradle-compiler-types"))
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
|
||||
+3
-3
@@ -32,7 +32,7 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
var autoAdvanceLanguageVersion: Boolean by FreezableVar(true)
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValues.LanguageVersions::class,
|
||||
value = DefaultValue.LANGUAGE_VERSIONS,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
)
|
||||
@Argument(
|
||||
@@ -46,7 +46,7 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
var autoAdvanceApiVersion: Boolean by FreezableVar(true)
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValues.ApiVersions::class,
|
||||
value = DefaultValue.API_VERSIONS,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
)
|
||||
@Argument(
|
||||
@@ -303,7 +303,7 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
var checkStickyPhaseConditions: Boolean by FreezableVar(false)
|
||||
|
||||
@GradleOption(
|
||||
DefaultValues.BooleanFalseDefault::class,
|
||||
DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
)
|
||||
@Argument(
|
||||
|
||||
+3
-3
@@ -39,21 +39,21 @@ abstract class CommonToolArguments : Freezable(), Serializable {
|
||||
var version: Boolean by FreezableVar(false)
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValues.BooleanFalseDefault::class,
|
||||
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INTERNAL
|
||||
)
|
||||
@Argument(value = "-verbose", description = "Enable verbose logging output")
|
||||
var verbose: Boolean by FreezableVar(false)
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValues.BooleanFalseDefault::class,
|
||||
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INTERNAL
|
||||
)
|
||||
@Argument(value = "-nowarn", description = "Generate no warnings")
|
||||
var suppressWarnings: Boolean by FreezableVar(false)
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValues.BooleanFalseDefault::class,
|
||||
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
)
|
||||
@Argument(value = "-Werror", description = "Report an error if there are any warnings")
|
||||
|
||||
-151
@@ -1,151 +0,0 @@
|
||||
/*
|
||||
* 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.cli.common.arguments
|
||||
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants.CALL
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants.NO_CALL
|
||||
import org.jetbrains.kotlin.config.ApiVersion
|
||||
import org.jetbrains.kotlin.config.JvmTarget
|
||||
import org.jetbrains.kotlin.config.LanguageVersion
|
||||
import org.jetbrains.kotlin.gradle.dsl.JsMainFunctionExecutionMode
|
||||
import org.jetbrains.kotlin.gradle.dsl.JsModuleKind
|
||||
import org.jetbrains.kotlin.gradle.dsl.JsSourceMapEmbedMode
|
||||
import org.jetbrains.kotlin.gradle.dsl.JsSourceMapNamesPolicy
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion as KotlinVersionDsl
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget as JvmTargetDsl
|
||||
import kotlin.reflect.KType
|
||||
import kotlin.reflect.typeOf
|
||||
|
||||
open class DefaultValues(
|
||||
val defaultValue: String,
|
||||
val type: KType,
|
||||
val kotlinOptionsType: KType,
|
||||
val possibleValues: List<String>? = null,
|
||||
val fromKotlinOptionConverterProp: String? = null,
|
||||
val toKotlinOptionConverterProp: String? = null,
|
||||
val toArgumentConverter: String? = toKotlinOptionConverterProp
|
||||
) {
|
||||
open class DefaultBoolean(defaultValue: Boolean) : DefaultValues(defaultValue.toString(), typeOf<Boolean>(), typeOf<Boolean>())
|
||||
|
||||
object BooleanFalseDefault : DefaultBoolean(false)
|
||||
|
||||
object BooleanTrueDefault : DefaultBoolean(true)
|
||||
|
||||
object StringNullDefault : DefaultValues("null", typeOf<String?>(), typeOf<String?>())
|
||||
|
||||
object EmptyStringListDefault : DefaultValues("emptyList<String>()", typeOf<List<String>>(), typeOf<List<String>>())
|
||||
|
||||
object LanguageVersions : DefaultValues(
|
||||
"null",
|
||||
typeOf<KotlinVersionDsl?>(),
|
||||
typeOf<String?>(),
|
||||
possibleValues = LanguageVersion.values()
|
||||
.filterNot { it.isUnsupported }
|
||||
.map { "\"${it.description}\"" },
|
||||
fromKotlinOptionConverterProp = """
|
||||
if (this != null) ${typeOf<KotlinVersionDsl>()}.fromVersion(this) else null
|
||||
""".trimIndent(),
|
||||
toKotlinOptionConverterProp = """
|
||||
this?.version
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
object ApiVersions : DefaultValues(
|
||||
"null",
|
||||
typeOf<KotlinVersionDsl?>(),
|
||||
typeOf<String?>(),
|
||||
possibleValues = LanguageVersion.values()
|
||||
.map(ApiVersion.Companion::createByLanguageVersion)
|
||||
.filterNot { it.isUnsupported }
|
||||
.map { "\"${it.description}\"" },
|
||||
fromKotlinOptionConverterProp = """
|
||||
if (this != null) ${typeOf<KotlinVersionDsl>()}.fromVersion(this) else null
|
||||
""".trimIndent(),
|
||||
toKotlinOptionConverterProp = """
|
||||
this?.version
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
object JvmTargetVersions : DefaultValues(
|
||||
"null",
|
||||
typeOf<JvmTargetDsl?>(),
|
||||
typeOf<String?>(),
|
||||
possibleValues = JvmTarget.supportedValues().map { "\"${it.description}\"" },
|
||||
fromKotlinOptionConverterProp = """
|
||||
if (this != null) ${typeOf<JvmTargetDsl>()}.fromTarget(this) else null
|
||||
""".trimIndent(),
|
||||
toKotlinOptionConverterProp = """
|
||||
this?.target
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
object JsEcmaVersions : DefaultValues(
|
||||
"\"v5\"",
|
||||
typeOf<String>(),
|
||||
typeOf<String>(),
|
||||
possibleValues = listOf("\"v5\"")
|
||||
)
|
||||
|
||||
object JsModuleKinds : DefaultValues(
|
||||
"${typeOf<JsModuleKind>()}.${JsModuleKind.MODULE_PLAIN.name}",
|
||||
typeOf<JsModuleKind>(),
|
||||
typeOf<String>(),
|
||||
possibleValues = listOf("\"plain\"", "\"amd\"", "\"commonjs\"", "\"umd\""),
|
||||
fromKotlinOptionConverterProp = """
|
||||
${typeOf<JsModuleKind>()}.fromKind(this)
|
||||
""".trimIndent(),
|
||||
toKotlinOptionConverterProp = """
|
||||
this.kind
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
object JsSourceMapContentModes : DefaultValues(
|
||||
"null",
|
||||
typeOf<JsSourceMapEmbedMode?>(),
|
||||
typeOf<String?>(),
|
||||
possibleValues = listOf(
|
||||
K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_NEVER,
|
||||
K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_ALWAYS,
|
||||
K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_INLINING
|
||||
).map { "\"$it\"" },
|
||||
fromKotlinOptionConverterProp = """
|
||||
this?.let { ${typeOf<JsSourceMapEmbedMode>()}.fromMode(it) }
|
||||
""".trimIndent(),
|
||||
toKotlinOptionConverterProp = """
|
||||
this?.mode
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
object JsSourceMapNamesPolicies : DefaultValues(
|
||||
"null",
|
||||
typeOf<JsSourceMapNamesPolicy?>(),
|
||||
typeOf<String?>(),
|
||||
possibleValues = listOf(
|
||||
K2JsArgumentConstants.SOURCE_MAP_NAMES_POLICY_NO,
|
||||
K2JsArgumentConstants.SOURCE_MAP_NAMES_POLICY_SIMPLE_NAMES,
|
||||
K2JsArgumentConstants.SOURCE_MAP_NAMES_POLICY_FQ_NAMES,
|
||||
).map { "\"$it\"" },
|
||||
fromKotlinOptionConverterProp = """
|
||||
this?.let { ${typeOf<JsSourceMapNamesPolicy>()}.fromPolicy(it) }
|
||||
""".trimIndent(),
|
||||
toKotlinOptionConverterProp = """
|
||||
this?.policy
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
object JsMain : DefaultValues(
|
||||
"${typeOf<JsMainFunctionExecutionMode>()}.${JsMainFunctionExecutionMode.CALL.name}",
|
||||
typeOf<JsMainFunctionExecutionMode>(),
|
||||
typeOf<String>(),
|
||||
possibleValues = listOf("\"" + CALL + "\"", "\"" + NO_CALL + "\""),
|
||||
fromKotlinOptionConverterProp = """
|
||||
${typeOf<JsMainFunctionExecutionMode>()}.fromMode(this)
|
||||
""".trimIndent(),
|
||||
toKotlinOptionConverterProp = """
|
||||
this.mode
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
+19
-1
@@ -20,14 +20,32 @@ import kotlin.reflect.KClass
|
||||
import kotlin.reflect.KVisibility
|
||||
|
||||
/**
|
||||
* @param value should be one of [DefaultValue] constants
|
||||
* @param gradleInputType should be one of [GradleInputTypes] constants
|
||||
*/
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
annotation class GradleOption(
|
||||
val value: KClass<out DefaultValues>,
|
||||
val value: Int,
|
||||
val gradleInputType: String
|
||||
)
|
||||
|
||||
// Enum class here is not possible due to bug in K2 compiler:
|
||||
// https://youtrack.jetbrains.com/issue/KT-54079
|
||||
object DefaultValue {
|
||||
const val BOOLEAN_FALSE_DEFAULT = 0
|
||||
const val BOOLEAN_TRUE_DEFAULT = 1
|
||||
const val STRING_NULL_DEFAULT = 2
|
||||
const val EMPTY_STRING_LIST_DEFAULT = 3
|
||||
const val LANGUAGE_VERSIONS = 4
|
||||
const val API_VERSIONS = 5
|
||||
const val JVM_TARGET_VERSIONS = 6
|
||||
const val JS_ECMA_VERSIONS = 7
|
||||
const val JS_MODULE_KINDS = 8
|
||||
const val JS_SOURCE_MAP_CONTENT_MODES = 9
|
||||
const val JS_MAIN = 10
|
||||
const val JS_SOURCE_MAP_NAMES_POLICY = 11
|
||||
}
|
||||
|
||||
// Enum class here is not possible due to bug in K2 compiler:
|
||||
// https://youtrack.jetbrains.com/issue/KT-54079
|
||||
object GradleInputTypes {
|
||||
|
||||
+13
-13
@@ -17,7 +17,7 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
||||
}
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValues.StringNullDefault::class,
|
||||
value = DefaultValue.STRING_NULL_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INTERNAL // handled by task 'outputFileProperty'
|
||||
)
|
||||
@GradleDeprecatedOption(
|
||||
@@ -32,14 +32,14 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
||||
var outputDir: String? by NullableStringFreezableVar(null)
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValues.StringNullDefault::class,
|
||||
value = DefaultValue.STRING_NULL_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
)
|
||||
@Argument(value = "-ir-output-name", description = "Base name of generated files")
|
||||
var moduleName: String? by NullableStringFreezableVar(null)
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValues.BooleanTrueDefault::class,
|
||||
value = DefaultValue.BOOLEAN_TRUE_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
)
|
||||
@Argument(value = "-no-stdlib", description = "Don't automatically include the default Kotlin/JS stdlib into compilation dependencies")
|
||||
@@ -60,14 +60,14 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
||||
var repositries: String? by NullableStringFreezableVar(null)
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValues.BooleanFalseDefault::class,
|
||||
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
)
|
||||
@Argument(value = "-source-map", description = "Generate source map")
|
||||
var sourceMap: Boolean by FreezableVar(false)
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValues.StringNullDefault::class,
|
||||
value = DefaultValue.STRING_NULL_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
)
|
||||
@Argument(value = "-source-map-prefix", description = "Add the specified prefix to paths in the source map")
|
||||
@@ -86,7 +86,7 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
||||
* When sourceMapEmbedSources are not null and source maps is disabled warning is reported.
|
||||
*/
|
||||
@GradleOption(
|
||||
value = DefaultValues.JsSourceMapContentModes::class,
|
||||
value = DefaultValue.JS_SOURCE_MAP_CONTENT_MODES,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
)
|
||||
@Argument(
|
||||
@@ -97,7 +97,7 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
||||
var sourceMapEmbedSources: String? by NullableStringFreezableVar(null)
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValues.JsSourceMapNamesPolicies::class,
|
||||
value = DefaultValue.JS_SOURCE_MAP_NAMES_POLICY,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
)
|
||||
@Argument(
|
||||
@@ -108,14 +108,14 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
||||
var sourceMapNamesPolicy: String? by NullableStringFreezableVar(null)
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValues.BooleanTrueDefault::class,
|
||||
value = DefaultValue.BOOLEAN_TRUE_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
)
|
||||
@Argument(value = "-meta-info", description = "Generate .meta.js and .kjsm files with metadata. Use to create a library")
|
||||
var metaInfo: Boolean by FreezableVar(false)
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValues.JsEcmaVersions::class,
|
||||
value = DefaultValue.JS_ECMA_VERSIONS,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
)
|
||||
@Argument(value = "-target", valueDescription = "{ v5 }", description = "Generate JS files for specific ECMA version")
|
||||
@@ -129,7 +129,7 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
||||
var irKeep: String? by NullableStringFreezableVar(null)
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValues.JsModuleKinds::class,
|
||||
value = DefaultValue.JS_MODULE_KINDS,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
)
|
||||
@Argument(
|
||||
@@ -140,7 +140,7 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
||||
var moduleKind: String? by NullableStringFreezableVar(K2JsArgumentConstants.MODULE_PLAIN)
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValues.JsMain::class,
|
||||
value = DefaultValue.JS_MAIN,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
)
|
||||
@Argument(
|
||||
@@ -280,14 +280,14 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
||||
var strictImplicitExportType: Boolean by FreezableVar(false)
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValues.BooleanTrueDefault::class,
|
||||
value = DefaultValue.BOOLEAN_TRUE_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
)
|
||||
@Argument(value = "-Xtyped-arrays", description = "Translate primitive arrays to JS typed arrays")
|
||||
var typedArrays: Boolean by FreezableVar(true)
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValues.BooleanFalseDefault::class,
|
||||
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
)
|
||||
@Argument(value = "-Xfriend-modules-disabled", description = "Disable internal declaration export")
|
||||
|
||||
+2
-2
@@ -14,7 +14,7 @@ class K2JSDceArguments : CommonToolArguments() {
|
||||
}
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValues.StringNullDefault::class,
|
||||
value = DefaultValue.STRING_NULL_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INTERNAL // handled by 'destinationDirectory'
|
||||
)
|
||||
@GradleDeprecatedOption(
|
||||
@@ -43,7 +43,7 @@ class K2JSDceArguments : CommonToolArguments() {
|
||||
var printReachabilityInfo: Boolean by FreezableVar(false)
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValues.BooleanFalseDefault::class,
|
||||
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
)
|
||||
@Argument(
|
||||
|
||||
+4
-4
@@ -37,7 +37,7 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
||||
var jdkHome: String? by NullableStringFreezableVar(null)
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValues.BooleanFalseDefault::class,
|
||||
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
)
|
||||
@Argument(value = "-no-jdk", description = "Don't automatically include the Java runtime into the classpath")
|
||||
@@ -67,14 +67,14 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
||||
var scriptTemplates: Array<String>? by FreezableVar(null)
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValues.StringNullDefault::class,
|
||||
value = DefaultValue.STRING_NULL_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
)
|
||||
@Argument(value = "-module-name", valueDescription = "<name>", description = "Name of the generated .kotlin_module file")
|
||||
var moduleName: String? by NullableStringFreezableVar(null)
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValues.JvmTargetVersions::class,
|
||||
value = DefaultValue.JVM_TARGET_VERSIONS,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
)
|
||||
@Argument(
|
||||
@@ -85,7 +85,7 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
||||
var jvmTarget: String? by NullableStringFreezableVar(null)
|
||||
|
||||
@GradleOption(
|
||||
value = DefaultValues.BooleanFalseDefault::class,
|
||||
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
|
||||
gradleInputType = GradleInputTypes.INPUT
|
||||
)
|
||||
@Argument(value = "-java-parameters", description = "Generate metadata for Java 1.8 reflection on method parameters")
|
||||
|
||||
Reference in New Issue
Block a user