-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.gradle.kts
126 lines (108 loc) · 3.48 KB
/
build.gradle.kts
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import xyz.jpenilla.runpaper.task.RunServer
import java.net.URI
plugins {
java
id("xyz.jpenilla.run-paper") version "2.3.1"
id("com.gradleup.shadow") version "8.3.3"
}
group = "org.evlis"
version = "1.2.0"
val targetJavaVersion = 21
repositories {
mavenCentral()
maven {
name = "papermc-repo"
url = URI("https://repo.papermc.io/repository/maven-public/")
}
maven {
name = "sonatype"
url = URI("https://oss.sonatype.org/content/groups/public/")
}
maven {
name = "aikars-framework"
url = URI("https://repo.aikar.co/content/groups/aikar/")
}
}
dependencies {
compileOnly("io.papermc.paper:paper-api:1.21.1-R0.1-SNAPSHOT")
implementation("co.aikar:acf-paper:0.5.1-SNAPSHOT")
implementation("net.kyori:adventure-api:4.18.0")
testImplementation("com.github.seeseemelk:MockBukkit-v1.21:3.133.1")
testImplementation("com.github.seeseemelk:MockBukkit-v1.21:3.133.1")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.0")
}
java {
sourceCompatibility = JavaVersion.toVersion(targetJavaVersion)
targetCompatibility = JavaVersion.toVersion(targetJavaVersion)
toolchain.languageVersion.set(JavaLanguageVersion.of(targetJavaVersion))
}
tasks.withType<JavaCompile>().all {
options.encoding = "UTF-8"
options.compilerArgs.add("-parameters")
options.isFork = true
options.release.set(targetJavaVersion)
}
tasks {
processResources {
val props = mapOf("version" to version)
inputs.properties(props)
filteringCharset = "UTF-8"
filesMatching("plugin.yml") {
expand(props)
}
}
build { dependsOn(shadowJar) }
shadowJar {
relocate("co.aikar.commands", "Lunamatic.acf")
relocate("co.aikar.locales", "Lunamatic.locales")
}
test {
useJUnitPlatform()
testLogging { events("passed", "skipped", "failed") }
}
runServer {
// Keep runServer task to inherit project plugin
minecraftVersion("1.21.1")
}
}
// Test Paper run & immediately shut down, for github actions
tasks.register<RunServer>("runServerTest") {
dependsOn(tasks.shadowJar)
minecraftVersion("1.21.1")
downloadPlugins {
github("Ifiht", "AutoStop", "v1.2.0", "AutoStop-1.2.0.jar")
}
pluginJars.from(tasks.shadowJar)
}
// Start a local test server for login & manual testing
tasks.register<RunServer>("runServerInteractive") {
dependsOn(tasks.shadowJar)
minecraftVersion("1.21.1")
pluginJars.from(tasks.shadowJar)
}
// Start a local Folia server for manual testing
runPaper.folia.registerTask {
minecraftVersion("1.20.6")
}
tasks.register("checkServerLogs") {
doLast {
// Path to the latest.log file
val logFile = File("run/logs/latest.log")
// Check if the log file exists
if (!logFile.exists()) {
throw GradleException("Log file not found: " + logFile.absolutePath)
}
// Read the log file line by line
val logContent = logFile.readLines()
// Find lines that contain the " ERROR]:" substring
val errorLines = logContent.filter { it.contains("ERROR]:") }
if (!errorLines.isEmpty()) {
println("Errors were found:")
errorLines.forEach(::println)
throw GradleException("Errors found in log file.")
} else {
println("No errors found in log file.")
}
}
}