-
Notifications
You must be signed in to change notification settings - Fork 21
/
build.gradle.kts
234 lines (198 loc) · 6.42 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
227
228
229
230
231
232
233
234
import org.jetbrains.changelog.Changelog
plugins {
java
id("maven-publish")
id("fabric-loom") version "1.7.+"
kotlin("jvm") version "2.0.20"
id("io.github.goooler.shadow") version "8.1.7"
kotlin("plugin.serialization") version "2.0.20"
id("me.modmuss50.mod-publish-plugin") version "0.7.4"
id("org.jetbrains.changelog") version "2.+"
}
configurations.implementation.get().extendsFrom(configurations.shadow.get())
allprojects {
val modId: String by project
val modName: String by project
val modVersion: String by project
val mavenGroup: String by project
apply(plugin = "fabric-loom")
base.archivesName.set(modId)
group = mavenGroup
version = "$modVersion+${rootProject.libs.versions.minecraft.get()}"
java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
loom {
//serverOnlyMinecraftJar()
}
repositories {
mavenCentral()
maven {
name = "Fabric"
url = uri("https://maven.fabricmc.net/")
}
maven("https://api.modrinth.com/maven")
maven("https://oss.sonatype.org/content/repositories/snapshots")
}
// Declare dependencies
dependencies {
// Fabric
minecraft(rootProject.libs.minecraft)
mappings(variantOf(rootProject.libs.yarn.mappings) { classifier("v2") })
modImplementation(rootProject.libs.fabric.loader)
// Mods
modImplementation(rootProject.libs.fabric.api)
// Optional deps
modRuntimeOnly(rootProject.libs.permission.api)
}
// Produce a sources distribution
java {
withSourcesJar()
}
// Add the licence to all distributions
tasks.withType<AbstractArchiveTask> {
from(file("LICENSE.txt"))
}
// Process any resources
tasks.processResources {
inputs.property("id", modId)
inputs.property("name", modName)
inputs.property("version", modVersion)
// fabric.mod.json
filesMatching("fabric.mod.json") {
expand(
mapOf(
"id" to modId,
"name" to modName,
"version" to modVersion,
"fabricLoader" to libs.versions.fabric.loader.get(),
"fabricApi" to libs.versions.fabric.api.get(),
)
)
}
}
}
repositories {
mavenCentral()
maven("https://maven.nucleoid.xyz/")
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
}
dependencies {
modImplementation(libs.fabric.kotlin)
modImplementation(libs.placeholder.api)
include(libs.placeholder.api)
modImplementation(libs.permission.api)
include(libs.permission.api)
shadow(libs.mcDiscordReserializer)
shadow(libs.adventure.gson)
shadow(libs.kord.extensions)
shadow(libs.emoji)
shadow(libs.konf.base)
shadow(libs.konf.toml)
// Optional deps
modCompileOnly(rootProject.libs.vanish.api)
subprojects.forEach {
implementation(project(":${it.name}", "namedElements"))
include(project("${it.name}:")) // nest within distribution
}
}
publishMods {
file.set(tasks.remapJar.get().archiveFile)
type.set(STABLE)
changelog.set(fetchChangelog())
displayName.set("Blockbot ${version.get()}")
modLoaders.add("fabric")
modLoaders.add("quilt")
val minecraftVersion = rootProject.libs.versions.minecraft.get()
curseforge {
accessToken.set(providers.environmentVariable("CF_API_TOKEN"))
projectId.set("482904")
minecraftVersions.add(minecraftVersion)
}
modrinth {
accessToken.set(providers.environmentVariable("MODRINTH_TOKEN"))
projectId.set("yKZ9outG")
minecraftVersions.add(minecraftVersion)
}
github {
accessToken.set(providers.environmentVariable("GITHUB_TOKEN"))
repository.set(providers.environmentVariable("GITHUB_REPOSITORY").getOrElse("QuiltServerTools/dryrun"))
commitish.set(providers.environmentVariable("GITHUB_REF_NAME").getOrElse("dryrun"))
}
}
tasks {
remapJar {
dependsOn(shadowJar)
input.set(shadowJar.get().archiveFile)
}
compileKotlin {
kotlinOptions {
jvmTarget = "21"
}
}
shadowJar {
from("LICENSE")
configurations = listOf(
project.configurations.shadow.get()
)
archiveClassifier.set("dev-all")
minimize {
exclude(project(":blockbot-api"))
}
exclude("kotlin/**", "kotlinx/coroutines/**", "kotlinx/serialization/**", "javax/**", "META-INF")
exclude("org/checkerframework/**", "org/intellij/**", "org/jetbrains/annotations/**")
exclude("com/google/gson/**")
exclude("org/slf4j/**")
exclude("org/bouncycastle/**")
exclude("com/codahale/**")
relocate("com.fasterxml")
relocate("com.moandjiezana")
relocate("com.uchuhimo")
relocate("com.github.zafarkhaja")
relocate("com.googlecode")
relocate("com.ibm")
relocate("com.iwebpp")
relocate("com.kotlindiscord")
relocate("com.sun")
relocate("com.typesafe")
relocate("com.vdurmont")
relocate("javassist")
relocate("dev.kord")
relocate("dev.vankka")
relocate("io.ktor")
relocate("io.sentry")
relocate("org.apache.commons")
relocate("org.eclipse")
relocate("org.gjt")
relocate("org.jaxen")
relocate("org.json")
relocate("org.koin")
relocate("org.pf4j")
relocate("org.relaxng")
relocate("org.reflections")
relocate("org.xml")
relocate("org.xmlpull")
relocate("org.yaml")
relocate("org.dom4j")
relocate("kotlinx.atomicfu")
relocate("kotlinx.datetime")
relocate("net.kyori")
relocate("net.peanuuutz")
}
}
fun com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar.relocate(pattern: String) {
this.relocate(pattern, "io.github.quiltservertools.blockbotdiscord.libs.$pattern")
}
private fun fetchChangelog(): String {
val changelog = tasks.getChangelog.get().changelog.get()
val modVersion: String by project
return if (changelog.has(modVersion)) {
changelog.renderItem(
changelog.get(modVersion).withHeader(false),
Changelog.OutputType.MARKDOWN
)
} else {
""
}
}