-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.gradle.kts
204 lines (190 loc) · 7.44 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
import io.papermc.hangarpublishplugin.model.Platforms
import net.minecrell.pluginyml.bukkit.BukkitPluginDescription
import xyz.jpenilla.runpaper.task.RunServer
plugins {
id("java")
alias(libs.plugins.shadowJar)
alias(libs.plugins.publishdata)
alias(libs.plugins.paper.run)
alias(libs.plugins.paper.yml)
alias(libs.plugins.hangar)
alias(libs.plugins.modrinth)
id("olf.build-logic")
`maven-publish`
}
if (!File("$rootDir/.git").exists()) {
logger.lifecycle(
"""
**************************************************************************************
You need to fork and clone this repository! Don't download a .zip file.
If you need assistance, consult the GitHub docs: https://docs.github.com/get-started/quickstart/fork-a-repo
**************************************************************************************
""".trimIndent()
).also { System.exit(1) }
}
group = "net.onelitefeather"
version = "1.2.1"
val supportedMinecraftVersions = listOf(
"1.19.4",
"1.20.6",
"1.21"
)
allprojects {
apply {
plugin("java")
}
repositories {
mavenCentral()
maven("https://repo.codemc.io/repository/maven-public")
maven("https://maven.enginehub.org/repo/")
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
maven("https://papermc.io/repo/repository/maven-public/")
maven("https://oss.sonatype.org/content/repositories/snapshots/")
}
dependencies {
if (name != "internal-api") {
compileOnly(project(":internal-api"))
}
compileOnly(rootProject.libs.paper)
}
}
dependencies {
implementation(libs.bstats)
implementation(libs.minimessage)
implementation(libs.cloud.command.paper)
implementation(libs.cloud.command.extras)
implementation(libs.cloud.command.annotations)
implementation(libs.semver)
implementation("net.kyori:adventure-text-feature-pagination:4.0.0-SNAPSHOT")
annotationProcessor(libs.cloud.command.annotations)
implementation(project(":internal-api"))
implementation(project(":WorldGuardv6Support"))
implementation(project(":WorldGuardv7Support"))
implementation(project(":PlotSquaredv6Support"))
implementation(project(":PlotSquaredv7Support"))
}
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
}
publishData {
useEldoNexusRepos(false)
publishTask("shadowJar")
}
tasks {
named<Jar>("jar") {
archiveClassifier.set("unshaded")
}
named("build") {
dependsOn(shadowJar)
}
supportedMinecraftVersions.forEach { serverVersion ->
register<RunServer>("run-$serverVersion") {
minecraftVersion(serverVersion)
jvmArgs("-DPaper.IgnoreJavaVersion=true", "-Dcom.mojang.eula.agree=true")
group = "run paper"
runDirectory.set(file("run-$serverVersion"))
pluginJars(rootProject.tasks.shadowJar.map { it.archiveFile }.get())
}
}
shadowJar {
archiveClassifier.set("")
relocate("org.bstats", "net.onelitefeather.antiredstoneclockremastered.org.bstats")
}
}
paper {
main = "net.onelitefeather.antiredstoneclockremastered.AntiRedstoneClockRemastered"
apiVersion = "1.19"
authors = listOf("OneLiteFeather", "TheMeinerLP")
serverDependencies {
register("PlotSquared") {
required = false
}
register("WorldGuard") {
required = false
}
}
permissions {
register("antiredstoneclockremastered.notify.admin")
register("antiredstoneclockremastered.notify.disable.donation")
register("antiredstoneclockremastered.notify.admin.update") {
default = BukkitPluginDescription.Permission.Default.OP
}
register("antiredstoneclockremastered.command.reload")
register("antiredstoneclockremastered.command.help")
register("antiredstoneclockremastered.command.feature.check.observer")
register("antiredstoneclockremastered.command.feature.check.piston")
register("antiredstoneclockremastered.command.feature.check.sculk")
register("antiredstoneclockremastered.command.feature.check.redstone_and_repeater")
register("antiredstoneclockremastered.command.feature.check.world.add")
register("antiredstoneclockremastered.command.feature.check.world.remove")
register("antiredstoneclockremastered.command.feature.check.region.remove")
register("antiredstoneclockremastered.command.feature.check.region.add")
register("antiredstoneclockremastered.command.feature.clock.notifyAdmins")
register("antiredstoneclockremastered.command.feature.clock.notifyConsole")
register("antiredstoneclockremastered.command.feature.clock.drop")
register("antiredstoneclockremastered.command.feature.clock.enddelay")
register("antiredstoneclockremastered.command.feature.clock.maxCount")
}
}
val branch = rootProject.branchName()
val baseVersion = publishData.getVersion(false)
val isRelease = !baseVersion.contains('-')
val isMainBranch = branch == "master"
if (!isRelease || isMainBranch) { // Only publish releases from the main branch
val suffixedVersion =
if (isRelease) baseVersion else baseVersion + "+" + System.getenv("GITHUB_RUN_NUMBER")
val changelogContent = if (isRelease) {
"See [GitHub](https://github.com/OneLiteFeatherNET/AntiRedstoneClock-Remastered) for release notes."
} else {
val commitHash = rootProject.latestCommitHash()
"[$commitHash](https://github.com/OneLiteFeatherNET/AntiRedstoneClock-Remastered/commit/$commitHash) ${rootProject.latestCommitMessage()}"
}
hangarPublish {
publications.register("AntiRedstoneClock-Remastered") {
version.set(suffixedVersion)
channel.set(if (isRelease) "Release" else "Snapshot")
changelog.set(changelogContent)
apiKey.set(System.getenv("HANGAR_SECRET"))
id.set("AntiRedstoneClock-Remastered")
platforms {
register(Platforms.PAPER) {
jar.set(tasks.shadowJar.flatMap { it.archiveFile })
platformVersions.set(supportedMinecraftVersions)
}
}
}
}
modrinth {
token.set(System.getenv("MODRINTH_TOKEN"))
projectId.set("UWh9tyEa")
versionType.set(if (isRelease) "release" else "beta")
versionNumber.set(suffixedVersion)
versionName.set(suffixedVersion)
changelog.set(changelogContent)
changelog.set(changelogContent)
uploadFile.set(tasks.shadowJar.flatMap { it.archiveFile })
gameVersions.addAll(supportedMinecraftVersions)
loaders.add("paper")
loaders.add("bukkit")
}
}
publishing {
publications.create<MavenPublication>("maven") {
// Configure our maven publication
publishData.configurePublication(this)
}
repositories {
// We add EldoNexus as our repository. The used url is defined by the publish data.
maven {
authentication {
credentials(PasswordCredentials::class) {
// Those credentials need to be set under "Settings -> Secrets -> Actions" in your repository
username = System.getenv("ELDO_USERNAME")
password = System.getenv("ELDO_PASSWORD")
}
}
name = "EldoNexus"
setUrl(publishData.getRepository())
}
}
}