Skip to content

Commit

Permalink
Source tarball - include file name in digest file
Browse files Browse the repository at this point in the history
Also fix two related Gradle deprecations
  • Loading branch information
snazy committed Nov 26, 2024
1 parent f6de118 commit 91d4000
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion build-logic/src/main/kotlin/publishing/MemoizedGitInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ internal class MemoizedGitInfo {
companion object {
private fun execProc(rootProject: Project, cmd: String, vararg args: Any): String {
val buf = ByteArrayOutputStream()
rootProject.exec {
rootProject.providers.exec {
executable = cmd
args(args.toList())
standardOutput = buf
Expand Down
32 changes: 15 additions & 17 deletions build-logic/src/main/kotlin/publishing/rootProject.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import io.github.gradlenexus.publishplugin.NexusPublishPlugin
import io.github.gradlenexus.publishplugin.internal.StagingRepositoryDescriptorRegistryBuildService
import org.gradle.api.Project
import org.gradle.api.services.BuildServiceRegistration
import org.gradle.api.tasks.Exec
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.named
import org.gradle.kotlin.dsl.register
Expand All @@ -40,27 +41,24 @@ internal fun configureOnRootProject(project: Project) =
val isRelease = project.hasProperty("release")
val isSigning = isRelease || project.hasProperty("signArtifacts")

val sourceTarball = tasks.register("sourceTarball")
sourceTarball.configure() {
val sourceTarball = tasks.register<Exec>("sourceTarball")
sourceTarball.configure {
group = "build"
description =
"Generate a source tarball for a release to be uploaded to dist.apache.org/repos/dist"

doFirst {
val e = project.extensions.getByType(PublishingHelperExtension::class.java)
mkdir(e.distributionDir)
exec {
executable = "git"
args(
"archive",
"--prefix=${e.baseName.get()}/",
"--format=tar.gz",
"--output=${e.sourceTarball.get().asFile.relativeTo(projectDir)}",
"HEAD"
)
workingDir(project.projectDir)
}
}
val e = project.extensions.getByType(PublishingHelperExtension::class.java)
doFirst { mkdir(e.distributionDir) }

executable = "git"
args(
"archive",
"--prefix=${e.baseName.get()}/",
"--format=tar.gz",
"--output=${e.sourceTarball.get().asFile.relativeTo(projectDir)}",
"HEAD"
)
workingDir(project.projectDir)
}

val digestSourceTarball = tasks.register("digestSourceTarball")
Expand Down
3 changes: 2 additions & 1 deletion build-logic/src/main/kotlin/publishing/util.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ internal fun generateDigest(input: File, output: File, algorithm: String) {
}

output.writeText(
md.digest().joinToString(separator = "") { eachByte -> "%02x".format(eachByte) }
md.digest().joinToString(separator = "") { eachByte -> "%02x".format(eachByte) } +
" ${input.name}"
)
}
}
Expand Down

0 comments on commit 91d4000

Please sign in to comment.