Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F12297412
build.gradle.kts
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
build.gradle.kts
View Options
import org.gradle.api.tasks.bundling.Jar
import org.gradle.api.tasks.Copy
import java.security.MessageDigest
import java.util.Properties
plugins {
id("java")
}
group = "org.eu.loupsgris.quilvaryn"
version = "0.1-SNAPSHOT"
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
}
repositories {
mavenCentral()
maven {
name = "papermc"
url = uri("https://repo.papermc.io/repository/maven-public/")
}
}
dependencies {
testImplementation(platform("org.junit:junit-bom:5.10.0"))
testImplementation("org.junit.jupiter:junit-jupiter")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
// Paper API (includes Bukkit + Spigot)
compileOnly("io.papermc.paper:paper-api:1.21.8-R0.1-SNAPSHOT")
// Adventure for l10n
compileOnly("net.kyori:adventure-api:4.24.0")
implementation("net.kyori:adventure-text-serializer-plain:4.24.0")
}
val promoteEnglishMessagesAsDefault by tasks.registering(Copy::class) {
from("src/main/resources/l10n/messages_en.properties")
into("src/main/resources/l10n")
rename { "messages.properties" }
}
tasks.processResources {
dependsOn(
promoteEnglishMessagesAsDefault,
)
}
tasks.named("build") {
dependsOn(
promoteEnglishMessagesAsDefault,
"updateResourcePackProperties",
)
}
val resourcePackSourceDir = layout.projectDirectory.dir("src/main/resources/resourcepack")
val resourcePackProperties = layout.projectDirectory.file("src/main/resources/resourcepack.properties")
val resourcePackBuildDir = layout.buildDirectory.dir("resourcepack")
val resourcePackZip = resourcePackBuildDir.get().file("suhayl.zip")
val resourcePackSha1 = resourcePackBuildDir.get().file("suhayl.sha1")
tasks.register<Zip>("zipResourcePack") {
from(resourcePackSourceDir)
archiveFileName.set("suhayl.zip")
destinationDirectory.set(resourcePackBuildDir)
}
tasks.register("computeResourcePackSha1") {
dependsOn("zipResourcePack")
inputs.file(resourcePackZip)
outputs.file(resourcePackSha1)
doLast {
val zipFile = resourcePackZip.asFile
val sha1 = MessageDigest.getInstance("SHA-1")
.digest(zipFile.readBytes())
.joinToString("") { "%02x".format(it) }
resourcePackSha1.asFile.writeText(sha1)
println("Resource pack SHA1: $sha1")
}
}
tasks.register("updateResourcePackProperties") {
dependsOn("computeResourcePackSha1")
doLast {
val sha1 = resourcePackSha1.asFile.readText().trim()
val propsFile = resourcePackProperties.asFile
val props = Properties().apply {
if (propsFile.exists()) {
propsFile.inputStream().use { load(it) }
}
}
props["resourcepack.url"] = "https://windriver.nasqueron.org/~minecraft/packs/suhayl.zip"
props["resourcepack.sha1"] = sha1
propsFile.outputStream().use { props.store(it, "Updated by Gradle") }
println("Updated ${propsFile.name} with SHA1=$sha1")
}
}
tasks.register<Exec>("deployResourcePack") {
val remoteHost = (findProperty("remoteHost") as String?) ?: "windriver.nasqueron.org"
val remoteUser = (findProperty("remoteUser") as String?) ?: System.getenv("USER") ?: "deploy"
val remoteDir = (findProperty("remoteResourcePackDir") as String?) ?: "/var/home-wwwroot/minecraft/packs/"
dependsOn("updateResourcePackProperties")
val zipFile = resourcePackZip.asFile
commandLine("scp", zipFile.absolutePath, "$remoteUser@$remoteHost:$remoteDir")
}
tasks.register<Exec>("deploy") {
group = "deployment"
description = "SCP the built JAR to windriver.nasqueron.org (configurable via -PremoteUser and -PremoteDir)."
dependsOn(
tasks.named("build"),
tasks.named("jar"),
tasks.named("deployResourcePack"),
)
val remoteHost = (findProperty("remoteHost") as String?) ?: "windriver.nasqueron.org"
val remoteUser = (findProperty("remoteUser") as String?) ?: System.getenv("USER") ?: "deploy"
val remoteDir = (findProperty("remoteDir") as String?) ?: ""
// Resolve the jar file produced by the 'jar' task
val jarTask = tasks.named<Jar>("jar").get()
val jarFileProvider = jarTask.archiveFile
doFirst {
val jarFile = jarFileProvider.get().asFile
if (!jarFile.exists()) {
throw GradleException("JAR not found at ${'$'}{jarFile.absolutePath}. Try running './gradlew build' first.")
}
commandLine("scp", jarFile.absolutePath, "$remoteUser@$remoteHost:$remoteDir")
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Oct 22, 11:55 (22 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3088948
Default Alt Text
build.gradle.kts (4 KB)
Attached To
Mode
rQVR Quilvaryn
Attached
Detach File
Event Timeline
Log In to Comment