146 lines
5.0 KiB
Plaintext
146 lines
5.0 KiB
Plaintext
import java.security.MessageDigest
|
|
import java.text.SimpleDateFormat
|
|
import java.util.*
|
|
|
|
plugins {
|
|
java
|
|
idea
|
|
id("io.freefair.lombok") version "8.4"
|
|
id("org.springframework.boot") version "3.5.0"
|
|
id("io.spring.dependency-management") version "1.1.7"
|
|
}
|
|
val GROUPSID = project.properties["GROUPSID"] as String
|
|
val VERSIONS = project.properties["VERSIONS"] as String
|
|
val ARTIFACTID = project.properties["ARTIFACTID"] as String
|
|
val buildTime = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Date())
|
|
val jarNameStr = "${ARTIFACTID}-${VERSIONS}"
|
|
val jarName = "${jarNameStr}.jar"
|
|
val srcJarName = "${jarNameStr}-sources.jar"
|
|
val webZipName = "${jarNameStr}-web.zip"
|
|
group = GROUPSID
|
|
version = VERSIONS
|
|
|
|
val libDir = rootDir.resolve("build").resolve("libs")
|
|
val srcDir = rootDir.resolve("src").resolve("main").resolve("java")
|
|
val webDir = rootDir.resolve("src").resolve("main").resolve("resources").resolve("html")
|
|
java {
|
|
toolchain {
|
|
languageVersion = JavaLanguageVersion.of(21)
|
|
}
|
|
}
|
|
|
|
allprojects {
|
|
configurations.all {
|
|
exclude(group = "org.springframework.boot", module = "spring-boot-starter-logging")
|
|
}
|
|
|
|
}
|
|
|
|
tasks.test {
|
|
useJUnitPlatform()
|
|
jvmArgs = listOf(
|
|
"-javaagent:${classpath.find { it.name.contains("mockito-core") }?.absolutePath}",
|
|
"-XX:+EnableDynamicAgentLoading",
|
|
)
|
|
}
|
|
|
|
dependencies {
|
|
implementation("org.springframework.boot:spring-boot-starter")
|
|
implementation("org.springframework.boot:spring-boot-starter-log4j2")
|
|
implementation("org.springframework.boot:spring-boot-starter-web")
|
|
implementation("org.springframework.boot:spring-boot-starter-data-redis")
|
|
implementation("org.springframework.boot:spring-boot-starter-actuator")
|
|
compileOnly("org.projectlombok:lombok")
|
|
testRuntimeOnly("org.projectlombok:lombok")
|
|
annotationProcessor("org.projectlombok:lombok")
|
|
implementation("org.jetbrains:annotations:24.0.0")
|
|
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.19.1")
|
|
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
|
developmentOnly("org.springframework.boot:spring-boot-devtools")
|
|
runtimeOnly("com.mysql:mysql-connector-j")
|
|
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
|
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.9")
|
|
implementation("cn.dev33:sa-token-redis-jackson:1.44.0")
|
|
implementation("cn.hutool:hutool-all:5.8.24")
|
|
implementation("cn.dev33:sa-token-jwt:1.44.0")
|
|
implementation("org.mindrot:jbcrypt:0.4")
|
|
implementation("com.github.f4b6a3:uuid-creator:6.1.0")
|
|
implementation("com.squareup.okhttp3:okhttp:5.0.0-alpha.16")
|
|
implementation("com.alibaba:druid-spring-boot-3-starter:1.2.25")
|
|
implementation("cn.dev33:sa-token-jwt:1.44.0")
|
|
implementation("cn.dev33:sa-token-spring-boot3-starter:1.44.0")
|
|
implementation("cn.dev33:sa-token-redis-jackson:1.44.0")
|
|
implementation("com.baomidou:mybatis-plus-spring-boot3-starter:3.5.12")
|
|
}
|
|
|
|
private fun generateHash(file: File, string: String): String {
|
|
val md = MessageDigest.getInstance(string)
|
|
file.forEachBlock(4096) { bytes, size ->
|
|
md.update(bytes, 0, size)
|
|
}
|
|
return md.digest().joinToString("") {
|
|
"%02x".format(it)
|
|
}
|
|
}
|
|
|
|
private fun getHash(file: File) {
|
|
val md5 = generateHash(file, "MD5")
|
|
val sha1 = generateHash(file, "SHA-1")
|
|
val sha256 = generateHash(file, "SHA-256")
|
|
val md5f = File(libDir, file.getName() + ".MD5.txt")
|
|
val sha1f = File(libDir, file.getName() + ".SHA1.txt")
|
|
val sha256f = File(libDir, file.getName() + ".SHA256.txt")
|
|
md5f.writeText(md5)
|
|
sha1f.writeText(sha1)
|
|
sha256f.writeText(sha256)
|
|
}
|
|
|
|
tasks.withType<Test> {
|
|
useJUnitPlatform()
|
|
}
|
|
|
|
tasks.register("rmkdir") {
|
|
delete(libDir)
|
|
mkdir(libDir)
|
|
}
|
|
tasks.register<Zip>("sources") {
|
|
archiveFileName.set(srcJarName)
|
|
destinationDirectory.set(libDir)
|
|
from(fileTree(srcDir.toString()))
|
|
into(".")
|
|
}
|
|
|
|
tasks.register<Zip>("web") {
|
|
archiveFileName.set(webZipName)
|
|
destinationDirectory.set(libDir)
|
|
from(fileTree(webDir.toString()))
|
|
into(".")
|
|
}
|
|
|
|
|
|
tasks.bootJar {
|
|
archiveFileName.set(jarName)
|
|
manifest {
|
|
attributes["Implementation-GroupId"] = GROUPSID
|
|
attributes["Implementation-ArtifactId"] = ARTIFACTID
|
|
attributes["Implementation-Version"] = VERSIONS
|
|
attributes["Email"] = "minglipro@163.com"
|
|
attributes["Implementation-Vendor"] = "minglipro|Armamem0t"
|
|
attributes["Copyright"] = "Copyright 2026 minglipro All rights reserved."
|
|
attributes["Env"] = "prod"
|
|
attributes["LICENSE"] = "Apache License 2.0"
|
|
attributes["Created"] = "2025-06-26 09:13:51"
|
|
attributes["Updated"] = buildTime
|
|
}
|
|
}
|
|
|
|
tasks.register("build-jar") {
|
|
dependsOn(tasks["rmkdir"], tasks["sources"], tasks["web"], tasks.bootJar)
|
|
mustRunAfter(tasks["rmkdir"], tasks["sources"], tasks["web"], tasks.bootJar)
|
|
doLast {
|
|
getHash(File(libDir, jarName))
|
|
getHash(File(libDir, srcJarName))
|
|
getHash(File(libDir, webZipName))
|
|
}
|
|
}
|