-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.gradle.kts
126 lines (110 loc) · 3.83 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 io.papermc.hangarpublishplugin.model.Platforms
plugins {
id("java")
id("com.github.johnrengelman.shadow") version "8.1.1"
id("io.papermc.hangar-publish-plugin") version "0.1.2"
}
var BuildFull = properties["BuildFull"].toString() == "true"
var libraries = listOf<String>()
libraries = libraries + "cn.lunadeer:MinecraftPluginUtils:2.0.7"
group = "cn.lunadeer"
version = "2.14.6-beta"
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}
// utf-8
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}
allprojects {
apply(plugin = "java")
apply(plugin = "com.github.johnrengelman.shadow")
repositories {
mavenLocal()
mavenCentral()
maven("https://oss.sonatype.org/content/groups/public")
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://jitpack.io")
maven("https://repo.mikeprimm.com/")
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
maven("https://repo.codemc.org/repository/maven-public")
}
dependencies {
compileOnly("com.github.BlueMap-Minecraft:BlueMapAPI:v2.6.2")
compileOnly("us.dynmap:DynmapCoreAPI:3.4")
compileOnly("me.clip:placeholderapi:2.11.6")
compileOnly("com.github.MilkBowl:VaultAPI:1.7")
compileOnly("net.milkbowl.vault:VaultUnlockedAPI:2.7")
if (!BuildFull) {
libraries.forEach {
compileOnly(it)
}
} else {
libraries.forEach {
implementation(it)
}
}
}
tasks.processResources {
outputs.upToDateWhen { false }
// copy languages folder from PROJECT_DIR/languages to core/src/main/resources
from(file("${projectDir}/languages")) {
into("languages")
}
// replace @version@ in plugin.yml with project version
filesMatching("**/plugin.yml") {
filter {
it.replace("@version@", rootProject.version.toString())
}
if (!BuildFull) {
var libs = "libraries: ["
libraries.forEach {
libs += "$it,"
}
filter {
it.replace("libraries: [ ]", libs.substring(0, libs.length - 1) + "]")
}
}
}
}
tasks.shadowJar {
archiveClassifier.set("")
archiveVersion.set(project.version.toString())
dependsOn(tasks.withType<ProcessResources>())
// add -lite to the end of the file name if BuildLite is true or -full if BuildLite is false
archiveFileName.set("${project.name}-${project.version}${if (BuildFull) "-full" else "-lite"}.jar")
}
}
dependencies {
implementation(project(":core"))
implementation(project(":v1_20_1"))
implementation(project(":v1_21"))
}
tasks.shadowJar {
archiveClassifier.set("")
archiveVersion.set(project.version.toString())
}
tasks.register("Clean&Build") { // <<<< RUN THIS TASK TO BUILD PLUGIN
dependsOn(tasks.clean)
dependsOn(tasks.shadowJar)
}
hangarPublish {
publications.register("plugin") {
version.set(project.version as String) // use project version as publication version
id.set("Dominion")
channel.set("Beta")
changelog.set("See https://github.com/ColdeZhang/Dominion/releases/tag/v${project.version}")
apiKey.set(System.getenv("HANGAR_TOKEN"))
// register platforms
platforms {
register(Platforms.PAPER) {
jar.set(tasks.shadowJar.flatMap { it.archiveFile })
println("ShadowJar: ${tasks.shadowJar.flatMap { it.archiveFile }}")
platformVersions.set(listOf("1.20.1-1.20.6","1.21.x"))
}
}
}
}
tasks.named("publishPluginPublicationToHangar") {
dependsOn(tasks.named("jar"))
}