Skip to content
This repository was archived by the owner on Jul 16, 2023. It is now read-only.

Commit 413f0e7

Browse files
committed
Update gradle to use FG5 and a sane version of gradle itself
[no-ci]
1 parent 1aa85ad commit 413f0e7

File tree

8 files changed

+555
-226
lines changed

8 files changed

+555
-226
lines changed

build.gradle

Lines changed: 298 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,298 @@
1+
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
2+
import org.gradle.api.tasks.testing.logging.TestLogEvent
3+
4+
buildscript {
5+
repositories {
6+
mavenCentral()
7+
mavenLocal()
8+
if (project.use_mixins.toBoolean()) {
9+
maven {
10+
name "MixinGradle Maven"
11+
url "https://repo.spongepowered.org/repository/maven-public"
12+
}
13+
}
14+
}
15+
dependencies {
16+
if (project.use_mixins.toBoolean()) {
17+
classpath "org.spongepowered:mixingradle:${mixingradle_version}"
18+
}
19+
}
20+
}
21+
22+
plugins {
23+
id "net.minecraftforge.gradle" version "${forge_gradle_version}"
24+
id "wtf.gofancy.fancygradle" version "${fancy_gradle_version}"
25+
}
26+
27+
version = project.version
28+
group = project.maven_group
29+
archivesBaseName = "${project.archives_base_name}-${project.minecraft_version}"
30+
31+
java.toolchain.languageVersion = JavaLanguageVersion.of(8)
32+
33+
if (project.use_intellij_idea.toBoolean()) {
34+
apply {
35+
plugin "java"
36+
plugin "idea"
37+
}
38+
39+
idea {
40+
module {
41+
downloadJavadoc = true
42+
downloadSources = true
43+
}
44+
}
45+
}
46+
47+
minecraft {
48+
mappings channel: "${mcp_mappings_channel}", version: "${mcp_mappings_version}"
49+
50+
/* AT stuff
51+
if (project.has_access_transformer.toBoolean()) {
52+
accessTransformer = file("src/main/resources/META-INF/htmltech_at.cfg")
53+
}*/
54+
55+
runs {
56+
client {
57+
//noinspection GroovyAssignabilityCheck
58+
workingDirectory project.file("run")
59+
if (project.use_coremod.toBoolean()) {
60+
jvmArg "-Dfml.coreMods.load=" + coremod_plugin_class_name
61+
}
62+
if (project.use_mixins.toBoolean()) {
63+
jvmArg "-Dmixin.hotSwap=true"
64+
jvmArg "-Dmixin.checks.interfaces=true"
65+
jvmArg "-Dmixin.debug=true"
66+
}
67+
property "forge.logging.markers", "REGISTRIES"
68+
property "forge.logging.console.level", "debug"
69+
environment "MC_VERSION", minecraft_version.toString()
70+
}
71+
72+
server {
73+
//noinspection GroovyAssignabilityCheck
74+
workingDirectory project.file("run")
75+
if (project.use_coremod.toBoolean()) {
76+
jvmArg "-Dfml.coreMods.load=" + coremod_plugin_class_name
77+
}
78+
if (project.use_mixins.toBoolean()) {
79+
jvmArg "-Dmixin.hotSwap=true"
80+
jvmArg "-Dmixin.checks.interfaces=true"
81+
}
82+
property "forge.logging.markers", "REGISTRIES"
83+
property "forge.logging.console.level", "debug"
84+
environment "MC_VERSION", minecraft_version.toString()
85+
}
86+
}
87+
}
88+
89+
repositories {
90+
maven {
91+
name "Cleanroom Maven"
92+
url "https://maven.cleanroommc.com"
93+
}
94+
maven { // JEI
95+
name "Progwml6 Maven"
96+
url "https://dvs1.progwml6.com/files/maven/"
97+
}
98+
maven { // CraftTweaker and JEI Backup
99+
name "BlameJared Maven"
100+
url "https://maven.blamejared.com"
101+
}
102+
if (project.use_mixins.toBoolean()) {
103+
maven {
104+
name "Sponge Maven"
105+
url "https://repo.spongepowered.org/maven"
106+
}
107+
}
108+
maven {
109+
name "Curse Maven"
110+
url "https://www.cursemaven.com"
111+
content {
112+
includeGroup "curse.maven"
113+
}
114+
}
115+
maven {
116+
name = "maverinth"
117+
url = "https://api.modrinth.com/maven"
118+
content {
119+
includeGroup "maven.modrinth"
120+
}
121+
}
122+
}
123+
124+
dependencies {
125+
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
126+
127+
// Hard deps
128+
implementation fg.deobf("curse.maven:codechicken-lib-1-8-${ccl_pid}:${ccl_fid}")
129+
implementation fg.deobf("maven.modrinth:gregtech-ce-unofficial:${gregtech_version}")
130+
131+
// Soft deps
132+
implementation "mezz.jei:jei_1.12.2:${jei_version}"
133+
implementation "CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-${crt_version}"
134+
implementation fg.deobf("curse.maven:top-${top_pid}:${top_fid}")
135+
implementation fg.deobf("curse.maven:ctm-${ctm_pid}:${ctm_fid}")
136+
implementation fg.deobf("curse.maven:groovyscript-${grs_pid}:${grs_fid}")
137+
implementation fg.deobf("curse.maven:ae2-extended-life-${ae2_pid}:${ae2_fid}")
138+
139+
// fuck you rong
140+
if (project.use_mixins.toBoolean()) {
141+
compileOnly "zone.rong:mixinbooter:${mixinbooter_version}"
142+
runtimeOnly "zone.rong:mixinbooter:${mixinbooter_version}"
143+
144+
annotationProcessor "org.spongepowered:mixin:${mixin_annotations_version}:processor"
145+
} else {
146+
// GroovyScript dependency
147+
runtimeOnly "zone.rong:mixinbooter:${mixinbooter_version}"
148+
}
149+
}
150+
151+
fancyGradle {
152+
patches {
153+
resources
154+
coremods
155+
asm
156+
codeChickenLib
157+
}
158+
}
159+
160+
processJarTask jar
161+
162+
if (project.build_deobfJar.toBoolean()) {
163+
// Create deobf dev jars
164+
tasks.register("deobfJar", Jar) {
165+
archiveClassifier.set "deobf"
166+
from sourceSets.main.output
167+
}
168+
processJarTask deobfJar
169+
}
170+
171+
if (project.build_apiJar.toBoolean()) {
172+
// Create API library jar
173+
tasks.register("apiJar", Jar) {
174+
archiveClassifier.set "api"
175+
from(sourceSets.main.java) {
176+
include "net.htmlcsjs.htmltech/api/**"
177+
}
178+
179+
from(sourceSets.main.output) {
180+
include "net.htmlcsjs.htmltech/api/**"
181+
}
182+
}
183+
}
184+
185+
if (project.build_sourceJar.toBoolean()) {
186+
// Create source jar
187+
tasks.register("sourcesJar", Jar) {
188+
archiveClassifier.set "sources"
189+
from sourceSets.main.allJava
190+
}
191+
}
192+
193+
// Loading resources, works even on IDE client runs
194+
sourceSets {
195+
main {
196+
if (project.use_mixins.toBoolean()) {
197+
ext.refMap = "mixins." + archives_base_name + ".refmap.json"
198+
}
199+
200+
java {
201+
srcDirs = ["src/main/java", "src/api/java"]
202+
}
203+
204+
resources {
205+
srcDirs = ["src/main/resources"]
206+
}
207+
}
208+
209+
test {
210+
java {
211+
srcDirs = ["src/test/java"]
212+
}
213+
resources {
214+
srcDirs = ["src/test/resources"]
215+
}
216+
}
217+
218+
// at compile time, put resources in same directories as classes
219+
main.output.setResourcesDir(main.java.classesDirectory)
220+
}
221+
222+
artifacts {
223+
if (project.build_deobfJar.toBoolean()) {
224+
archives deobfJar
225+
}
226+
if (project.build_apiJar.toBoolean()) {
227+
archives apiJar
228+
}
229+
if (project.build_sourceJar.toBoolean()) {
230+
archives sourcesJar
231+
}
232+
}
233+
234+
// It is important to NOT re-obfuscate jars for the deobfuscated environment.
235+
// Therefore, we do not finalize the "jar" task with the "reobfJar" task.
236+
// The Forge FG5 example buildscript states otherwise, however it creates broken builds in deobfuscated environments.
237+
238+
processResources {
239+
// required to allow file expansion later
240+
duplicatesStrategy = DuplicatesStrategy.INCLUDE
241+
242+
// this will ensure that this task is redone when the versions change.
243+
inputs.property "version", version
244+
inputs.property "mcversion", minecraft_version
245+
246+
// replace stuff in mcmod.info, nothing else
247+
from(sourceSets.main.resources.srcDirs) {
248+
include "mcmod.info"
249+
250+
// replace version and mcversion
251+
expand(["version": version, "mcversion": minecraft_version])
252+
}
253+
254+
// copy everything else except mcmod.info
255+
from(sourceSets.main.resources.srcDirs) {
256+
exclude "mcmod.info"
257+
}
258+
}
259+
260+
test {
261+
testLogging {
262+
events TestLogEvent.STARTED, TestLogEvent.PASSED, TestLogEvent.FAILED
263+
exceptionFormat TestExceptionFormat.FULL
264+
showExceptions true
265+
showStackTraces true
266+
showCauses true
267+
showStandardStreams true
268+
}
269+
270+
useJUnitPlatform()
271+
}
272+
273+
/**
274+
* Applies required processing to jar tasks
275+
* @param task the task to process
276+
*/
277+
private void processJarTask(task) {
278+
task.configure {
279+
manifest {
280+
// noinspection GroovyAssignabilityCheck
281+
def attribute_map = [:]
282+
if (project.use_coremod.toBoolean()) {
283+
attribute_map["FMLCorePlugin"] = project.coremod_plugin_class_name
284+
if (project.include_mod.toBoolean()) {
285+
attribute_map["FMLCorePluginContainsFMLMod"] = true
286+
attribute_map["ForceLoadAsMod"] = project.gradle.startParameter.taskNames[0] == "build"
287+
}
288+
}
289+
if (project.use_mixins.toBoolean()) {
290+
attribute_map["TweakClass"] = "org.spongepowered.asm.launch.MixinTweaker"
291+
}
292+
if (project.has_access_transformer.toBoolean()) {
293+
attribute_map["FMLAT"] = "htmltech_at.cfg"
294+
}
295+
attributes(attribute_map)
296+
}
297+
}
298+
}

0 commit comments

Comments
 (0)