-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
127 lines (102 loc) · 3.73 KB
/
build.gradle.kts
File metadata and controls
127 lines (102 loc) · 3.73 KB
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
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("net.fabricmc.fabric-loom-remap") version "1.14-SNAPSHOT"
id("org.jetbrains.kotlin.jvm") version "2.3.0"
id("dev.deftu.gradle.bloom") version "0.2.0"
id("me.modmuss50.mod-publish-plugin") version "1.1.0"
}
val modid = property("mod.id")
val modname = property("mod.name")
val modversion = property("mod.version")
val mcversion = stonecutter.current.version
val oneconfigversion = property("oneconfig_version")
version = "$modversion+$mcversion"
base.archivesName = modname.toString()
repositories {
maven("https://maven.parchmentmc.org")
maven("https://repo.polyfrost.org/releases")
maven("https://repo.polyfrost.org/snapshots")
maven("https://maven.gegy.dev/releases")
}
loom {
runConfigs.all {
ideConfigGenerated(stonecutter.current.isActive)
runDir = "../../run" // This sets the run folder for all mc versions to the same folder. Remove this line if you want individual run folders.
}
runConfigs.remove(runConfigs["server"]) // Removes server run configs
}
dependencies {
minecraft("com.mojang:minecraft:$mcversion")
@Suppress("UnstableApiUsage")
mappings(loom.layered {
officialMojangMappings()
optionalProp("${property("parchment_version")}") {
parchment("org.parchmentmc.data:parchment-$mcversion:$it@zip")
}
optionalProp("${property("yalmm_version")}") {
mappings("dev.lambdaurora:yalmm-mojbackward:$mcversion+build.$it")
}
})
modImplementation("net.fabricmc:fabric-loader:${property("loader_version")}")
modImplementation("org.polyfrost.oneconfig:$mcversion-fabric:$oneconfigversion")
for (module in arrayOf("config", "config-impl", "internal", "ui")) {
implementation("org.polyfrost.oneconfig:$module:$oneconfigversion")
}
}
bloom {
replacement("@MOD_ID@", modid!!)
replacement("@MOD_NAME@", modname!!)
replacement("@MOD_VERSION@", modversion!!)
}
tasks.processResources {
val props = mapOf(
"mod_id" to modid,
"mod_name" to modname,
"mod_version" to modversion,
"mc_version" to mcversion,
"loader_version" to providers.gradleProperty("loader_version").get()
)
inputs.properties(props)
filesMatching("fabric.mod.json") {
expand(props)
}
}
tasks.withType<JavaCompile>().configureEach {
options.release.set(21)
}
tasks.withType<KotlinCompile>().configureEach {
compilerOptions.jvmTarget.set(JvmTarget.JVM_21)
}
java {
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
tasks.jar {
inputs.property("archivesName", base.archivesName)
from("LICENSE") {
rename { "${it}_${inputs.properties["archivesName"]}" }
}
}
fun <T> optionalProp(property: String, block: (String) -> T?): T? =
findProperty(property)?.toString()?.takeUnless { it.isBlank() }?.let(block)
val modrinthId = findProperty("publish.modrinth")?.toString()?.takeIf { it.isNotBlank() }
// make sure modrinth.token is set in your user gradle properties
publishMods {
file = project.tasks.remapJar.get().archiveFile
displayName = modversion.toString()
version = "v$modversion"
changelog = project.rootProject.file("CHANGELOG.md").takeIf { it.exists() }?.readText() ?: "No changelog provided."
type = ALPHA
modLoaders.add("fabric")
dryRun = modrinthId == null
if (modrinthId != null) {
modrinth {
projectId = property("publish.modrinth").toString()
accessToken = findProperty("modrinth.token").toString()
minecraftVersions.add(mcversion)
requires("oneconfig")
}
}
}