-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
162 lines (137 loc) · 4.65 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
import java.io.BufferedReader
import java.io.InputStreamReader
plugins {
`java-library`
`maven-publish`
id("com.github.johnrengelman.shadow") version ("8.1.1")
id("xyz.jpenilla.run-paper") version("2.3.1")
id("com.modrinth.minotaur") version ("2.+")
}
allprojects {
apply(plugin = "maven-publish")
group = "org.lushplugins"
version = "1.0.9"
repositories {
mavenCentral()
mavenLocal()
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") // Spigot
maven("https://repo.lushplugins.org/releases") // LushLib
maven("https://repo.lushplugins.org/snapshots") // LushLib
}
publishing {
repositories {
maven {
name = "lushReleases"
url = uri("https://repo.lushplugins.org/releases")
credentials(PasswordCredentials::class)
authentication {
isAllowInsecureProtocol = true
create<BasicAuthentication>("basic")
}
}
maven {
name = "lushSnapshots"
url = uri("https://repo.lushplugins.org/snapshots")
credentials(PasswordCredentials::class)
authentication {
isAllowInsecureProtocol = true
create<BasicAuthentication>("basic")
}
}
}
}
}
dependencies {
compileOnly("org.spigotmc:spigot-api:1.21.4-R0.1-SNAPSHOT")
implementation(project(":api"))
implementation("org.lushplugins:LushLib:0.10.24")
}
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
withSourcesJar()
}
tasks {
withType<JavaCompile> {
options.encoding = "UTF-8"
}
shadowJar {
relocate("org.lushplugins.lushlib", "org.lushplugins.pluginupdater.libraries.lushlib")
minimize()
val folder = System.getenv("pluginFolder")
if (folder != null) destinationDirectory.set(file(folder))
archiveFileName.set("${project.name}-${project.version}.jar")
}
processResources {
expand(project.properties)
inputs.property("version", rootProject.version)
filesMatching("plugin.yml") {
expand("version" to rootProject.version)
}
}
runServer {
minecraftVersion("1.21")
downloadPlugins {
modrinth("viaversion", "5.0.3")
modrinth("viabackwards", "5.0.3")
// The following plugins are intentionally outdated
modrinth("djC8I9ui", "3.2.0") // LushRewards
modrinth("discordsrv", "1.27.0")
modrinth("coreprotect", "22.3")
modrinth("fancynpcs", "2.2.2")
modrinth("fancyholograms", "2.3.1")
}
}
}
tasks.withType(xyz.jpenilla.runtask.task.AbstractRun::class) {
javaLauncher = javaToolchains.launcherFor {
vendor = JvmVendorSpec.JETBRAINS
languageVersion = JavaLanguageVersion.of(21)
}
jvmArgs("-XX:+AllowEnhancedClassRedefinition")
}
publishing {
publications {
create<MavenPublication>("maven") {
groupId = rootProject.group.toString() + ".pluginupdater"
artifactId = rootProject.name
version = rootProject.version.toString()
from(project.components["java"])
}
}
}
modrinth {
token.set(System.getenv("MODRINTH_TOKEN"))
projectId.set("IBSpJfbm")
if (System.getenv("RELEASE_TYPE") == "release") {
versionNumber.set(rootProject.version.toString())
} else {
versionNumber.set(rootProject.version.toString() + "-" + getCurrentCommitHash())
print(rootProject.version.toString() + "-" + getCurrentCommitHash())
}
uploadFile.set(file("build/libs/${project.name}-${project.version}.jar"))
versionType.set(System.getenv("RELEASE_TYPE"))
gameVersions.addAll(
"1.18", "1.18.1", "1.18.2",
"1.19", "1.19.1", "1.19.2", "1.19.3", "1.19.4",
"1.20", "1.20.1", "1.20.2", "1.20.3", "1.20.4", "1.20.5", "1.20.6",
"1.21", "1.21.1"
)
loaders.addAll("spigot", "paper", "purpur")
syncBodyFrom.set(rootProject.file("README.md").readText())
}
tasks.modrinth {
dependsOn("shadowJar")
dependsOn(tasks.modrinthSyncBody)
}
fun getCurrentCommitHash(): String {
val process = ProcessBuilder("git", "rev-parse", "--short", "HEAD").start()
val reader = BufferedReader(InputStreamReader(process.inputStream))
val commitHash = reader.readLine()
reader.close()
process.waitFor()
if (process.exitValue() == 0) {
return commitHash ?: ""
} else {
throw IllegalStateException("Failed to retrieve the commit hash.")
}
}