[Gradle, JS] Add isMpp property

#KT-38592 fixed
This commit is contained in:
Ilya Goncharov
2020-05-19 16:35:54 +03:00
parent 0b33e9430b
commit 22f5d3b134
5 changed files with 34 additions and 5 deletions
@@ -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.
*/
package org.jetbrains.kotlin.gradle.plugin.mpp
@@ -180,8 +180,7 @@ abstract class AbstractKotlinTarget(
return result
}
// TODO[Ilya Goncharov] fix internal on public when we remove legacy js
internal fun createUsageContexts(
internal open fun createUsageContexts(
producingCompilation: KotlinCompilation<*>
): Set<DefaultKotlinUsageContext> {
// Here, the Java Usage values are used intentionally as Gradle needs this for
@@ -80,6 +80,16 @@ constructor(
}
}
override fun createUsageContexts(producingCompilation: KotlinCompilation<*>): Set<DefaultKotlinUsageContext> {
return super.createUsageContexts(producingCompilation) +
DefaultKotlinUsageContext(
compilation = compilations.getByName(KotlinCompilation.MAIN_COMPILATION_NAME),
usage = project.usageByName("java-api-jars"),
dependencyConfigurationName = apiElementsConfigurationName,
overrideConfigurationArtifacts = emptySet()
)
}
override fun createKotlinVariant(
componentName: String,
compilation: KotlinCompilation<*>,
@@ -99,6 +109,10 @@ constructor(
.get()
var irTarget: KotlinJsIrTarget? = null
internal set
open var isMpp: Boolean? = null
internal set
val testTaskName get() = testRuns.getByName(KotlinTargetWithTests.DEFAULT_TEST_RUN_NAME).testTaskName
val testTask: TaskProvider<KotlinTestReport>
@@ -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.
*/
@@ -25,6 +25,9 @@ open class KotlinJsTargetPreset(
var irPreset: KotlinJsIrTargetPreset? = null
internal set
open val isMpp: Boolean
get() = true
override val platformType: KotlinPlatformType
get() = KotlinPlatformType.js
@@ -40,6 +43,7 @@ open class KotlinJsTargetPreset(
KotlinJsCompilerType.IR.lowerName
)
)
this.isMpp = this@KotlinJsTargetPreset.isMpp
project.whenEvaluated {
if (!isBrowserConfigured && !isNodejsConfigured) {
@@ -88,6 +92,8 @@ class KotlinJsSingleTargetPreset(
project,
kotlinPluginVersion
) {
override val isMpp: Boolean
get() = false
override fun useDisambiguitionClassifierAsSourcesetNamePreffix() = false
@@ -36,6 +36,9 @@ constructor(
override lateinit var testRuns: NamedDomainObjectContainer<KotlinJsReportAggregatingTestRun>
internal set
open var isMpp: Boolean? = null
internal set
override var moduleName: String? = null
set(value) {
check(!isBrowserConfigured && !isNodejsConfigured) {
@@ -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.
*/
@@ -21,11 +21,15 @@ open class KotlinJsIrTargetPreset(
) {
internal var mixedMode: Boolean? = null
open val isMpp: Boolean
get() = true
override val platformType: KotlinPlatformType
get() = KotlinPlatformType.js
override fun instantiateTarget(name: String): KotlinJsIrTarget {
return project.objects.newInstance(KotlinJsIrTarget::class.java, project, platformType, mixedMode).apply {
this.isMpp = this@KotlinJsIrTargetPreset.isMpp
if (!mixedMode) {
project.whenEvaluated {
if (!isBrowserConfigured && !isNodejsConfigured) {
@@ -74,6 +78,9 @@ class KotlinJsIrSingleTargetPreset(
project,
kotlinPluginVersion
) {
override val isMpp: Boolean
get() = 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<KotlinJsIrCompilation>): String? {
return if (mixedMode!!) {