[Gradle, JS] Disambiguation classifier consider single platform plugin
This commit is contained in:
+8
-2
@@ -30,5 +30,11 @@ enum class JsCompilerType : Named, Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
fun String.removeCapitalizedJsCompilerSuffix(compilerType: JsCompilerType): String =
|
||||
removeSuffix(compilerType.name.capitalize())
|
||||
fun String.removeJsCompilerSuffix(compilerType: JsCompilerType): String {
|
||||
val truncatedString = removeSuffix(compilerType.name)
|
||||
if (this != truncatedString) {
|
||||
return truncatedString
|
||||
}
|
||||
|
||||
return removeSuffix(compilerType.name.capitalize())
|
||||
}
|
||||
+3
-2
@@ -12,7 +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.plugin.removeJsCompilerSuffix
|
||||
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.PackageJson
|
||||
import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile
|
||||
@@ -38,7 +38,8 @@ open class KotlinJsCompilation(
|
||||
override val defaultSourceSetName: String
|
||||
get() = lowerCamelCaseName(
|
||||
(target as KotlinJsTarget).irTarget?.let {
|
||||
target.disambiguationClassifier?.removeCapitalizedJsCompilerSuffix(JsCompilerType.legacy)
|
||||
target.disambiguationClassifier
|
||||
?.removeJsCompilerSuffix(JsCompilerType.legacy)
|
||||
} ?: target.disambiguationClassifier,
|
||||
compilationName
|
||||
)
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ constructor(
|
||||
): KotlinVariant {
|
||||
return super.createKotlinVariant(componentName, compilation, usageContexts).apply {
|
||||
irTarget?.let {
|
||||
artifactTargetName = targetName.removeCapitalizedJsCompilerSuffix(JsCompilerType.legacy)
|
||||
artifactTargetName = targetName.removeJsCompilerSuffix(JsCompilerType.legacy)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -11,7 +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.plugin.removeJsCompilerSuffix
|
||||
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget
|
||||
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTargetConfigurator
|
||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTargetPreset
|
||||
@@ -37,7 +37,7 @@ open class KotlinJsTargetPreset(
|
||||
platformType
|
||||
).apply {
|
||||
this.irTarget = irPreset?.createTarget(
|
||||
lowerCamelCaseName(name.removeCapitalizedJsCompilerSuffix(JsCompilerType.legacy), JsCompilerType.ir.name)
|
||||
lowerCamelCaseName(name.removeJsCompilerSuffix(JsCompilerType.legacy), JsCompilerType.ir.name)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -73,7 +73,7 @@ class KotlinJsSingleTargetPreset(
|
||||
override fun provideTargetDisambiguationClassifier(target: KotlinOnlyTarget<KotlinJsCompilation>): String? =
|
||||
irPreset?.let {
|
||||
super.provideTargetDisambiguationClassifier(target)
|
||||
?.removePrefix(target.name.removeCapitalizedJsCompilerSuffix(JsCompilerType.legacy))
|
||||
?.removePrefix(target.name.removeJsCompilerSuffix(JsCompilerType.legacy))
|
||||
?.decapitalize()
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ class KotlinJsIrCompilation(
|
||||
return lowerCamelCaseName(
|
||||
if ((target as KotlinJsIrTarget).mixedMode)
|
||||
target.disambiguationClassifier
|
||||
?.removeCapitalizedJsCompilerSuffix(JsCompilerType.ir)
|
||||
?.removeJsCompilerSuffix(JsCompilerType.ir)
|
||||
else
|
||||
target.disambiguationClassifier,
|
||||
compilationName
|
||||
|
||||
+2
-2
@@ -12,7 +12,7 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinCompilationFactory
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinOnlyTarget
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinOnlyTargetPreset
|
||||
import org.jetbrains.kotlin.gradle.plugin.removeCapitalizedJsCompilerSuffix
|
||||
import org.jetbrains.kotlin.gradle.plugin.removeJsCompilerSuffix
|
||||
import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName
|
||||
|
||||
open class KotlinJsIrTargetPreset(
|
||||
@@ -61,7 +61,7 @@ class KotlinJsIrSingleTargetPreset(
|
||||
override fun provideTargetDisambiguationClassifier(target: KotlinOnlyTarget<KotlinJsIrCompilation>): String? {
|
||||
return if (mixedMode!!) {
|
||||
super.provideTargetDisambiguationClassifier(target)
|
||||
?.removePrefix(target.name.removeCapitalizedJsCompilerSuffix(JsCompilerType.ir))
|
||||
?.removePrefix(target.name.removeJsCompilerSuffix(JsCompilerType.ir))
|
||||
?.decapitalize()
|
||||
} else {
|
||||
null
|
||||
|
||||
Reference in New Issue
Block a user