-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbuild.gradle.kts
143 lines (122 loc) · 4.48 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
@file:Suppress("UnstableApiUsage")
import net.fabricmc.loom.api.LoomGradleExtensionAPI
val buildConfigName: String by project
val license: 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 forgeVersion: String by project
val cctVersion: String by project
val jeiVersion: String by project
val githubUser: String by project
val githubRepo: String by project
plugins {
id("dev.architectury.loom") version "1.3.+"
id("io.github.juuxel.loom-vineflower") version "1.11.0"
id("com.github.gmazzo.buildconfig") version "4.0.4"
java
`maven-publish`
}
base {
version = "$minecraftVersion-$modVersion"
archivesName.set("$modId-forge")
}
loom {
silentMojangMappingsLicense()
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://squiddev.cc/maven/") // CC: Tweaked
maven("https://maven.blamejared.com") // JEI
maven("https://cursemaven.com")
mavenLocal()
}
dependencies {
// Minecraft
minecraft("com.mojang:minecraft:$minecraftVersion")
mappings(loom.layered {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-$minecraftVersion:$parchmentVersion@zip")
})
// Forge
forge("net.minecraftforge:forge:$minecraftVersion-$forgeVersion")
// CC: Tweaked
modCompileOnly("cc.tweaked:cc-tweaked-$minecraftVersion-forge:$cctVersion")
// JEI
modLocalRuntime("mezz.jei:jei-$minecraftVersion-forge:$jeiVersion") { isTransitive = false }
// Testing Mods
modLocalRuntime("curse.maven:pipez-443900:4713656") // Pipez 1.1.5
modLocalRuntime("curse.maven:mekanism-268560:4807067") // Mekanism 10.4.2.16
modLocalRuntime("curse.maven:mekanism-generators-268566:4807070") // Mekanism Generators 10.4.2.16
}
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,
// use major version for FML only because wrong Forge version error message
// is way better than FML error message
"forgeFMLVersion" to forgeVersion.substringBefore("."),
"cctVersion" to cctVersion,
"githubUser" to githubUser,
"githubRepo" to githubRepo
)
println("[Process Resources] Replacing resource properties: ")
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)
}
withType<GenerateModuleMetadata> {
enabled = false
}
}
extensions.configure<JavaPluginExtension> {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}
extensions.configure<LoomGradleExtensionAPI> {
runs {
forEach {
val dir = "run/${it.environment}"
println("[Run Config] '${it.name}' directory: $dir")
it.runDir(dir)
// allows DCEVM hot-swapping when using the JBR (https://github.com/JetBrains/JetBrainsRuntime)
it.vmArgs("-XX:+IgnoreUnrecognizedVMOptions", "-XX:+AllowEnhancedClassRedefinition")
}
}
}
buildConfig {
buildConfigField("String", "MOD_ID", "\"$modId\"")
buildConfigField("String", "MOD_NAME", "\"$modName\"")
buildConfigField("String", "MOD_VERSION", "\"$version\"")
packageName(modPackage)
className(buildConfigName)
useJavaOutput()
}