[Gradle, JS] Fix grammar in methods for JS import
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -366,11 +366,11 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
|
||||
val platformId = (getPlatformType.invoke(gradleTarget) as? Named)?.name ?: return null
|
||||
val platform = KotlinPlatform.byId(platformId) ?: return null
|
||||
val useDisambiguationClassifier =
|
||||
targetClass.getMethodOrNull("getUseDisambiguitionClassifierAsSourcesetNamePreffix")?.invoke(gradleTarget) as? Boolean ?: true
|
||||
targetClass.getMethodOrNull("getUseDisambiguationClassifierAsSourceSetNamePrefix")?.invoke(gradleTarget) as? Boolean ?: true
|
||||
val disambiguationClassifier = if (useDisambiguationClassifier)
|
||||
getDisambiguationClassifier(gradleTarget) as? String
|
||||
else {
|
||||
targetClass.getMethodOrNull("getOverrideDisambiguitionClassifierOnIdeImport")?.invoke(gradleTarget) as? String
|
||||
targetClass.getMethodOrNull("getOverrideDisambiguationClassifierOnIdeImport")?.invoke(gradleTarget) as? String
|
||||
}
|
||||
val getPreset = targetClass.getMethodOrNull("getPreset")
|
||||
val targetPresetName: String?
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -28,8 +28,8 @@ interface KotlinTargetComponent : SoftwareComponent {
|
||||
interface KotlinTarget : Named, HasAttributes {
|
||||
val targetName: String
|
||||
val disambiguationClassifier: String? get() = targetName
|
||||
val useDisambiguitionClassifierAsSourcesetNamePreffix: Boolean
|
||||
val overrideDisambiguitionClassifierOnIdeImport: String?
|
||||
val useDisambiguationClassifierAsSourceSetNamePrefix: Boolean
|
||||
val overrideDisambiguationClassifierOnIdeImport: String?
|
||||
|
||||
val platformType: KotlinPlatformType
|
||||
|
||||
|
||||
+6
-5
@@ -21,10 +21,11 @@ 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
|
||||
// This function is used in IDE import in order to indicate that sourceSetName=disambiguationClassifier+compilationName
|
||||
protected open fun useDisambiguationClassifierAsSourceSetNamePrefix() = true
|
||||
|
||||
protected open fun overrideDisambiguitionClassifierOnIdeImport(name: String): String? = null
|
||||
// This function is used in IDE import in order to override sourceSetName
|
||||
protected open fun overrideDisambiguationClassifierOnIdeImport(name: String): String? = null
|
||||
|
||||
abstract protected fun instantiateTarget(name: String): R
|
||||
|
||||
@@ -32,8 +33,8 @@ abstract class KotlinOnlyTargetPreset<R : KotlinOnlyTarget<T>, T : KotlinCompila
|
||||
val result = instantiateTarget(name).apply {
|
||||
targetName = name
|
||||
disambiguationClassifier = provideTargetDisambiguationClassifier(this@apply)
|
||||
useDisambiguitionClassifierAsSourcesetNamePreffix = useDisambiguitionClassifierAsSourcesetNamePreffix()
|
||||
overrideDisambiguitionClassifierOnIdeImport = overrideDisambiguitionClassifierOnIdeImport(name)
|
||||
useDisambiguationClassifierAsSourceSetNamePrefix = useDisambiguationClassifierAsSourceSetNamePrefix()
|
||||
overrideDisambiguationClassifierOnIdeImport = overrideDisambiguationClassifierOnIdeImport(name)
|
||||
preset = this@KotlinOnlyTargetPreset
|
||||
|
||||
val compilationFactory = createCompilationFactory(this)
|
||||
|
||||
+2
-3
@@ -13,7 +13,6 @@ import org.gradle.api.artifacts.ConfigurablePublishArtifact
|
||||
import org.gradle.api.artifacts.PublishArtifact
|
||||
import org.gradle.api.attributes.Attribute
|
||||
import org.gradle.api.attributes.AttributeContainer
|
||||
import org.gradle.api.attributes.Usage
|
||||
import org.gradle.api.attributes.Usage.JAVA_RUNTIME_JARS
|
||||
import org.gradle.api.component.ComponentWithCoordinates
|
||||
import org.gradle.api.component.ComponentWithVariants
|
||||
@@ -43,10 +42,10 @@ abstract class AbstractKotlinTarget(
|
||||
override val defaultConfigurationName: String
|
||||
get() = disambiguateName("default")
|
||||
|
||||
override var useDisambiguitionClassifierAsSourcesetNamePreffix: Boolean = true
|
||||
override var useDisambiguationClassifierAsSourceSetNamePrefix: Boolean = true
|
||||
internal set
|
||||
|
||||
override var overrideDisambiguitionClassifierOnIdeImport: String? = null
|
||||
override var overrideDisambiguationClassifierOnIdeImport: String? = null
|
||||
internal set
|
||||
|
||||
override val apiElementsConfigurationName: String
|
||||
|
||||
+5
-5
@@ -31,15 +31,12 @@ open class KotlinJsTargetPreset(
|
||||
override val platformType: KotlinPlatformType
|
||||
get() = KotlinPlatformType.js
|
||||
|
||||
override fun useDisambiguitionClassifierAsSourcesetNamePreffix() = irPreset == null
|
||||
override fun useDisambiguationClassifierAsSourceSetNamePrefix() = irPreset == null
|
||||
|
||||
override fun overrideDisambiguitionClassifierOnIdeImport(name: String): String? = if (isMpp) {
|
||||
override fun overrideDisambiguationClassifierOnIdeImport(name: String): String? =
|
||||
irPreset?.let {
|
||||
name.removeJsCompilerSuffix(KotlinJsCompilerType.LEGACY)
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
override fun instantiateTarget(name: String): KotlinJsTarget {
|
||||
return project.objects.newInstance(
|
||||
@@ -105,6 +102,9 @@ class KotlinJsSingleTargetPreset(
|
||||
override val isMpp: Boolean
|
||||
get() = false
|
||||
|
||||
override fun overrideDisambiguationClassifierOnIdeImport(name: String): String? =
|
||||
null
|
||||
|
||||
// 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