@@ -183,6 +183,13 @@ tasks {
183183 }
184184 }
185185
186+ val javaOnlySourcesJar by creating(Jar ::class ) {
187+ from(kotlin.sourceSets[" jvmMain" ].kotlin) {
188+ into(" ." )
189+ }
190+ archiveClassifier.set(" sources" )
191+ }
192+
186193 val allMetadataJar by existing(Jar ::class ) {
187194 archiveClassifier.set(" common" )
188195 }
@@ -203,6 +210,10 @@ nexusPublishing {
203210}
204211
205212configurations {
213+ create(" javaOnlySourcesElements" ) {
214+ copyAttributes(configurations.findByName(" jvmSourcesElements" )!! .attributes, attributes)
215+ }
216+
206217 create(" javadocElements" ) {
207218 attributes {
208219 attribute(Category .CATEGORY_ATTRIBUTE , project.objects.named(Category ::class .java, Category .DOCUMENTATION ))
@@ -214,6 +225,7 @@ configurations {
214225}
215226
216227artifacts {
228+ add(" javaOnlySourcesElements" , tasks.getByName(" javaOnlySourcesJar" ))
217229 add(" javadocElements" , tasks.getByName(" javadocJar" ))
218230}
219231
@@ -244,7 +256,7 @@ publishing {
244256 variant(" jvmRuntimeElements" ) {
245257 configureVariantDetails { mapToMavenScope(" runtime" ) }
246258 }
247- variant(" jvmSourcesElements " )
259+ variant(" javaOnlySourcesElements " )
248260 variant(" javadocElements" )
249261 }
250262 val targetModules = kotlin.targets.filter { it.targetName != " jvm" && it.targetName != " metadata" }.map { target ->
0 commit comments