Files
Starlight_Lancher/packages/app-lib/java/build.gradle.kts

94 lines
2.2 KiB
Plaintext

import java.security.MessageDigest
plugins {
java
id("com.diffplug.spotless") version "8.0.0"
id("com.gradleup.shadow") version "9.2.2"
}
repositories {
mavenCentral()
}
dependencies {
implementation("org.ow2.asm:asm:9.9")
implementation("org.ow2.asm:asm-tree:9.9")
implementation("com.google.code.gson:gson:2.13.2")
testImplementation(libs.junit.jupiter)
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
tasks.withType<JavaCompile>().configureEach {
options.release = 8
options.compilerArgs.addAll(listOf("-Xlint:all", "-Werror"))
}
spotless {
java {
palantirJavaFormat()
removeUnusedImports()
}
}
tasks.jar {
enabled = false
}
tasks.shadowJar {
archiveFileName = "theseus.jar"
manifest {
attributes["Premain-Class"] = "com.modrinth.theseus.agent.TheseusAgent"
}
addMultiReleaseAttribute = false
enableAutoRelocation = true
relocationPrefix = "com.modrinth.theseus.shadow"
}
val authlibInjector by tasks.registering {
notCompatibleWithConfigurationCache("Downloads and verifies a pinned external Java agent")
val output = layout.buildDirectory.file("libs/authlib-injector.jar")
inputs.property("version", "1.2.8")
inputs.property(
"sha256",
"9c7f4343e6c82034958ffb48c14a2cb0c85928be7283103ce17da00c6d5a7b10",
)
outputs.file(output)
doLast {
val bytes = uri(
"https://authlib-injector.yushi.moe/artifact/56/authlib-injector-1.2.8.jar",
).toURL().readBytes()
val checksum = MessageDigest.getInstance("SHA-256")
.digest(bytes)
.joinToString("") { "%02x".format(it) }
check(checksum == inputs.properties["sha256"]) {
"authlib-injector checksum mismatch: $checksum"
}
output.get().asFile.apply {
parentFile.mkdirs()
writeBytes(bytes)
}
}
}
tasks.build {
dependsOn(authlibInjector)
}
tasks.named<Test>("test") {
useJUnitPlatform()
}
tasks.withType<AbstractArchiveTask>().configureEach {
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
}