-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
162 lines (137 loc) · 4.86 KB
/
build.gradle.kts
File metadata and controls
162 lines (137 loc) · 4.86 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
import java.io.BufferedReader
import java.io.InputStreamReader
plugins {
`java-library`
`maven-publish`
id("com.gradleup.shadow") version("9.3.1")
id("xyz.jpenilla.run-paper") version("3.0.2")
id("com.modrinth.minotaur") version ("2.+")
}
allprojects {
apply(plugin = "maven-publish")
group = "org.lushplugins"
version = "2.2.0"
repositories {
mavenLocal()
mavenCentral()
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:26.1.1-R0.1-SNAPSHOT")
implementation(project(":api"))
implementation("org.lushplugins:LushLib:1.0.0")
implementation("io.github.revxrsal:lamp.common:4.0.0-rc.16")
implementation("io.github.revxrsal:lamp.bukkit:4.0.0-rc.16")
}
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
withSourcesJar()
}
tasks {
withType<JavaCompile> {
options.encoding = "UTF-8"
}
shadowJar {
relocate("org.lushplugins.lushlib", "org.lushplugins.pluginupdater.libraries.lushlib")
minimize()
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.7.1") // ViaVersion
modrinth("viabackwards", "5.7.1") // ViaBackwards
// The following plugins are intentionally outdated for testing purposes
modrinth("djC8I9ui", "3.2.0") // LushRewards
modrinth("discordsrv", "1.27.0") // DiscordSRV
modrinth("coreprotect", "22.3") // CoreProtect
modrinth("fancynpcs", "2.2.2") // FancyNPCs
modrinth("fancyholograms", "2.3.1") // FancyHolograms
modrinth("nMwMeNFr", "2025.07") // UltimateAutoRestart
}
}
}
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())
changelog.set(getChangelogSinceLastTag())
} else {
versionNumber.set("${rootProject.version}-${getCurrentCommitHash()}")
}
uploadFile.set(file("build/libs/${project.name}-${project.version}.jar"))
versionType.set(System.getenv("RELEASE_TYPE"))
gameVersions.addAll(
"1.21.4", "1.21.5", "1.21.6", "1.21.7", "1.21.8", "1.21.9", "1.21.10", "1.21.11",
"26.1"
)
loaders.addAll("spigot", "paper", "purpur", "folia")
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.")
}
}
fun getLastTag(): String {
return ProcessBuilder("git", "describe", "--tags", "--abbrev=0")
.start().inputStream.bufferedReader().readText().trim()
}
fun getChangelogSinceLastTag(): String {
return ProcessBuilder("git", "log", "${getLastTag()}..HEAD", "--pretty=format:* %s ([#%h](https://github.com/OakLoaf/PluginUpdater/commit/%H))")
.start().inputStream.bufferedReader().readText().trim()
}