更新 build.gradle.kts

This commit is contained in:
Armamem0t 2025-07-05 16:56:31 +08:00 committed by git.mingliqiye.com
parent fa25eff19f
commit f995e5c25a
Signed by: git.mingliqiye.com
GPG Key ID: F810443113074559

View File

@ -1,12 +1,14 @@
import java.security.MessageDigest
import java.text.SimpleDateFormat
import java.util.Date
plugins {
id("java")
id("java-library")
id("maven-publish")
id("com.github.johnrengelman.shadow") version ("8.1.1")
}
import java.text.SimpleDateFormat
import java.util.Date
plugins {
id("java")
id("java-library")
id("maven-publish")
id("com.github.johnrengelman.shadow") version ("8.1.1")
}
val GROUPSID = project.properties["GROUPSID"] as String
val VERSIONS = project.properties["VERSIONS"] as String
@ -22,6 +24,8 @@ group = GROUPSID
version = VERSIONS
val libDir = rootDir.resolve("build").resolve("libs")
val publicationsDir =
rootDir.resolve("build").resolve("publications").resolve("mavenJava")
java {
withSourcesJar()
@ -32,7 +36,8 @@ dependencies {
testImplementation(platform("org.junit:junit-bom:5.10.0"))
testImplementation("org.junit.jupiter:junit-jupiter")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
implementation("org.checkerframework:checker-qual:3.43.0")
implementation("org.jetbrains:annotations:24.0.0")
annotationProcessor("org.jetbrains:annotations:24.0.0")
}
tasks.test {
@ -49,15 +54,15 @@ private fun generateHash(file: File, string: String): String {
}
}
private fun getHash(file: File) {
private fun getHash(outpath: String, file: File) {
val md5 = generateHash(file, "MD5")
val sha1 = generateHash(file, "SHA-1")
val sha256 = generateHash(file, "SHA-256")
val sha512 = generateHash(file, "SHA-512")
val md5f = File(libDir, file.getName() + ".md5")
val sha1f = File(libDir, file.getName() + ".sha1")
val sha256f = File(libDir, file.getName() + ".sha256")
val sha512f = File(libDir, file.getName() + ".sha512")
val md5f = File(outpath, file.getName() + ".md5")
val sha1f = File(outpath, file.getName() + ".sha1")
val sha256f = File(outpath, file.getName() + ".sha256")
val sha512f = File(outpath, file.getName() + ".sha512")
md5f.writeText(md5)
sha1f.writeText(sha1)
sha256f.writeText(sha256)
@ -125,11 +130,13 @@ tasks.register("build-jar") {
dependsOn(tasks["sourcesJar"])
dependsOn(tasks["generatePomFileForMavenJavaPublication"])
dependsOn(tasks["generateMetadataFileForMavenJavaPublication"])
/*doLast {
getHash(File(libDir, jarName))
getHash(File(libDir, fatJarName))
getHash(File(libDir, srcJarName))
}*/
doLast {
getHash(libDir.toString(),File(libDir, jarName))
getHash(libDir.toString(),File(libDir, fatJarName))
getHash(libDir.toString(),File(libDir, srcJarName))
getHash(publicationsDir.toString(),File(publicationsDir, "module.json"))
getHash(publicationsDir.toString(),File(publicationsDir, "pom-default.xml"))
}
}
components {
withType<AdhocComponentWithVariants>().configureEach {
@ -155,3 +162,4 @@ publishing {
}
}