-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
184 lines (170 loc) · 5.31 KB
/
build.gradle.kts
File metadata and controls
184 lines (170 loc) · 5.31 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
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
import io.papermc.hangarpublishplugin.model.Platforms
import net.minecrell.pluginyml.bukkit.BukkitPluginDescription.Permission.Default
import xyz.jpenilla.runpaper.task.RunServer
import xyz.jpenilla.runtask.pluginsapi.PluginDownloadService
import xyz.jpenilla.runtask.service.DownloadsAPIService
plugins {
java
alias(libs.plugins.shadow)
alias(libs.plugins.paper.run)
alias(libs.plugins.bukkit.yml)
alias(libs.plugins.hangar)
alias(libs.plugins.modrinth)
alias(libs.plugins.cyclonedx)
jacoco
}
if (!File("$rootDir/.git").exists()) {
logger.lifecycle(
"""
**************************************************************************************
You need to fork and clone this repository! Don't download a .zip file.
If you need assistance, consult the GitHub docs: https://docs.github.com/get-started/quickstart/fork-a-repo
**************************************************************************************
""".trimIndent()
).also { System.exit(1) }
}
val supportedMinecraftVersions = listOf(
"1.20.6",
"1.21",
"1.21.1",
"1.21.2",
"1.21.3",
"1.21.4",
"1.21.5",
"1.21.6",
"1.21.7",
"1.21.8",
"1.21.9",
"1.21.10"
)
dependencies {
compileOnly(libs.paper)
implementation(libs.semver)
// testing
testImplementation(libs.paper)
testImplementation(libs.mockbukkit)
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
}
bukkit {
main = "net.onelitefeather.attollo.Attollo"
apiVersion = "1.20"
authors = listOf("OneLiteFeather Network","TheMeinerLP")
foliaSupported = true
permissions {
register("attollo.use") {
description = "Allows the player to use the plugin"
default = Default.TRUE
}
register("attollo.update") {
description = "Allows the player to see update notifications"
default = Default.OP
}
}
commands {
register("attollo") {
permission = "attollo.command.attollo"
}
}
}
tasks {
named("build") {
dependsOn(shadowJar)
}
test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
showStandardStreams = false
}
maxParallelForks = 1
// Generate test reports
reports {
junitXml.required.set(true)
html.required.set(true)
}
// Test result publication
finalizedBy(jacocoTestReport)
}
supportedMinecraftVersions.forEach { serverVersion ->
register<RunServer>("run-$serverVersion") {
minecraftVersion(serverVersion)
jvmArgs("-DPaper.IgnoreJavaVersion=true", "-Dcom.mojang.eula.agree=true")
group = "run paper"
runDirectory.set(file("run-$serverVersion"))
pluginJars(rootProject.tasks.shadowJar.map { it.archiveFile }.get())
}
}
supportedMinecraftVersions.forEach { serverVersion ->
register<RunServer>("run-folia-$serverVersion") {
minecraftVersion(serverVersion)
jvmArgs("-DPaper.IgnoreJavaVersion=true", "-Dcom.mojang.eula.agree=true")
group = "run folia"
runDirectory.set(file("run-folia-$serverVersion"))
pluginJars(rootProject.tasks.shadowJar.map { it.archiveFile }.get())
downloadsApiService.convention(DownloadsAPIService.folia(project))
pluginDownloadService.convention(PluginDownloadService.paper(project))
}
}
shadowJar {
archiveClassifier.set("")
relocate("org.bstats", "net.onelitefeather.attollo.org.bstats")
dependsOn(jar)
}
this.modrinth {
dependsOn(shadowJar)
}
this.publishAllPublicationsToHangar {
dependsOn(shadowJar)
}
jacocoTestReport {
dependsOn(test)
reports {
xml.required.set(true)
html.required.set(true)
}
}
}
val baseVersion = version as String
val baseChannel = with(baseVersion) {
when {
contains("SNAPSHOT", true) -> "Snapshot"
contains("ALPHA", true) -> "Alpha"
contains("BETA", true) -> "Beta"
else -> "Release"
}
}
val changelogContent = "See [GitHub](https://github.com/OneLiteFeatherNET/Attollo/releases/tag/$baseVersion) for release notes."
hangarPublish {
publications.register("Attollo") {
version.set(baseVersion)
channel.set(baseChannel)
changelog.set(changelogContent)
apiKey.set(System.getenv("HANGAR_SECRET"))
id.set("Attollo")
platforms {
register(Platforms.PAPER) {
jar.set(tasks.shadowJar.flatMap { it.archiveFile })
platformVersions.set(supportedMinecraftVersions)
}
}
}
}
modrinth {
token.set(System.getenv("MODRINTH_TOKEN"))
projectId.set("ULt9SvKn")
versionType.set(baseChannel.lowercase())
versionNumber.set(baseVersion)
versionName.set(baseVersion)
changelog.set(changelogContent)
changelog.set(changelogContent)
uploadFile.set(tasks.shadowJar.flatMap { it.archiveFile })
gameVersions.addAll(supportedMinecraftVersions)
loaders.add("paper")
loaders.add("bukkit")
loaders.add("folia")
}