forked from BreweryTeam/BreweryX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
226 lines (198 loc) · 8.95 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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
/*
* BreweryX Bukkit-Plugin for an alternate brewing process
* Copyright (C) 2024 The Brewery Team
*
* This file is part of BreweryX.
*
* BreweryX is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BreweryX is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with BreweryX. If not, see <http://www.gnu.org/licenses/gpl-3.0.html>.
*/
import org.apache.commons.io.output.ByteArrayOutputStream
import org.apache.tools.ant.filters.ReplaceTokens
import java.nio.charset.Charset
plugins {
id("java")
id("maven-publish")
id("com.gradleup.shadow") version "8.3.5"
}
val langVersion = 17
val encoding = "UTF-8"
group = "com.dre.brewery"
version = "3.4.4"
repositories {
mavenCentral()
maven("https://jitpack.io") // GriefPrevention, SlimeFun, PlaceholderAPI
maven("https://repo.md-5.net/content/groups/public/") // Bungee
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") // Spigot
maven("https://nexus.hc.to/content/repositories/pub_releases") // Vault
maven("https://maven.enginehub.org/repo/") // WorldEdit, WorldGuard
maven("https://ci.ender.zone/plugin/repository/everything/") // LWC Extended
maven("https://repo.minebench.de/") // ChestShop
maven("https://repo.codemc.org/repository/maven-public/") // BlockLocker
maven("https://nexus.phoenixdevt.fr/repository/maven-public/") // MythicLib (MMOItems)
maven("https://repo.projectshard.dev/repository/releases/") // Shopkeepers
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/") // PlaceholderAPI
maven("https://repo.glaremasters.me/repository/towny/") // Towny
maven("https://repo.oraxen.com/releases") // Oraxen
maven("https://storehouse.okaeri.eu/repository/maven-public/") // Okaeri Config
maven("https://papermc.io/repo/repository/maven-public/") // PaperLib
}
dependencies {
// Spigot
compileOnly("org.spigotmc:spigot-api:1.20.2-R0.1-SNAPSHOT") {
exclude("com.google.code.gson", "gson") // Implemented manually
}
// Paper Lib, performance improvements on Paper based servers and async teleporting on Folia
implementation("io.papermc:paperlib:1.0.8")
// Implemented manually mainly due to older server versions implementing versions of GSON
// Which don't support records.
implementation("com.google.code.gson:gson:2.11.0")
// For proper scheduling between Bukkit-Folia like servers, https://github.com/Anon8281/UniversalScheduler
implementation("com.github.Anon8281:UniversalScheduler:0.1.3")
// Nice annotations, I prefer these to Lombok's, https://www.jetbrains.com/help/idea/annotating-source-code.html
implementation("org.jetbrains:annotations:16.0.2")
// MongoDB & log4j to suppress MongoDB's logger
implementation("org.mongodb:mongodb-driver-sync:5.3.0-beta0")
compileOnly("org.apache.logging.log4j:log4j-core:2.23.1")
// Lombok
compileOnly("org.projectlombok:lombok:1.18.30")
annotationProcessor("org.projectlombok:lombok:1.18.30")
// Okaeri configuration
implementation("eu.okaeri:okaeri-configs-yaml-snakeyaml:5.0.5") {
exclude("org.yaml", "snakeyaml")
}
constraints {
implementation("org.yaml:snakeyaml") {
version {
require("2.3")
reject("1.33")
}
}
}
// Plugin Compatability
compileOnly("net.milkbowl.vault:VaultAPI:1.6")
compileOnly("com.sk89q:worldguard:6.1") // https://dev.bukkit.org/projects/worldedit/files
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.7")
compileOnly("com.sk89q.worldedit:worldedit-bukkit:7.3.0-SNAPSHOT") // https://dev.bukkit.org/projects/worldedit/files
compileOnly("com.sk89q.worldedit:worldedit-core:7.3.0-SNAPSHOT") // https://dev.bukkit.org/projects/worldguard/files
compileOnly("com.griefcraft.lwc:LWCX:2.2.9-dev")// https://www.spigotmc.org/resources/lwc-extended.69551/history
compileOnly("com.github.TechFortress:GriefPrevention:16.18") // https://www.spigotmc.org/resources/griefprevention.1884/history
compileOnly("de.diddiz:logblock:1.16.5.1") // https://www.spigotmc.org/resources/logblock.67333/history
compileOnly("com.github.Slimefun:Slimefun4:RC-35") // https://github.com/Slimefun/Slimefun4/releases
compileOnly("io.lumine:MythicLib-dist:1.6-SNAPSHOT") // https://www.spigotmc.org/resources/mythiclib.90306/history
compileOnly("com.acrobot.chestshop:chestshop:3.12.2") // https://github.com/ChestShop-authors/ChestShop-3/releases
compileOnly("com.palmergames.bukkit.towny:towny:0.100.3.0") // https://www.spigotmc.org/resources/towny-advanced.72694/history
compileOnly("com.nisovin.shopkeepers:ShopkeepersAPI:2.18.0") // https://www.spigotmc.org/resources/shopkeepers.80756/history
compileOnly("nl.rutgerkok:blocklocker:1.10.4") // https://www.spigotmc.org/resources/blocklocker.3268/history
compileOnly("me.clip:placeholderapi:2.11.5") // https://www.spigotmc.org/resources/placeholderapi.6245/history
compileOnly("io.th0rgal:oraxen:1.163.0") // https://www.spigotmc.org/resources/%E2%98%84%EF%B8%8F-oraxen-custom-items-blocks-emotes-furniture-resourcepack-and-gui-1-18-1-21-3.72448/
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.6.1") // https://www.spigotmc.org/resources/%E2%9C%A8itemsadder%E2%AD%90emotes-mobs-items-armors-hud-gui-emojis-blocks-wings-hats-liquids.73355/updates
testImplementation(platform("org.junit:junit-bom:5.9.1"))
testImplementation("org.junit.jupiter:junit-jupiter")
}
tasks {
build {
dependsOn(shadowJar)
finalizedBy("kotlinReducedJar")
}
jar {
enabled = false // Shadow produces our jar files
}
withType<JavaCompile>().configureEach {
options.encoding = encoding
}
test {
useJUnitPlatform()
}
processResources {
outputs.upToDateWhen { false }
filter<ReplaceTokens>(mapOf(
"tokens" to mapOf("version" to "${project.version};${getGitBranch()}"),
"beginToken" to "\${",
"endToken" to "}"
)).filteringCharset = encoding
}
shadowJar {
relocate("com.google", "com.dre.brewery.depend.google")
relocate("com.github.Anon8281.universalScheduler", "com.dre.brewery.depend.universalScheduler")
relocate("eu.okaeri", "com.dre.brewery.depend.okaeri")
relocate("com.mongodb", "com.dre.brewery.depend.mongodb")
relocate("io.papermc.lib", "com.dre.brewery.depend.paperlib")
archiveClassifier.set("")
}
// Kotlin Reduced Jars
register<Copy>("prepareKotlinReducedJar") {
dependsOn(shadowJar)
from(zipTree(shadowJar.get().archiveFile))
into(layout.buildDirectory.dir("kt-reduced"))
doLast {
val pluginFile = layout.buildDirectory.file("kt-reduced/plugin.yml").get().asFile
var content = pluginFile.readText()
content = content.replace("libraries: ['org.jetbrains.kotlin:kotlin-stdlib:2.0.21']", "")
pluginFile.writeText(content)
}
}
register<Jar>("kotlinReducedJar") {
dependsOn("prepareKotlinReducedJar")
from(layout.buildDirectory.dir("kt-reduced"))
include("**/*")
duplicatesStrategy = DuplicatesStrategy.INHERIT
archiveClassifier.set("KtReduced")
}
}
fun getGitBranch(): String = ByteArrayOutputStream().use { stream ->
var branch = "none"
project.exec {
commandLine = listOf("git", "rev-parse", "--abbrev-ref", "HEAD")
standardOutput = stream
}
if (stream.size() > 0) branch = stream.toString(Charset.defaultCharset().name()).trim()
return branch
}
java {
toolchain.languageVersion = JavaLanguageVersion.of(langVersion)
}
publishing {
val repoUrl = System.getenv("repo_url") ?: "https://repo.jsinco.dev/releases"
val user = System.getenv("repo_username")
val pass = System.getenv("repo_secret")
repositories {
if (user == null || pass == null) {
println("No repository credentials found, skipping publication")
return@repositories
}
maven {
url = uri(repoUrl)
credentials(PasswordCredentials::class) {
username = user
password = pass
}
authentication {
create<BasicAuthentication>("basic")
}
}
}
publications {
if (user == null || pass == null) {
return@publications
}
create<MavenPublication>("maven") {
groupId = project.group.toString()
artifactId = "BreweryX"
version = project.version.toString()
artifact(tasks.shadowJar.get().archiveFile) {
builtBy(tasks.shadowJar)
}
}
}
}