-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
180 lines (145 loc) · 5.19 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
plugins {
id("java")
id("maven-publish")
id("fabric-loom") version "1.8-SNAPSHOT"
id("com.modrinth.minotaur") version "2.+"
id("me.modmuss50.mod-publish-plugin") version "0.5.+"
}
repositories {
maven("https://api.modrinth.com/maven") {
name = "Modrinth"
}
maven("https://maven.terraformersmc.com/releases/") {
name = "TerraformersMC"
}
}
object Constants {
const val ARCHIVES_BASE_NAME: String = "ctm-selector"
const val MOD_VERSION: String = "0.3.0"
const val LOADER_VERSION: String = "0.16.7"
}
class ModData {
val hasVersionRange = properties.containsKey("range_name")
val mcVersion = property("minecraft_version").toString()
val rangedName = if (hasVersionRange) property("range_name").toString() else mcVersion
private val modrinthVersions = if (hasVersionRange) property("modrinth_versions") else mcVersion
val versionsList = modrinthVersions.toString().split(" ")
val min = if (hasVersionRange) versionsList[0] else mcVersion
val max = if (hasVersionRange) versionsList[versionsList.size - 1] else mcVersion
val fabricVersion = property("fabric_version").toString()
val modmenuVersion = property("modmenu_version").toString()
val continuityVersion = property("continuity_version").toString()
val fullVersion = "${Constants.MOD_VERSION}+${rangedName}"
val isj21 = mcVersion !in listOf("1.19.4", "1.20.1", "1.20.2", "1.20.4")
val javaVersion = if (isj21) "21" else "17"
}
val mod = ModData()
// Sets the name of the output jar files
base {
archivesName = "${Constants.ARCHIVES_BASE_NAME}-${mod.fullVersion}"
group = "fr.aeldit.ctms"
}
dependencies {
minecraft("com.mojang:minecraft:${mod.mcVersion}")
mappings("net.fabricmc:yarn:${property("yarn_mappings")}:v2")
modImplementation("net.fabricmc:fabric-loader:${Constants.LOADER_VERSION}")
modImplementation("net.fabricmc.fabric-api:fabric-api:${mod.fabricVersion}")
// Fabric API
for (name in listOf(
// ModMenu dependencies
"fabric-resource-loader-v0",
"fabric-key-binding-api-v1",
// CyanLib dependencies
"fabric-lifecycle-events-v1",
"fabric-screen-api-v1"
)) {
val module = fabricApi.module(name, mod.fabricVersion)
modImplementation(module)
}
// ModMenu
modImplementation("com.terraformersmc:modmenu:${mod.modmenuVersion}")
// Continuity
modLocalRuntime("maven.modrinth:continuity:${mod.continuityVersion}")
// zip4j
implementation("net.lingala.zip4j:zip4j:2.11.5")
include("net.lingala.zip4j:zip4j:2.11.5")
}
loom {
runConfigs.all {
ideConfigGenerated(true) // Run configurations are not created for subprojects by default
runDir = "../../run" // Use a shared run folder and just create separate worlds
}
}
java {
sourceCompatibility = if (mod.isj21) JavaVersion.VERSION_21 else JavaVersion.VERSION_17
targetCompatibility = if (mod.isj21) JavaVersion.VERSION_21 else JavaVersion.VERSION_17
}
val buildAndCollect = tasks.register<Copy>("buildAndCollect") {
group = "build"
from(tasks.remapJar.get().archiveFile)
into(rootProject.layout.buildDirectory.file("libs/${Constants.ARCHIVES_BASE_NAME}-${mod.fullVersion}"))
dependsOn("build")
}
if (stonecutter.current.isActive) {
rootProject.tasks.register("buildActive") {
group = "project"
dependsOn(buildAndCollect)
}
}
tasks {
processResources {
inputs.property("version", mod.fullVersion)
inputs.property("loader_version", Constants.LOADER_VERSION)
inputs.property("min", mod.min)
inputs.property("max", mod.max)
inputs.property("java_version", mod.javaVersion)
filesMatching("fabric.mod.json") {
expand(
mapOf(
"version" to mod.fullVersion,
"loader_version" to Constants.LOADER_VERSION,
"min" to mod.min,
"max" to mod.max,
"java_version" to mod.javaVersion
)
)
}
}
jar {
from("LICENSE")
}
withType<JavaCompile> {
options.encoding = "UTF-8"
options.release = if (mod.isj21) 21 else 17
}
}
publishMods {
modrinth {
accessToken = System.getenv("MODRINTH_TOKEN")
projectId = "6OpnBWtt"
displayName = "[${mod.rangedName}] CTM Selector ${Constants.MOD_VERSION}"
version = mod.fullVersion
type = STABLE
file = tasks.remapJar.get().archiveFile
if (mod.hasVersionRange) {
minecraftVersions.addAll(mod.versionsList)
} else {
minecraftVersions.add(mod.mcVersion)
}
modLoaders.add("fabric")
requires("fabric-api", "modmenu", "continuity")
changelog = rootProject.file("changelogs/latest.md")
.takeIf { it.exists() }
?.readText()
?: "No changelog provided."
dryRun = true
}
}
modrinth {
token.set(System.getenv("MODRINTH_TOKEN"))
projectId.set(Constants.ARCHIVES_BASE_NAME)
if (rootProject.file("README.md").exists()) {
syncBodyFrom.set(rootProject.file("README.md").readText())
}
debugMode = false
}