From c21123cec83c4aee83ade07624814d52da7ff146 Mon Sep 17 00:00:00 2001 From: Sergey Igushkin Date: Tue, 1 Feb 2022 00:43:42 +0400 Subject: [PATCH] KPM: Add the JVM JAR artifact to the projects `archives` configuration This automatically sets up the dependency between the `assemble` task and the task building the JAR --- .../pm20/KotlinFragmentCompilationOutputsJarArtifact.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/pm20/KotlinFragmentCompilationOutputsJarArtifact.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/pm20/KotlinFragmentCompilationOutputsJarArtifact.kt index 0e11f0ecf9c..afedff49584 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/pm20/KotlinFragmentCompilationOutputsJarArtifact.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/pm20/KotlinFragmentCompilationOutputsJarArtifact.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.gradle.plugin.mpp.pm20 +import org.gradle.api.artifacts.Dependency import org.gradle.jvm.tasks.Jar import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.disambiguateName import org.jetbrains.kotlin.gradle.tasks.locateOrRegisterTask @@ -14,10 +15,12 @@ import org.jetbrains.kotlin.gradle.utils.dashSeparatedName * Registers a [Jar] task with the variant's compilation outputs and attaches this artifact to the given configuration. */ val KotlinFragmentCompilationOutputsJarArtifact = FragmentArtifacts { - artifact(project.locateOrRegisterTask(fragment.outputsJarTaskName) { + val jar = project.locateOrRegisterTask(fragment.outputsJarTaskName) { it.from(fragment.compilationOutputs.allOutputs) it.archiveClassifier.set(dashSeparatedName(fragment.name, fragment.containingModule.moduleClassifier)) - }) + } + artifact(jar) + fragment.project.artifacts.add(Dependency.ARCHIVES_CONFIGURATION, jar) } internal val KotlinGradleVariant.outputsJarTaskName: String