This repository has been archived by the owner on Sep 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
106 lines (91 loc) · 3.28 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
import dev.s7a.gradle.minecraft.server.tasks.LaunchMinecraftServerTask
plugins {
java
idea
id("org.jetbrains.kotlin.jvm") version "1.7.10"
id("com.github.johnrengelman.shadow") version "7.1.2"
// https://github.com/sya-ri/minecraft-server-gradle-plugin
id("dev.s7a.gradle.minecraft.server") version "1.2.0"
}
group = project.property("group").toString()
version = project.property("version").toString()
// Define the "bundle" configuration which will be included in the shadow jar.
val bundle: Configuration by configurations.creating
repositories {
mavenCentral()
maven {
name = "spigotmc-repo"
url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
}
maven {
name = "sonatype"
url = uri("https://oss.sonatype.org/content/groups/public/")
}
maven {
url = uri("https://repo.extendedclip.com/content/repositories/placeholderapi/")
}
}
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${project.property("kotlin_version")}")?.let { bundle(it) }
// implementation("org.jetbrains.kotlin:kotlin-reflect:${project.property("kotlin_version")}")?.let { bundle(it) }
// implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")?.let { bundle(it) }
compileOnly("org.spigotmc:spigot-api:${project.property("spigot_version").toString()}")
compileOnly("me.clip:placeholderapi:2.11.2")
}
val targetJavaVersion = 17
java {
val javaVersion = JavaVersion.toVersion(targetJavaVersion)
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion.set(JavaLanguageVersion.of(targetJavaVersion))
}
}
tasks {
processResources {
val props = mutableMapOf("version" to version)
filesMatching("plugin.yml") {
expand(props)
}
}
jar {
archiveClassifier.set("source")
from(rootProject.file("LICENSE"))
}
shadowJar {
archiveClassifier.set("")
// Include our bundle configuration in the shadow jar.
configurations = listOf(bundle)
}
build {
dependsOn(shadowJar)
}
task<LaunchMinecraftServerTask>("buildAndLaunchServer") {
dependsOn(build)
doFirst {
copy {
from(buildDir.resolve("libs/${project.property("plugin_name")}-$version.jar"))
into(buildDir.resolve("MinecraftServer/plugins"))
}
}
// Spigot: https://getbukkit.org/download/spigot
// Paper: https://github.com/sya-ri/minecraft-server-gradle-plugin
jarUrl.set(LaunchMinecraftServerTask.JarUrl.Paper(project.property("mc_version").toString()))
agreeEula.set(true)
jvmArgument.set(arrayListOf("-Deditable.java.test.console=true"))
}
task("reloadPluginJar") {
dependsOn(build)
doFirst {
copy {
from(buildDir.resolve("libs/${project.property("plugin_name")}-$version.jar"))
into(buildDir.resolve("MinecraftServer/plugins"))
}
}
}
}
tasks.withType(JavaCompile::class.java).configureEach {
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible) {
options.release.set(targetJavaVersion)
}
}