generated from isXander/FabricKotlinTemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
build.gradle.kts
264 lines (223 loc) · 7.58 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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
plugins {
`java-library`
kotlin("jvm") version "2.0.21"
kotlin("plugin.serialization") version "2.0.21"
id("fabric-loom") version "1.8.+"
id("me.modmuss50.mod-publish-plugin") version "0.5.+"
`maven-publish`
id("org.ajoberstar.grgit") version "5.0.+"
}
val mcVersion = property("mcVersion")!!.toString()
val mcSemverVersion = stonecutter.current.version
val mcDep = property("fmj.mcDep").toString()
group = "dev.isxander"
val versionWithoutMC = "2.14.2"
version = "$versionWithoutMC+${stonecutter.current.project}"
val isAlpha = "alpha" in version.toString()
val isBeta = "beta" in version.toString()
base {
archivesName.set(property("modName").toString())
}
loom {
if (stonecutter.current.isActive) {
runConfigs.all {
ideConfigGenerated(true)
runDir("../../run")
}
}
mixin {
useLegacyMixinAp.set(false)
}
}
stonecutter {
swap(
"fov-precision",
if (stonecutter.eval(stonecutter.current.version, ">=1.21.2"))
"float" else "double"
)
}
repositories {
mavenCentral()
maven("https://maven.terraformersmc.com")
maven("https://maven.isxander.dev/releases")
maven("https://maven.isxander.dev/snapshots")
maven("https://maven.parchmentmc.org")
maven("https://maven.quiltmc.org/repository/release")
exclusiveContent {
forRepository { maven("https://api.modrinth.com/maven") }
filter { includeGroup("maven.modrinth") }
}
exclusiveContent {
forRepository { maven("https://cursemaven.com") }
filter { includeGroup("curse.maven") }
}
maven("https://jitpack.io")
maven("https://maven.flashyreese.me/snapshots")
maven("https://oss.sonatype.org/content/repositories/snapshots")
}
dependencies {
minecraft("com.mojang:minecraft:$mcVersion")
mappings(loom.layered {
// quilt does not support pre-releases so it is necessary to only layer if they exist
optionalProp("deps.parchment") {
parchment("org.parchmentmc.data:parchment-$it@zip")
}
officialMojangMappings()
})
modImplementation("net.fabricmc:fabric-loader:${property("deps.fabricLoader")}")
val fapiVersion = property("deps.fabricApi").toString()
listOf(
"fabric-resource-loader-v0",
"fabric-lifecycle-events-v1",
"fabric-key-binding-api-v1",
"fabric-command-api-v2",
).forEach {
modImplementation(fabricApi.module(it, fapiVersion))
}
modRuntimeOnly("net.fabricmc.fabric-api:fabric-api:$fapiVersion") // so you can do `depends: fabric-api` in FMJ
modImplementation("net.fabricmc:fabric-language-kotlin:${property("deps.flk")}")
modApi("dev.isxander:yet-another-config-lib:${property("deps.yacl")}") {
// was including old fapi version that broke things at runtime
exclude(group = "net.fabricmc.fabric-api", module = "fabric-api")
}
// mod menu compat
optionalProp("deps.modMenu") {
modImplementation("com.terraformersmc:modmenu:$it")
}
optionalProp("deps.controlify") {
modImplementation("dev.isxander:controlify:$it")
}
modImplementation(include("com.akuleshov7:ktoml-core-jvm:${property("deps.ktoml")}")!!)
}
tasks {
processResources {
val modId: String by project
val modName: String by project
val modDescription: String by project
val githubProject: String by project
val props = mapOf(
"id" to modId,
"group" to project.group,
"name" to modName,
"description" to modDescription,
"version" to project.version,
"github" to githubProject,
"mc" to mcDep
)
props.forEach(inputs::property)
filesMatching("fabric.mod.json") {
expand(props)
}
eachFile {
// don't include photoshop files for the textures for development
if (name.endsWith(".psd")) {
exclude()
}
}
}
register("releaseMod") {
group = "mod"
dependsOn("publishMods")
dependsOn("publish")
}
}
val javaMajorVersion = property("java.version").toString().toInt()
java {
withSourcesJar()
javaMajorVersion
.let { JavaVersion.values()[it - 1] }
.let {
sourceCompatibility = it
targetCompatibility = it
}
}
tasks.withType<JavaCompile> {
options.release = javaMajorVersion
}
kotlin {
jvmToolchain(javaMajorVersion)
}
publishMods {
displayName.set("Zoomify $versionWithoutMC for MC $mcVersion")
file.set(tasks.remapJar.get().archiveFile)
changelog.set(
rootProject.file("changelogs/${versionWithoutMC}.md")
.takeIf { it.exists() }
?.readText()
?: "No changelog provided."
)
type.set(when {
isAlpha -> ALPHA
isBeta -> BETA
else -> STABLE
})
modLoaders.add("fabric")
fun versionList(prop: String) = findProperty(prop)?.toString()
?.split(',')
?.map { it.trim() }
?: emptyList()
// modrinth and curseforge use different formats for snapshots. this can be expressed globally
val stableMCVersions = versionList("pub.stableMC")
val modrinthId: String by project
if (modrinthId.isNotBlank() && hasProperty("modrinth.token")) {
modrinth {
projectId.set(modrinthId)
accessToken.set(findProperty("modrinth.token")?.toString())
minecraftVersions.addAll(stableMCVersions)
minecraftVersions.addAll(versionList("pub.modrinthMC"))
requires { slug.set("fabric-api") }
requires { slug.set("yacl") }
optional { slug.set("modmenu") }
}
}
val curseforgeId: String by project
if (curseforgeId.isNotBlank() && hasProperty("curseforge.token")) {
curseforge {
projectId.set(curseforgeId)
accessToken.set(findProperty("curseforge.token")?.toString())
minecraftVersions.addAll(stableMCVersions)
minecraftVersions.addAll(versionList("pub.curseMC"))
requires { slug.set("fabric-api") }
requires { slug.set("yacl") }
optional { slug.set("modmenu") }
}
}
val githubProject: String by project
if (githubProject.isNotBlank() && hasProperty("github.token")) {
github {
repository.set(githubProject)
accessToken.set(findProperty("github.token")?.toString())
commitish.set(grgit.branch.current().name)
}
}
}
publishing {
publications {
create<MavenPublication>("mod") {
groupId = "dev.isxander"
artifactId = "zoomify"
from(components["java"])
}
}
repositories {
val username = "XANDER_MAVEN_USER".let { System.getenv(it) ?: findProperty(it) }?.toString()
val password = "XANDER_MAVEN_PASS".let { System.getenv(it) ?: findProperty(it) }?.toString()
if (username != null && password != null) {
maven(url = "https://maven.isxander.dev/releases") {
name = "XanderReleases"
credentials {
this.username = username
this.password = password
}
}
} else {
println("Xander Maven credentials not satisfied.")
}
}
}
fun <T> optionalProp(property: String, block: (String) -> T?) {
findProperty(property)?.toString()?.takeUnless { it.isBlank() }?.let(block)
}
fun isPropDefined(property: String): Boolean {
return findProperty(property)?.toString()?.isNotBlank() ?: false
}