Fixed import of JS source sets with Both mode
Added flag indicating that source set naming contract is violated. In this case disambiguition classifier is ignored in IDE. #KT-37562 Fixed
This commit is contained in:
@@ -354,7 +354,12 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
|
||||
val getDisambiguationClassifier = targetClass.getMethodOrNull("getDisambiguationClassifier") ?: return null
|
||||
val platformId = (getPlatformType.invoke(gradleTarget) as? Named)?.name ?: return null
|
||||
val platform = KotlinPlatform.byId(platformId) ?: return null
|
||||
val disambiguationClassifier = getDisambiguationClassifier(gradleTarget) as? String
|
||||
val useDisambiguationClassifier =
|
||||
targetClass.getMethodOrNull("getUseDisambiguitionClassifierAsSourcesetNamePreffix")?.invoke(gradleTarget) as? Boolean ?: true
|
||||
val disambiguationClassifier = if (useDisambiguationClassifier)
|
||||
getDisambiguationClassifier(gradleTarget) as? String
|
||||
else
|
||||
null
|
||||
val getPreset = targetClass.getMethodOrNull("getPreset")
|
||||
val targetPresetName: String?
|
||||
targetPresetName = try {
|
||||
|
||||
+1
@@ -28,6 +28,7 @@ interface KotlinTargetComponent : SoftwareComponent {
|
||||
interface KotlinTarget : Named, HasAttributes {
|
||||
val targetName: String
|
||||
val disambiguationClassifier: String? get() = targetName
|
||||
val useDisambiguitionClassifierAsSourcesetNamePreffix: Boolean
|
||||
|
||||
val platformType: KotlinPlatformType
|
||||
|
||||
|
||||
+4
@@ -21,12 +21,16 @@ abstract class KotlinOnlyTargetPreset<R : KotlinOnlyTarget<T>, T : KotlinCompila
|
||||
protected open fun provideTargetDisambiguationClassifier(target: KotlinOnlyTarget<T>): String? =
|
||||
target.targetName
|
||||
|
||||
// This function is used in IDE import in order to indicate that sourceSetName=disambiguitionClassifier+compilationName
|
||||
protected open fun useDisambiguitionClassifierAsSourcesetNamePreffix() = true
|
||||
|
||||
abstract protected fun instantiateTarget(name: String): R
|
||||
|
||||
override fun createTarget(name: String): R {
|
||||
val result = instantiateTarget(name).apply {
|
||||
targetName = name
|
||||
disambiguationClassifier = provideTargetDisambiguationClassifier(this@apply)
|
||||
useDisambiguitionClassifierAsSourcesetNamePreffix = useDisambiguitionClassifierAsSourcesetNamePreffix()
|
||||
preset = this@KotlinOnlyTargetPreset
|
||||
|
||||
val compilationFactory = createCompilationFactory(this)
|
||||
|
||||
+3
@@ -44,6 +44,9 @@ abstract class AbstractKotlinTarget(
|
||||
override val defaultConfigurationName: String
|
||||
get() = disambiguateName("default")
|
||||
|
||||
override var useDisambiguitionClassifierAsSourcesetNamePreffix: Boolean = true
|
||||
internal set
|
||||
|
||||
override val apiElementsConfigurationName: String
|
||||
get() = disambiguateName("apiElements")
|
||||
|
||||
|
||||
+3
@@ -88,6 +88,9 @@ class KotlinJsSingleTargetPreset(
|
||||
project,
|
||||
kotlinPluginVersion
|
||||
) {
|
||||
|
||||
override fun useDisambiguitionClassifierAsSourcesetNamePreffix() = false
|
||||
|
||||
// In a Kotlin/JS single-platform project, we don't need any disambiguation suffixes or prefixes in the names:
|
||||
override fun provideTargetDisambiguationClassifier(target: KotlinOnlyTarget<KotlinJsCompilation>): String? =
|
||||
irPreset?.let {
|
||||
|
||||
Reference in New Issue
Block a user