[Gradle, JS] Refactor with remove copypaste
This commit is contained in:
+4
-1
@@ -28,4 +28,7 @@ enum class JsCompilerType : Named, Serializable {
|
||||
JsCompilerType
|
||||
.values().firstOrNull { it.name.equals(argument, ignoreCase = true) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun String.removeCapitalizedJsCompilerSuffix(compilerType: JsCompilerType): String =
|
||||
removeSuffix(compilerType.name.capitalize())
|
||||
+2
-1
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinJsOptions
|
||||
import org.jetbrains.kotlin.gradle.plugin.JsCompilerType
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilationWithResources
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
|
||||
import org.jetbrains.kotlin.gradle.plugin.removeCapitalizedJsCompilerSuffix
|
||||
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.PackageJson
|
||||
import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile
|
||||
@@ -37,7 +38,7 @@ open class KotlinJsCompilation(
|
||||
override val defaultSourceSetName: String
|
||||
get() = lowerCamelCaseName(
|
||||
(target as KotlinJsTarget).irTarget?.let {
|
||||
target.disambiguationClassifier?.removeSuffix(JsCompilerType.legacy.name.capitalize())
|
||||
target.disambiguationClassifier?.removeCapitalizedJsCompilerSuffix(JsCompilerType.legacy)
|
||||
} ?: target.disambiguationClassifier,
|
||||
compilationName
|
||||
)
|
||||
|
||||
+2
-1
@@ -11,6 +11,7 @@ package org.jetbrains.kotlin.gradle.plugin.mpp
|
||||
import org.gradle.api.Project
|
||||
import org.jetbrains.kotlin.gradle.plugin.JsCompilerType
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
||||
import org.jetbrains.kotlin.gradle.plugin.removeCapitalizedJsCompilerSuffix
|
||||
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget
|
||||
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTargetConfigurator
|
||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrSingleTargetPreset
|
||||
@@ -35,7 +36,7 @@ open class KotlinJsTargetPreset(
|
||||
platformType
|
||||
).apply {
|
||||
this.irTarget = irPreset?.createTarget(
|
||||
lowerCamelCaseName(name.removeSuffix(JsCompilerType.legacy.name.capitalize()), JsCompilerType.ir.name)
|
||||
lowerCamelCaseName(name.removeCapitalizedJsCompilerSuffix(JsCompilerType.legacy), JsCompilerType.ir.name)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-5
@@ -7,10 +7,7 @@ package org.jetbrains.kotlin.gradle.targets.js.ir
|
||||
|
||||
import org.gradle.api.file.SourceDirectorySet
|
||||
import org.gradle.api.tasks.TaskProvider
|
||||
import org.jetbrains.kotlin.gradle.plugin.JsCompilerType
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation
|
||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrType.DEVELOPMENT
|
||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrType.PRODUCTION
|
||||
@@ -51,7 +48,7 @@ class KotlinJsIrCompilation(
|
||||
return lowerCamelCaseName(
|
||||
if ((target as KotlinJsIrTarget).mixedMode)
|
||||
target.disambiguationClassifier
|
||||
?.removeSuffix(JsCompilerType.ir.name.capitalize())
|
||||
?.removeCapitalizedJsCompilerSuffix(JsCompilerType.ir)
|
||||
else
|
||||
target.disambiguationClassifier,
|
||||
compilationName
|
||||
|
||||
Reference in New Issue
Block a user