-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbuild.gradle.kts
230 lines (186 loc) · 6.54 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
import com.matthewprenger.cursegradle.CurseArtifact
import com.matthewprenger.cursegradle.CurseProject
import com.matthewprenger.cursegradle.CurseRelation
import com.modrinth.minotaur.dependencies.DependencyType
import com.modrinth.minotaur.dependencies.ModDependency
import groovy.json.JsonGenerator
import groovy.json.JsonSlurper
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm").version("1.8.10")
kotlin("plugin.serialization").version("1.8.10")
id("fabric-loom").version("1.1.+")
id("com.matthewprenger.cursegradle").version("1.4.0")
id("com.modrinth.minotaur").version("2.4.5")
id("maven-publish")
}
val prop = Property()
val env: Map<String, String> = System.getenv()
version = env["MOD_VERSION"] ?: "local"
repositories {
maven("https://maven.bai.lol")
maven("https://maven.shedaniel.me/")
maven("https://maven.terraformersmc.com/releases")
maven("https://maven.blamejared.com/")
maven("https://ladysnake.jfrog.io/artifactory/mods")
}
dependencies {
minecraft("com.mojang:minecraft:${prop["minecraft"]}")
mappings("net.fabricmc:yarn:${prop["yarn"]}:v2")
modImplementation("net.fabricmc:fabric-loader:${prop["fabricLoader"]}")
modImplementation("net.fabricmc.fabric-api:fabric-api:${prop["fabricApi"]}")
modImplementation("net.fabricmc:fabric-language-kotlin:${prop["fabricKotlin"]}")
modImplementation("dev.onyxstudios.cardinal-components-api:cardinal-components-base:${prop["cca"]}")
modImplementation("dev.emi:trinkets:${prop["trinkets"]}")
modCompileOnly("mcp.mobius.waila:wthit-api:fabric-${prop["wthit"]}")
modRuntimeOnly("mcp.mobius.waila:wthit:fabric-${prop["wthit"]}")
modRuntimeOnly("lol.bai:badpackets:fabric-${prop["badpackets"]}")
modRuntimeOnly("dev.architectury:architectury-fabric:${prop["architectury"]}")
modCompileOnly("me.shedaniel:RoughlyEnoughItems-api-fabric:${prop["rei"]}")
modCompileOnly("me.shedaniel:RoughlyEnoughItems-default-plugin-fabric:${prop["rei"]}")
modCompileOnly("dev.emi:emi:${prop["emi"]}")
prop["jei"].split("-").also { (mc, jei) ->
modCompileOnly("mezz.jei:jei-${mc}-fabric:${jei}") { isTransitive = false }
}
when (prop["recipeViewer"]) {
"emi" -> modRuntimeOnly("dev.emi:emi:${prop["emi"]}")
"rei" -> modRuntimeOnly("me.shedaniel:RoughlyEnoughItems-fabric:${prop["rei"]}")
"jei" -> prop["jei"].split("-").also { (mc, jei) ->
modRuntimeOnly("mezz.jei:jei-${mc}-fabric:${jei}")
}
}
}
sourceSets {
val main by getting
val devrun by creating
val datagen by creating
listOf(devrun, datagen).forEach {
it.compileClasspath += main.compileClasspath + main.output
it.runtimeClasspath += main.runtimeClasspath + main.output
}
val generated by creating {
compiledBy("runDatagen")
resources {
srcDir(file("src/generated/output"))
}
}
devrun.apply {
compileClasspath += generated.output
runtimeClasspath += generated.output
}
}
loom {
runs {
getByName("client") {
source("devrun")
}
getByName("server") {
source("devrun")
}
create("datagen") {
server()
name("Data Generation")
vmArgs(
"-Dfabric-api.datagen",
"-Dfabric-api.datagen.output-dir=${file("src/generated/output")}",
"-Dfabric-api.datagen.modid=slotlink_datagen"
)
runDir("build/datagen")
source("datagen")
}
}
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
tasks.getByName("runDatagen") {
inputs.dir(file("src/datagen"))
outputs.dir(file("src/generated"))
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "17"
}
}
tasks.jar {
from(sourceSets["generated"].output) {
exclude("fabric.mod.json")
exclude(".cache/**")
}
}
tasks.getByName("processGeneratedResources") {
dependsOn("runDatagen")
}
tasks.withType<ProcessResources> {
inputs.property("version", project.version)
filesMatching("fabric.mod.json") {
expand("version" to project.version)
}
doLast {
val slurper = JsonSlurper()
val json = JsonGenerator.Options()
.disableUnicodeEscaping()
.build()
fileTree(outputs.files.asPath) {
include("**/*.json")
forEach {
val mini = json.toJson(slurper.parse(it, "UTF-8"))
it.writeText(mini)
}
}
}
}
curseforge {
env["CURSEFORGE_API"]?.let { CURSEFORGE_API ->
apiKey = CURSEFORGE_API
project(closureOf<CurseProject> {
id = prop["cf.projectId"]
releaseType = prop["cf.releaseType"]
changelogType = "markdown"
changelog = "https://github.com/badasintended/slotlink/releases/tag/${project.version}"
mainArtifact(tasks["remapJar"], closureOf<CurseArtifact> {
displayName = "[${prop["minecraft"]}] v${project.version}"
})
addGameVersion("Fabric")
prop["cf.gameVersion"].split(", ").forEach {
addGameVersion(it)
}
relations(closureOf<CurseRelation> {
prop["cf.require"].split(", ").forEach {
requiredDependency(it)
}
prop["cf.optional"].split(", ").forEach {
optionalDependency(it)
}
})
afterEvaluate {
uploadTask.dependsOn("build")
}
})
}
}
modrinth {
env["MODRINTH_TOKEN"]?.let { MODRINTH_TOKEN ->
token.set(MODRINTH_TOKEN)
projectId.set(prop["mr.projectId"])
versionNumber.set(version.toString())
versionType.set(prop["mr.releaseType"])
changelog.set("https://github.com/badasintended/slotlink/releases/tag/${project.version}")
uploadFile.set(tasks["remapJar"])
loaders.addAll("fabric", "quilt")
gameVersions.addAll(prop["mr.gameVersion"].split(", "))
prop["mr.require"].split(", ").forEach {
dependencies.add(ModDependency(it, DependencyType.REQUIRED))
}
prop["mr.optional"].split(", ").forEach {
dependencies.add(ModDependency(it, DependencyType.OPTIONAL))
}
}
}
class Property {
operator fun get(name: String) = project.property(name).toString()
}