-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
71 lines (63 loc) · 2.4 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
71 lines (63 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import java.net.URI
import java.nio.file.Files
import java.nio.file.StandardCopyOption
plugins {
id("java-library")
id("com.gradleup.shadow") version "9.4.1"
}
repositories {
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://jitpack.io")
}
dependencies {
compileOnly("com.github.ModernSpout:Spout:${project.providers.gradleProperty("spoutVersion").get()}")
}
java {
toolchain.languageVersion = JavaLanguageVersion.of(25)
}
val serverDir: File = projectDir.resolve("run")
val pluginDir: File = serverDir.resolve("plugins")
tasks {
build {
dependsOn(shadowJar)
}
// Task to download the Spout server JAR for the runTask
register("downloadServer") {
group = "spout"; notCompatibleWithConfigurationCache(""); doFirst {
serverDir.mkdirs(); pluginDir.mkdirs(); URI(
"https://github.com/ModernSpout/Spout/releases/download/${
project.providers.gradleProperty("spoutVersion").get()
.let { "$it/spout-${project.providers.gradleProperty("apiVersion").get()}-R$it" }
}.jar").toURL().openStream().use {
Files.copy(it, serverDir.resolve("server.jar").toPath(), StandardCopyOption.REPLACE_EXISTING)
}
}
}
// Task to spin up a Spout server with the plugin
register("runServer", JavaExec::class) {
group = "spout"; notCompatibleWithConfigurationCache("")
dependsOn("shadowJar")
if (!serverDir.resolve("server.jar").exists()) dependsOn("downloadServer")
doFirst {
pluginDir.resolve("${project.name}.jar").delete()
Files.copy(
layout.buildDirectory.file("libs/${project.name}-${version}.jar").get().asFile.toPath(),
pluginDir.resolve("${project.name}.jar").toPath()
)
}
classpath = files(serverDir.resolve("server.jar")); minHeapSize = "2G"; maxHeapSize = "2G"
workingDir = serverDir; jvmArgs = listOf("-Dcom.mojang.eula.agree=true", "-Dspout.server.paper.enabled=true")
args = listOf("--nogui"); standardInput = System.`in`
}
processResources {
val props = mapOf(
"version" to version,
"description" to project.description,
"apiVersion" to "\"${project.providers.gradleProperty("apiVersion").get()}\"",
)
filesMatching("paper-plugin.yml") {
expand(props)
}
}
}