If a target has no main compilation, don't create a sources JAR

Currently, Android libraries are not published as a part of an MPP
library, and building no sources JAR for them is OK.

Issue #KT-26390
This commit is contained in:
Sergey Igushkin
2018-09-06 12:32:06 +03:00
committed by Ilya Matveev
parent 779030da1b
commit 699cff27a7
@@ -139,7 +139,8 @@ class KotlinMultiplatformPlugin(
private fun configureSourceJars(project: Project) = with(project.kotlinExtension as KotlinMultiplatformExtension) {
targets.all { target ->
val mainCompilation = target.compilations.getByName(KotlinCompilation.MAIN_COMPILATION_NAME)
val mainCompilation = target.compilations.findByName(KotlinCompilation.MAIN_COMPILATION_NAME)
// If a target has no `main` compilation (e.g. Android), don't create the source JAR
?: return@all
val sourcesJar = project.tasks.create(target.sourcesJarTaskName, Jar::class.java) { sourcesJar ->