uleming
03/04/2025, 8:11 AMzipBundle to publish/upload a java library to MavenCental which is bunch of jar files including hash and signatures.
The publish extension configured to prepared staging artifacts in local directory
repositories {
maven {
name = "localStaging"
// change URLs to point to your repos, e.g. <http://my.org/repo>
val releasesRepoUrl = uri(layout.buildDirectory.dir("repos/releases"))
val snapshotsRepoUrl = uri(layout.buildDirectory.dir("repos/snapshots"))
url = if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl
}
}
The publish extension dynamically generates several tasks, and one of them publishMavenJavaPublicationToLocalStagingRepository, generates all artifacts.
This tasks properly create necessary directory structure fit the MavenCentral requirements.
I left only to create a zip bundle which is very simple.
val zipBundle by tasks.registering(Zip::class) {
archiveFileName = "central-bundle.zip"
destinationDirectory = project.layout.buildDirectory.dir("distributions")
from(project.layout.buildDirectory.dir("repos/releases"))
}
But this has not direct binding between zipBundle tasks and publishMavenJavaPublicationToLocalStagingRepository.
I did succeed to bind task zipBundle to uploadToMavenCentral.
If i trigger uploadToMavenCentral it will trigger zipBundle as the output of zipBundle is the input for uploadToMavenCentral
Now I need to do the same between publishMavenJavaPublicationToLocalStagingRepository and zipBundle
This snippet
val dummy by tasks.registering {
var pb = tasks.getByName("publishMavenJavaPublicationToLocalStagingRepository")
println(pb.outputs.files.files)
}
show than generated publish tasks doens't declare the generated artifacts as an output of task.
Is there way to overcome it?Vampire
03/04/2025, 8:36 AMoutputs.dir to add the directory as output of the task to achieve the intended wiring.Philip W
03/04/2025, 1:56 PMuleming
03/06/2025, 6:37 AMoutputs.dir to add the directory as output of the task to achieve the intended wiring.
It did the trick, this part if not obvious in Javdoc how to declare outputs.dir but after playing couple of hours I archived it. Worth smooth.