-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.gradle.kts
154 lines (132 loc) · 4.93 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
@file:Suppress("UnstableApiUsage")
import net.fabricmc.loom.api.LoomGradleExtensionAPI
val license: String by project
val enableAccessWidener: String by project
val minecraftVersion: String by project
val modVersion: String by project
val modPackage: String by project
val modId: String by project
val modName: String by project
val modAuthor: String by project
val modDescription: String by project
val modCredits: String by project
val parchmentVersion: String by project
val manifoldVersion: String by project
val forgeVersion: String by project
val forgeRecipeViewer: String by project
val jeiVersion: String by project
val reiVersion: String by project
val kubeVersion: String by project
val githubUser: String by project
val githubRepo: String by project
plugins {
id("dev.architectury.loom") version "1.2.+"
id("io.github.juuxel.loom-vineflower") version "1.11.0"
id("com.github.gmazzo.buildconfig") version "4.0.4"
java
}
base {
version = "$minecraftVersion-$modVersion"
group = modPackage
archivesName.set("$modId-forge")
}
loom {
silentMojangMappingsLicense()
forge {
mixinConfig("$modId.mixins.json")
}
if (project.findProperty("enableAccessWidener") == "true") {
accessWidenerPath.set(file("src/main/resources/$modId.accesswidener"))
forge {
convertAccessWideners.set(true)
extraAccessWideners.add(loom.accessWidenerPath.get().asFile.name)
}
println("Access widener enabled for project. Access widener path: ${loom.accessWidenerPath.get()}")
}
}
repositories {
maven("https://maven.parchmentmc.org/") // Parchment
maven("https://maven.blamejared.com") // JEI
maven("https://maven.shedaniel.me") // REI
maven("https://maven.saps.dev/minecraft") // KubeJS
mavenLocal()
}
dependencies {
// Minecraft
minecraft("com.mojang:minecraft:$minecraftVersion")
mappings(loom.layered {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-$minecraftVersion:$parchmentVersion@zip")
})
// Project
implementation("systems.manifold:manifold-ext-rt:$manifoldVersion")
annotationProcessor("systems.manifold:manifold-ext:$manifoldVersion")
// Forge
forge("net.minecraftforge:forge:$minecraftVersion-$forgeVersion")
// Compile
modCompileOnlyApi("mezz.jei:jei-$minecraftVersion-common-api:$jeiVersion") { isTransitive = false }
modCompileOnlyApi("mezz.jei:jei-$minecraftVersion-forge-api:$jeiVersion") { isTransitive = false }
modCompileOnly("me.shedaniel:RoughlyEnoughItems-forge:$reiVersion")
compileOnly("me.shedaniel:REIPluginCompatibilities-forge-annotations:9.+")
modCompileOnly("dev.latvian.mods:kubejs-forge:$kubeVersion")
// Runtime
modLocalRuntime("dev.latvian.mods:kubejs-forge:$kubeVersion")
when (forgeRecipeViewer) {
"rei" -> modLocalRuntime("me.shedaniel:RoughlyEnoughItems-forge:$reiVersion")
"jei" -> modLocalRuntime("mezz.jei:jei-$minecraftVersion-forge:$jeiVersion") { isTransitive = false }
else -> throw GradleException("Invalid recipeViewer value: $forgeRecipeViewer")
}
}
tasks {
processResources {
val resourceTargets = listOf("META-INF/mods.toml", "pack.mcmeta")
val replaceProperties = mapOf(
"license" to license,
"minecraftVersion" to minecraftVersion,
"version" to project.version as String,
"modId" to modId,
"modName" to modName,
"modAuthor" to modAuthor,
"modDescription" to modDescription,
"modCredits" to modCredits,
"forgeVersion" to forgeVersion,
"forgeLoaderVersion" to forgeVersion.substringBefore("."),
"jeiVersion" to jeiVersion,
"reiVersion" to reiVersion,
"kubeVersion" to kubeVersion,
"githubUser" to githubUser,
"githubRepo" to githubRepo
)
println("[Process Resources] Replacing properties in resources: ")
replaceProperties.forEach { (key, value) -> println("\t -> $key = $value") }
inputs.properties(replaceProperties)
filesMatching(resourceTargets) {
expand(replaceProperties)
}
}
withType<JavaCompile> {
options.encoding = "UTF-8"
options.release.set(17)
options.compilerArgs.add("-Xplugin:Manifold no-bootstrap")
}
withType<GenerateModuleMetadata> {
enabled = false
}
}
extensions.configure<JavaPluginExtension> {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}
extensions.configure<LoomGradleExtensionAPI> {
runs {
forEach {
it.vmArgs("-XX:+IgnoreUnrecognizedVMOptions", "-XX:+AllowEnhancedClassRedefinition")
}
}
}
buildConfig {
buildConfigField("String", "MOD_ID", "\"$modId\"")
buildConfigField("String", "MOD_NAME", "\"$modName\"")
buildConfigField("String", "MOD_VERSION", "\"$version\"")
packageName(modPackage)
useJavaOutput()
}