@@ -13,6 +13,7 @@ import org.gradle.api.attributes.HasConfigurableAttributes
1313import org.gradle.api.attributes.Usage
1414import org.gradle.api.attributes.Usage.USAGE_ATTRIBUTE
1515import org.gradle.api.file.FileCollection
16+ import org.gradle.api.file.RegularFile
1617import org.gradle.api.provider.Provider
1718import org.gradle.api.publish.plugins.PublishingPlugin.PUBLISH_TASK_GROUP
1819import org.gradle.api.tasks.bundling.Zip
@@ -53,8 +54,9 @@ internal fun Project.registerPublishToCentralPortalTasks(
5354 kind : Kind ,
5455 inputFiles : FileCollection ,
5556 spec : CentralPortalOptions ,
56- allowEmptyFiles : Provider <Boolean >
57- ) {
57+ allowEmptyFiles : Provider <Boolean >,
58+ publishAllChecksums : Provider <Boolean >
59+ ): Provider <RegularFile > {
5860 val name = kind.name
5961
6062 val releaseTaskName = " nmcpPublish${name.capitalizeFirstLetter()} ToCentralPortal"
@@ -84,19 +86,31 @@ internal fun Project.registerPublishToCentralPortalTasks(
8486 it.destinationDirectory.set(project.layout.buildDirectory.dir(" nmcp/zip" ))
8587 it.archiveFileName.set(zipName)
8688 it.eachFile {
87- // Exclude maven-metadata files, or the bundle is not recognized
88- // See https://slack-chats.kotlinlang.org/t/16407246/anyone-tried-the-https-central-sonatype-org-publish-publish-#c8738fe5-8051-4f64-809f-ca67a645216e
89- if (it.name.startsWith(" maven-metadata" )) {
90- it.exclude()
89+ val publishAllChecksums = publishAllChecksums.getOrElse(false )
90+ when {
91+ it.name.startsWith(" maven-metadata" ) -> {
92+ // Exclude maven-metadata files, or the bundle is not recognized
93+ // See https://slack-chats.kotlinlang.org/t/16407246/anyone-tried-the-https-central-sonatype-org-publish-publish-#c8738fe5-8051-4f64-809f-ca67a645216e
94+ it.exclude()
95+ }
96+ ! publishAllChecksums && (it.name.endsWith(" .sha256" ) || it.name.endsWith(" .sha512" )) -> {
97+ // It's not clear if those are used, and it reduces the number of files in the deployment
98+ it.exclude()
99+ }
100+ ! publishAllChecksums && (it.name.endsWith(" .asc.md5" ) || it.name.endsWith(" .asc.sha1" )) -> {
101+ // It's not clear if those are used, and it reduces the number of files in the deployment
102+ it.exclude()
103+ }
91104 }
92105 }
93106 it.dependsOn(checkFilesTaskProvider)
94107 }
95108
109+ val zipProvider = zipTaskProvider.flatMap { it.archiveFile }
96110
97111 val releaseTask = registerNmcpPublishWithPublisherApiTask(
98112 taskName = releaseTaskName,
99- inputFile = zipTaskProvider.flatMap { it.archiveFile } ,
113+ inputFile = zipProvider ,
100114 username = spec.username,
101115 password = spec.password,
102116 publicationName = spec.publicationName.orElse(checkFilesTaskProvider.flatMap { it.outputFile }.map { it.asFile.readText() }),
@@ -148,7 +162,7 @@ internal fun Project.registerPublishToCentralPortalTasks(
148162 registerNmcpPublishFileByFileToFileSystemTask(
149163 taskName = localTaskName,
150164 m2AbsolutePath = project.provider { m2File.absolutePath },
151- inputFiles = inputFiles ,
165+ inputFiles = zipTree(zipProvider) ,
152166 parallelism = spec.uploadSnapshotsParallelism.orElse(defaultParallelism),
153167 )
154168
@@ -171,6 +185,8 @@ internal fun Project.registerPublishToCentralPortalTasks(
171185 }
172186 }
173187 }
188+
189+ return zipProvider
174190}
175191
176192private fun taskPath (project : Project , taskName : String ): String {
0 commit comments