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
This commit is contained in:
Sergey Igushkin
2022-02-01 00:43:42 +04:00
committed by Space
parent 29fe11b957
commit c21123cec8
@@ -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<KotlinGradleVariant> {
artifact(project.locateOrRegisterTask<Jar>(fragment.outputsJarTaskName) {
val jar = project.locateOrRegisterTask<Jar>(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