This repository has been archived by the owner on Aug 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.gradle.kts
176 lines (159 loc) · 5.75 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
@file:Suppress("UnstableApiUsage")
import java.text.SimpleDateFormat
import java.util.*
val modId: String by project
val modName: String by project
val modVersion: String by project
val modBase: String by project
val modAuthor: String by project
val modDescription: String by project
val modCredits: String by project
val mcVersion: String by project
val mcVersionRange: String by project
val forgeVersion: String by project
val forgeVersionRange: String by project
val mappingsChannel: String by project
val mappingsVersion: String by project
val recipeViewer: String by project
val license: String by project
val githubUser: String by project
val githubRepo: String by project
val ae2Version: String by project
val ae2VersionRange: String by project
val jeiVersion: String by project
val jeiVersionRange: String by project
val crtVersion: String by project
val crtVersionRange: String by project
val kubeVersion: String by project
val kubeVersionRange: String by project
plugins {
id("dev.architectury.loom") version "0.12.0-SNAPSHOT"
id("com.github.gmazzo.buildconfig") version "3.0.3"
java
idea
eclipse
}
base {
version = "$mcVersion-$modVersion"
group = "$modBase.$modId"
archivesName.set(modId)
}
loom {
silentMojangMappingsLicense()
forge {
mixinConfig("$modId.mixins.json")
dataGen {
mod(modId)
}
}
launches {
named("client") {
// property("fabric.log.level", "debug")
arg("-XX:+IgnoreUnrecognizedVMOptions", "-XX:+AllowEnhancedClassRedefinition")
}
named("server") {
// property("fabric.log.level", "debug")
arg("-XX:+IgnoreUnrecognizedVMOptions", "-XX:+AllowEnhancedClassRedefinition")
}
named("data") {
arg("--existing", file("src/main/resources").absolutePath)
}
}
}
repositories {
maven("https://maven.parchmentmc.org/")
maven("https://modmaven.dev/")
maven("https://maven.blamejared.com/")
maven("https://maven.saps.dev/minecraft/")
flatDir {
name = "extra-mods"
dir(file("extra-mods-$mcVersion"))
}
}
dependencies {
minecraft("com.mojang:minecraft:$mcVersion")
forge("net.minecraftforge:forge:$mcVersion-$forgeVersion")
mappings(loom.layered {
officialMojangMappings()
parchment("org.parchmentmc.data:$mappingsChannel-$mcVersion:$mappingsVersion@zip")
})
modCompileOnly(modLocalRuntime("appeng:appliedenergistics2-forge:$ae2Version")!!)
modCompileOnly(modLocalRuntime("com.blamejared.crafttweaker:CraftTweaker-forge-$mcVersion:$crtVersion")!!)
modCompileOnly(modLocalRuntime("dev.latvian.mods:kubejs-forge:$kubeVersion")!!)
modCompileOnlyApi("mezz.jei:jei-$mcVersion:$jeiVersion:api")
when (recipeViewer) {
"jei" -> modLocalRuntime("mezz.jei:jei-$mcVersion:$jeiVersion")
"rei" -> modLocalRuntime("me.shedaniel:RoughlyEnoughItems-forge:8+")
else -> throw GradleException("Invalid recipeViewer value: $recipeViewer")
}
fileTree("extra-mods-$mcVersion") { include("**/*.jar") }
.forEach { f ->
val sepIndex = f.nameWithoutExtension.lastIndexOf('-')
if (sepIndex == -1) {
throw IllegalArgumentException("Invalid mod name: ${f.nameWithoutExtension}")
}
val mod = f.nameWithoutExtension.substring(0, sepIndex)
val version = f.nameWithoutExtension.substring(sepIndex + 1)
println("Extra mod $mod with version $version detected")
modLocalRuntime("extra-mods:$mod:$version")
}
}
tasks {
withType<JavaCompile> {
options.encoding = "UTF-8"
options.release.set(17)
}
withType<GenerateModuleMetadata> {
enabled = false
}
jar {
manifest {
attributes(
"Specification-Title" to modName,
"Specification-Vendor" to modAuthor,
"Specification-Version" to "1",
"Implementation-Title" to project.name,
"Implementation-Version" to modVersion,
"Implementation-Vendor" to modAuthor,
"Implementation-Timestamp" to SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(Date()),
"Timestamp" to System.currentTimeMillis(),
"Built-On-Java" to "${System.getProperty("java.vm.version")} (${System.getProperty("java.vm.vendor")})",
"Build-On-Minecraft" to mcVersion
)
}
}
processResources {
val resourceTargets = listOf("META-INF/mods.toml", "pack.mcmeta")
val replaceProperties = mapOf(
"modId" to modId,
"modName" to modName,
"modVersion" to modVersion,
"modAuthor" to modAuthor,
"modDescription" to modDescription,
"modCredits" to modCredits,
"mcVersionRange" to mcVersionRange,
"forgeVersionRange" to forgeVersionRange,
"license" to license,
"githubUser" to githubUser,
"githubRepo" to githubRepo,
"ae2VersionRange" to ae2VersionRange,
"jeiVersionRange" to jeiVersionRange,
"crtVersionRange" to crtVersionRange,
"kubeVersionRange" to kubeVersionRange
)
inputs.properties(replaceProperties)
filesMatching(resourceTargets) {
expand(replaceProperties)
}
}
}
extensions.configure<JavaPluginExtension> {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}
buildConfig {
buildConfigField("String", "MOD_ID", "\"$modId\"")
buildConfigField("String", "MOD_VERSION", "\"$modVersion\"")
buildConfigField("String", "MOD_NAME", "\"$modName\"")
buildConfigField("String", "MOD_GROUP", "\"$modBase.$modId\"")
packageName("$modBase.$modId")
}