forked from Creators-of-Create/Create
-
Notifications
You must be signed in to change notification settings - Fork 200
/
build.gradle
236 lines (196 loc) · 8.6 KB
/
build.gradle
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
import java.util.jar.JarEntry
import java.util.jar.JarOutputStream
//file:noinspection GrMethodMayBeStatic
plugins {
id "fabric-loom" version "1.5.+"
id "io.github.p03w.machete" version "1.1.4" // automatic jar compressing on build
id "com.modrinth.minotaur" version "2.+" // modrinth publishing
id "com.matthewprenger.cursegradle" version "1.+" // curseforge publishing
id "maven-publish" // maven publishing
}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
String runNumber = System.getenv("GITHUB_RUN_NUMBER")
String build = runNumber != null ? "build.$runNumber" : "local"
version = "$mod_version-$build+mc$minecraft_version"
group = project.maven_group
archivesBaseName = "create-fabric"
repositories {
maven { url = "https://maven.quiltmc.org/repository/release" } // QM
maven { url = "https://maven.parchmentmc.org" } // Parchment
maven { url = "https://maven.fabricmc.net/" } // FAPI, Loader
maven { url = "https://mvn.devos.one/snapshots/" } // Registrate, Porting Lib, Forge Tags, Milk Lib
maven { url = "https://jitpack.io/" } // for Porting Lib: Mixin Extras, Fabric ASM
maven { url = "https://raw.githubusercontent.com/Fuzss/modresources/main/maven/" } // Forge Config API Port
maven { url = "https://maven.tterrag.com/" } // Flywheel
maven { url = "https://maven.shedaniel.me/" } // REI and deps
maven { url = "https://api.modrinth.com/maven" } // LazyDFU, Sodium, Sandwichable
maven { url = "https://maven.terraformersmc.com/" } // Mod Menu, Trinkets
maven { url = "https://modmaven.dev" } // Botania
maven { // Reach Entity Attributes
url = "https://maven.jamieswhiteshirt.com/libs-release"
content { includeGroup("com.jamieswhiteshirt") }
}
maven { url = "https://maven.ladysnake.org/releases" } // CCA, for Trinkets
}
configurations.configureEach {
resolutionStrategy {
force("net.fabricmc:fabric-loader:$loader_version")
}
}
dependencies {
setup(dependencies)
devEnv(dependencies)
compat(dependencies)
dependencies(dependencies)
}
// actual dependencies for Create
def dependencies(DependencyHandler deps) {
deps.modImplementation("net.fabricmc.fabric-api:fabric-api:$fabric_version")
deps.modApi(deps.include("io.github.fabricators_of_create:Porting-Lib:$port_lib_version+$minecraft_version"))
deps.modApi(deps.include("com.tterrag.registrate_fabric:Registrate:$registrate_version")) {
exclude(group: "io.github.fabricators_of_create") // avoid duplicate Porting Lib
}
deps.modApi(deps.include("me.alphamode:ForgeTags:$forge_tags_version"))
deps.modApi(deps.include("com.electronwill.night-config:core:$night_config_version"))
deps.modApi(deps.include("com.electronwill.night-config:toml:$night_config_version"))
deps.modApi(deps.include("net.minecraftforge:forgeconfigapiport-fabric:$forge_config_api_port_version"))
deps.modApi(deps.include("com.jozufozu.flywheel:flywheel-fabric-$flywheel_minecraft_version:$flywheel_version"))
deps.modApi(deps.include("com.jamieswhiteshirt:reach-entity-attributes:$reach_entity_attributes_version"))
deps.modApi(deps.include("io.github.tropheusj:milk-lib:$milk_lib_version"))
deps.api(deps.include("com.google.code.findbugs:jsr305:$jsr305_version"))
}
// initial project setup
def setup(DependencyHandler deps) {
deps.minecraft("com.mojang:minecraft:$minecraft_version")
deps.mappings(loom.layered {
it.mappings("org.quiltmc:quilt-mappings:$minecraft_version+build.$qm_version:intermediary-v2")
it.parchment("org.parchmentmc.data:parchment-$minecraft_version:$parchment_version@zip")
it.officialMojangMappings { nameSyntheticMembers = false }
})
deps.modImplementation("net.fabricmc:fabric-loader:$loader_version")
}
// setup mods that enhance development
def devEnv(DependencyHandler deps) {
deps.modLocalRuntime("maven.modrinth:lazydfu:$lazy_dfu_version")
deps.modLocalRuntime("com.terraformersmc:modmenu:$modmenu_version")
deps.modLocalRuntime("dev.emi:trinkets:$trinkets_version")
if (cc_enabled) {
deps.modLocalRuntime("maven.modrinth:cc-restitched:$cc_version")
deps.modLocalRuntime("maven.modrinth:cloth-config:$cloth_version")
}
}
// setup mods that are available for compatibility reasons
def compat(DependencyHandler deps) {
deps.modCompileOnly("maven.modrinth:cc-restitched:$cc_version")
deps.modCompileOnly("vazkii.botania:Botania:$botania_version") { transitive = false }
deps.modCompileOnly("com.terraformersmc:modmenu:$modmenu_version")
deps.modCompileOnly("maven.modrinth:sandwichable:$sandwichable_version")
deps.modCompileOnly("maven.modrinth:sodium:$sodium_version")
deps.modCompileOnly("dev.emi:trinkets:$trinkets_version") { exclude(group: "com.terraformersmc") }
deps.modCompileOnly("dev.onyxstudios.cardinal-components-api:cardinal-components-base:$cca_version")
deps.modCompileOnly("dev.onyxstudios.cardinal-components-api:cardinal-components-entity:$cca_version")
recipeViewers(deps)
}
// setup the three recipe viewer mods
def recipeViewers(DependencyHandler deps) {
// EMI
deps.modCompileOnly("dev.emi:emi:$emi_version") { transitive = false }
// JEI
deps.modCompileOnly("mezz.jei:jei-$minecraft_version-fabric:$jei_version") { transitive = false }
// REI
deps.modCompileOnly("me.shedaniel:RoughlyEnoughItems-api-fabric:$rei_version")
deps.modCompileOnly("me.shedaniel:RoughlyEnoughItems-default-plugin-fabric:$rei_version")
switch (recipe_viewer.toLowerCase(Locale.ROOT)) {
case "jei": deps.modLocalRuntime("mezz.jei:jei-$minecraft_version-fabric:$jei_version"); break
case "rei": deps.modLocalRuntime("me.shedaniel:RoughlyEnoughItems-fabric:$rei_version"); break
case "emi": deps.modLocalRuntime("dev.emi:emi:$emi_version"); break
case "disabled": break
default: println("Unknown recipe viewer specified: $recipe_viewer. Must be JEI, REI, EMI, or disabled.")
}
}
machete {
enabled = Boolean.getBoolean("PUBLISHING") // only optimize published releases
}
tasks.register("buildOrPublish") {
group = "build"
String mavenUser = System.getenv("MAVEN_USER")
if (mavenUser != null && !mavenUser.isEmpty()) {
dependsOn(tasks.named("publish"))
println("prepared for publish")
} else {
dependsOn(tasks.named("build"))
println("prepared for build")
}
}
sourceSets {
main {
resources {
srcDir("src/generated/resources")
exclude(".cache")
}
}
}
loom {
accessWidenerPath = file("src/main/resources/create.accesswidener")
runs {
configureEach {
vmArg "-XX:+AllowEnhancedClassRedefinition"
vmArg "-XX:+IgnoreUnrecognizedVMOptions"
}
datagen {
client()
name "Data Generation"
vmArg "-Dfabric-api.datagen"
vmArg "-Dfabric-api.datagen.output-dir=${file("src/generated/resources")}"
vmArg "-Dfabric-api.datagen.modid=create"
vmArg "-Dporting_lib.datagen.existing_resources=${file("src/main/resources")}"
}
server {
runDir "run/server"
}
gametestServer {
server()
name "Headlesss GameTests"
vmArg "-Dfabric-api.gametest"
vmArg "-Dfabric-api.gametest.report-file=${project.buildDir}/junit.xml"
runDir "run/gametest"
}
}
}
processResources {
exclude("**/*.bbmodel", "**/*.lnk")
Map<String, Object> properties = [
"version": version,
"minecraft_version": minecraft_version,
"loader_version": loader_version,
"fabric_version": fabric_version,
"port_lib_version": port_lib_version,
"forge_tags_version": forge_tags_version,
"forge_config_version": forge_config_api_port_version,
"milk_lib_version": milk_lib_version,
"reach_entity_attributes_version": reach_entity_attributes_version
]
properties.forEach((k, v) -> inputs.property(k, v))
filesMatching("fabric.mod.json") {
expand properties
}
filesMatching("create.mixins.json") {
expand "archivesBaseName": archivesBaseName
}
duplicatesStrategy = DuplicatesStrategy.WARN
}
tasks.withType(JavaCompile).configureEach {
it.options.release = Integer.parseInt(sourceCompatibility)
}
java {
withSourcesJar()
}
jar {
from("LICENSE") {
rename { "${it}_$archivesBaseName" }
}
}
// see gradle/publishing.gradle for publishing
apply from: "gradle/publishing/publishing.gradle"
apply from: "gradle/compat/compat.gradle"