Skip to content

Commit

Permalink
add sha generation
Browse files Browse the repository at this point in the history
  • Loading branch information
fellmann authored and tobias-bahls committed Nov 20, 2023
1 parent 134a32c commit 483b9da
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.jetbrains.dokka.gradle.DokkaTask
import java.io.OutputStream
import java.security.DigestOutputStream
import java.security.MessageDigest

plugins {
id("org.jetbrains.kotlin.jvm") version "1.8.20" // Apply the Kotlin JVM plugin to add support for Kotlin.
Expand Down Expand Up @@ -188,4 +191,19 @@ tasks {
test {
jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED")
}
}
shadowJar {
doLast {
println(calcSha1(File("$buildDir/libs/$executableName.jar")))
}
}
}

fun calcSha1(file: File): String {
val md = DigestOutputStream(
OutputStream.nullOutputStream(), MessageDigest.getInstance("SHA-1")
)
file.inputStream().copyTo(md)
return md.messageDigest.digest().toHex()
}

fun ByteArray.toHex() = joinToString(separator = "") { eachByte -> "%02x".format(eachByte) }

0 comments on commit 483b9da

Please sign in to comment.