Skip to content

Commit e9b247e

Browse files
authored
Advertise source jars for JVM-only libraries (#4394)
Original implementation: https://github.com/vanniktech/gradle-maven-publish-plugin/blob/f22bd35c84c3df28700db4ca3de11d5b78a29fde/plugin/src/main/kotlin/com/vanniktech/maven/publish/Platform.kt#L472 Thanks, @vanniktech! The issue with the replaced implementation is that it only packs the jar, without registering the publication variant. Checking the sources of `java { withSourcesJar() }`, we see the corresponding logic, but given that we can instead invoke it directly, no need to reimplement it. Fixes #4112
1 parent 6baf7c8 commit e9b247e

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

buildSrc/src/main/kotlin/pub-conventions.gradle.kts

+1-5
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,11 @@ publishing {
2222
apply(plugin = "java-library")
2323

2424
// MPP projects pack their sources automatically, java libraries need to explicitly pack them
25-
val sources = tasks.register("sourcesJar", Jar::class) {
26-
archiveClassifier = "sources"
27-
from(sourceSets.named("main").get().allSource)
28-
}
25+
project.extensions.getByType(JavaPluginExtension::class.java).withSourcesJar()
2926

3027
publications {
3128
register("mavenJava", MavenPublication::class) {
3229
from(components["java"])
33-
artifact(sources)
3430
}
3531
}
3632
}

0 commit comments

Comments
 (0)