[Gradle] Keep kotlinSourcesJar in Kotlin/JVM projects
After introducing sourcesElements for Multiplatform projects the task was not registered. As result of an assumption that Java Gradle Plugin is taking care of sources publication. But in fact some users can still rely on Kotlin's `kotlinSourceJar` task instead of JGP's `sourcesJar`. This look inconsistent and is a matter of a different issue: KT-54207 ^KT-36943
This commit is contained in:
+4
-2
@@ -133,11 +133,13 @@ abstract class AbstractKotlinTarget(
|
||||
classifierPrefix: String? = null,
|
||||
sourcesElementsConfigurationName: String = this.sourcesElementsConfigurationName,
|
||||
): PublishArtifact? {
|
||||
val sourcesJarTask = sourcesJarTask(producingCompilation, componentName, artifactNameAppendix)
|
||||
|
||||
// If sourcesElements configuration not found, don't create artifact.
|
||||
// This can happen in pure JVM plugin where source publication is delegated to Java Gradle Plugin
|
||||
// This can happen in pure JVM plugin where source publication is delegated to Java Gradle Plugin.
|
||||
// But we still want to have sourcesJarTask be registered
|
||||
project.configurations.findByName(sourcesElementsConfigurationName) ?: return null
|
||||
|
||||
val sourcesJarTask = sourcesJarTask(producingCompilation, componentName, artifactNameAppendix)
|
||||
val artifact = project.artifacts.add(sourcesElementsConfigurationName, sourcesJarTask) as ConfigurablePublishArtifact
|
||||
artifact.classifier = dashSeparatedName(classifierPrefix, "sources")
|
||||
return artifact
|
||||
|
||||
Reference in New Issue
Block a user