-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
144 lines (126 loc) · 3.98 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import net.minecrell.pluginyml.bukkit.BukkitPluginDescription
import java.io.BufferedReader
import java.nio.file.Paths
val javaVersion = 17
val minecraftVersion = "1.20.4"
fun runCommand(command: Array<String>) = Runtime
.getRuntime()
.exec(command)
.let { process ->
process.waitFor()
val output = process.inputStream.use {
it.bufferedReader().use(BufferedReader::readText)
}
process.destroy()
output.trim()
}
// example version number: MPP-0.1.302-1.19.4-SNAPSHOT
// when changing version be sure to only use the chars mentioned in the comments
// otherwise you have to change the regex in the workflows
fun getPluginVersion(): String {
val baseVersion = "0.1" // only 0-9. not empty
val versionSuffix = "SNAPSHOT" // only A-Z not empty
val commitCount = runCommand(arrayOf("git", "rev-list", "--count", "HEAD")).trim() // only 0-9 not empty
return "$baseVersion.$commitCount-$minecraftVersion-$versionSuffix"
}
group = "de.danielmaile.mpp"
version = getPluginVersion()
plugins {
`java-library`
`embedded-kotlin`
id("io.papermc.paperweight.userdev") version "1.5.3"
id("xyz.jpenilla.run-paper") version "2.0.1"
id("net.minecrell.plugin-yml.bukkit") version "0.5.3"
id("com.github.johnrengelman.shadow") version "7.0.0"
id("org.jlleitschuh.gradle.ktlint") version "11.3.1"
id("de.undercouch.download") version "5.4.0"
}
bukkit {
load = BukkitPluginDescription.PluginLoadOrder.POSTWORLD
main = "de.danielmaile.mpp.MPP"
apiVersion = "1.19"
authors = listOf("Daniel Maile", "ChechuDEV", "Others")
libraries = libs.bundles.plugin.get().map { "${it.group}:${it.name}:${it.version}" }
commands {
register("mpp") {
permission = "mpp.mpp"
}
}
}
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(javaVersion))
}
repositories {
mavenCentral()
maven("https://repo.dmulloy2.net/repository/public/")
maven("https://repo.mattstudios.me/artifactory/public/")
}
dependencies {
paperweight.paperDevBundle("$minecraftVersion-R0.1-SNAPSHOT")
implementation(libs.bundles.implementation) {
exclude(group = "net.kyori", module = "adventure-api")
exclude(group = "net.kyori", module = "adventure-text-serializer-legacy")
exclude(group = "net.kyori", module = "adventure-text-serializer-gson")
}
compileOnly(libs.bundles.compile)
testImplementation(libs.bundles.test)
}
tasks {
assemble {
dependsOn(reobfJar)
}
compileJava {
options.encoding = Charsets.UTF_8.name()
options.release.set(javaVersion)
}
shadowJar {
relocate("dev.triumphteam.gui", "de.danielmaile.libs.gui")
relocate("org.bstats", "de.danielmaile.libs.bStats")
}
javadoc {
options.encoding = Charsets.UTF_8.name()
}
processResources {
filteringCharset = Charsets.UTF_8.name()
}
build {
finalizedBy("buildResourcePack")
}
runServer {
jvmArgs("-Dcom.mojang.eula.agree=true")
pluginJars(File(buildDir, "ProtocolLib.jar"))
minecraftVersion(minecraftVersion)
}
// region group often used tasks for convenience
clean {
group = "mpp"
}
build {
group = "mpp"
}
ktlintCheck {
group = "mpp"
}
runServer {
group = "mpp"
}
test {
useJUnitPlatform()
}
// endregion
}
tasks.register<JavaExec>("buildResourcePack") {
mainClass.set("de.danielmaile.resourcepack.ResourcePackBuilderKt")
classpath(sourceSets["main"].runtimeClasspath, configurations.compileClasspath)
group = "mpp"
args = listOf(getPluginVersion(), project.projectDir.absolutePath)
}
tasks.register<RunResourcePackServer>("runResourcePackServer") {
dependsOn("buildResourcePack")
group = "mpp"
port = 8080
resourcePackZip = File(
projectDir.toPath().resolve(Paths.get("build", "resourcepack")).toFile(),
"MPP-${getPluginVersion()}.zip"
)
}