[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.
|
* 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 platformId = (getPlatformType.invoke(gradleTarget) as? Named)?.name ?: return null
|
||||||
val platform = KotlinPlatform.byId(platformId) ?: return null
|
val platform = KotlinPlatform.byId(platformId) ?: return null
|
||||||
val useDisambiguationClassifier =
|
val useDisambiguationClassifier =
|
||||||
targetClass.getMethodOrNull("getUseDisambiguitionClassifierAsSourcesetNamePreffix")?.invoke(gradleTarget) as? Boolean ?: true
|
targetClass.getMethodOrNull("getUseDisambiguationClassifierAsSourceSetNamePrefix")?.invoke(gradleTarget) as? Boolean ?: true
|
||||||
val disambiguationClassifier = if (useDisambiguationClassifier)
|
val disambiguationClassifier = if (useDisambiguationClassifier)
|
||||||
getDisambiguationClassifier(gradleTarget) as? String
|
getDisambiguationClassifier(gradleTarget) as? String
|
||||||
else {
|
else {
|
||||||
targetClass.getMethodOrNull("getOverrideDisambiguitionClassifierOnIdeImport")?.invoke(gradleTarget) as? String
|
targetClass.getMethodOrNull("getOverrideDisambiguationClassifierOnIdeImport")?.invoke(gradleTarget) as? String
|
||||||
}
|
}
|
||||||
val getPreset = targetClass.getMethodOrNull("getPreset")
|
val getPreset = targetClass.getMethodOrNull("getPreset")
|
||||||
val targetPresetName: String?
|
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.
|
* 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 {
|
interface KotlinTarget : Named, HasAttributes {
|
||||||
val targetName: String
|
val targetName: String
|
||||||
val disambiguationClassifier: String? get() = targetName
|
val disambiguationClassifier: String? get() = targetName
|
||||||
val useDisambiguitionClassifierAsSourcesetNamePreffix: Boolean
|
val useDisambiguationClassifierAsSourceSetNamePrefix: Boolean
|
||||||
val overrideDisambiguitionClassifierOnIdeImport: String?
|
val overrideDisambiguationClassifierOnIdeImport: String?
|
||||||
|
|
||||||
val platformType: KotlinPlatformType
|
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? =
|
protected open fun provideTargetDisambiguationClassifier(target: KotlinOnlyTarget<T>): String? =
|
||||||
target.targetName
|
target.targetName
|
||||||
|
|
||||||
// This function is used in IDE import in order to indicate that sourceSetName=disambiguitionClassifier+compilationName
|
// This function is used in IDE import in order to indicate that sourceSetName=disambiguationClassifier+compilationName
|
||||||
protected open fun useDisambiguitionClassifierAsSourcesetNamePreffix() = true
|
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
|
abstract protected fun instantiateTarget(name: String): R
|
||||||
|
|
||||||
@@ -32,8 +33,8 @@ abstract class KotlinOnlyTargetPreset<R : KotlinOnlyTarget<T>, T : KotlinCompila
|
|||||||
val result = instantiateTarget(name).apply {
|
val result = instantiateTarget(name).apply {
|
||||||
targetName = name
|
targetName = name
|
||||||
disambiguationClassifier = provideTargetDisambiguationClassifier(this@apply)
|
disambiguationClassifier = provideTargetDisambiguationClassifier(this@apply)
|
||||||
useDisambiguitionClassifierAsSourcesetNamePreffix = useDisambiguitionClassifierAsSourcesetNamePreffix()
|
useDisambiguationClassifierAsSourceSetNamePrefix = useDisambiguationClassifierAsSourceSetNamePrefix()
|
||||||
overrideDisambiguitionClassifierOnIdeImport = overrideDisambiguitionClassifierOnIdeImport(name)
|
overrideDisambiguationClassifierOnIdeImport = overrideDisambiguationClassifierOnIdeImport(name)
|
||||||
preset = this@KotlinOnlyTargetPreset
|
preset = this@KotlinOnlyTargetPreset
|
||||||
|
|
||||||
val compilationFactory = createCompilationFactory(this)
|
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.artifacts.PublishArtifact
|
||||||
import org.gradle.api.attributes.Attribute
|
import org.gradle.api.attributes.Attribute
|
||||||
import org.gradle.api.attributes.AttributeContainer
|
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.attributes.Usage.JAVA_RUNTIME_JARS
|
||||||
import org.gradle.api.component.ComponentWithCoordinates
|
import org.gradle.api.component.ComponentWithCoordinates
|
||||||
import org.gradle.api.component.ComponentWithVariants
|
import org.gradle.api.component.ComponentWithVariants
|
||||||
@@ -43,10 +42,10 @@ abstract class AbstractKotlinTarget(
|
|||||||
override val defaultConfigurationName: String
|
override val defaultConfigurationName: String
|
||||||
get() = disambiguateName("default")
|
get() = disambiguateName("default")
|
||||||
|
|
||||||
override var useDisambiguitionClassifierAsSourcesetNamePreffix: Boolean = true
|
override var useDisambiguationClassifierAsSourceSetNamePrefix: Boolean = true
|
||||||
internal set
|
internal set
|
||||||
|
|
||||||
override var overrideDisambiguitionClassifierOnIdeImport: String? = null
|
override var overrideDisambiguationClassifierOnIdeImport: String? = null
|
||||||
internal set
|
internal set
|
||||||
|
|
||||||
override val apiElementsConfigurationName: String
|
override val apiElementsConfigurationName: String
|
||||||
|
|||||||
+5
-5
@@ -31,15 +31,12 @@ open class KotlinJsTargetPreset(
|
|||||||
override val platformType: KotlinPlatformType
|
override val platformType: KotlinPlatformType
|
||||||
get() = KotlinPlatformType.js
|
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 {
|
irPreset?.let {
|
||||||
name.removeJsCompilerSuffix(KotlinJsCompilerType.LEGACY)
|
name.removeJsCompilerSuffix(KotlinJsCompilerType.LEGACY)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun instantiateTarget(name: String): KotlinJsTarget {
|
override fun instantiateTarget(name: String): KotlinJsTarget {
|
||||||
return project.objects.newInstance(
|
return project.objects.newInstance(
|
||||||
@@ -105,6 +102,9 @@ class KotlinJsSingleTargetPreset(
|
|||||||
override val isMpp: Boolean
|
override val isMpp: Boolean
|
||||||
get() = false
|
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:
|
// 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? =
|
override fun provideTargetDisambiguationClassifier(target: KotlinOnlyTarget<KotlinJsCompilation>): String? =
|
||||||
irPreset?.let {
|
irPreset?.let {
|
||||||
|
|||||||
Reference in New Issue
Block a user