-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
255 lines (216 loc) · 7.06 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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
buildscript {
repositories {
mavenCentral()
maven {
name = "jitpack"
url = "https://jitpack.io"
content {
includeGroup "com.github.Juuxel"
}
}
}
dependencies {
classpath "com.github.Juuxel:fc0-tools:1.1.4"
}
}
import juuxel.fc0.tools.bytecodetweaker.BytecodeTweaker
import net.fabricmc.stitch.commands.CommandFixNesting
import java.nio.file.Files
plugins {
id 'java'
id 'application'
id 'org.jetbrains.gradle.plugin.idea-ext' version '0.7'
}
mainClassName = 'tk.valoeghese.fc0.client.Main'
sourceCompatibility = JavaVersion.VERSION_1_8
group 'tk.valoeghese'
version '0.2.3'
repositories {
mavenCentral()
maven {
name = "FabricMC"
url = "https://maven.fabricmc.net"
}
}
configurations {
enigma {
extendsFrom runtimeClasspath
}
game {
extendsFrom runtimeClasspath
}
}
def gameJar = project.file("2fc0f18-${version}.jar")
def mappingsDir = project.file('mappings')
def intermediaryJar = project.file("build/intermediary-${gameJar.name}")
def runDirectory = project.file('run')
if (!gameJar.exists()) {
def url = new URL("https://github.com/valoeghese/2fc-early-releases/raw/master/2fc0f18-${version}.jar")
try {
println "Downloading 2fc0f18 v$version"
def stream = url.openStream()
try {
Files.copy(stream, gameJar.toPath())
} finally {
stream.close()
}
} catch (IOException e) {
System.err.println "Could not download 2fc0f18 v$version"
e.printStackTrace()
}
}
if (!runDirectory.exists()) {
runDirectory.mkdir()
}
dependencies {
game files(gameJar)
// lwjgl
implementation "org.lwjgl:lwjgl:${project.lwjgl_version}"
implementation "org.lwjgl:lwjgl-assimp:${project.lwjgl_version}"
//implementation "org.lwjgl:lwjgl-jawt:${project.lwjgl_version}"
implementation "org.lwjgl:lwjgl-opengl:${project.lwjgl_version}"
implementation "org.lwjgl:lwjgl-glfw:${project.lwjgl_version}"
implementation "org.lwjgl:lwjgl-openal:${project.lwjgl_version}"
implementation "org.lwjgl:lwjgl-stb:${project.lwjgl_version}"
// joml
implementation "org.joml:joml:${project.joml_version}"
// fastutil
implementation "it.unimi.dsi:fastutil:${project.fastutil_version}"
// lwjgl natives
runtimeOnly "org.lwjgl:lwjgl:${project.lwjgl_version}:${project.natives}"
runtimeOnly "org.lwjgl:lwjgl-assimp:${project.lwjgl_version}:${project.natives}"
runtimeOnly "org.lwjgl:lwjgl-opengl:${project.lwjgl_version}:${project.natives}"
runtimeOnly "org.lwjgl:lwjgl-glfw:${project.lwjgl_version}:${project.natives}"
runtimeOnly "org.lwjgl:lwjgl-openal:${project.lwjgl_version}:${project.natives}"
runtimeOnly "org.lwjgl:lwjgl-stb:${project.lwjgl_version}:${project.natives}"
compileOnly "com.google.code.findbugs:jsr305:3.0.2"
testCompile group: 'junit', name: 'junit', version: '4.12'
enigma "cuchaz:enigma:$project.enigma_version"
}
task intermediary(type: RemapJarTask) {
inputJar = gameJar
mappings = file("intermediary/${version}.tiny")
libraries = configurations.runtimeClasspath
outputJar = intermediaryJar
from = "official"
to = "intermediary"
doLast {
CommandFixNesting.run(outputJar)
def tweakFile = file("bytecode_tweaks/${version}.json")
if (tweakFile.exists()) {
new BytecodeTweaker(tweakFile).run(outputJar.toPath())
}
}
}
task deobf(type: DeobfuscateTask, dependsOn: intermediary) {
group = "fc0"
mappings = mappingsDir
intermediaryMappings = file("intermediary/${version}.tiny")
inputJar = intermediaryJar
outputJar = file("build/deobf-${gameJar.name}")
libraries = configurations.runtimeClasspath
outputMappings = file("build/mappings.tiny")
}
task decompile(type: DecompileTask, dependsOn: deobf) {
group = "fc0"
input = deobf.outputJar
output = file('src/main/java')
cleanOutput = file('src/raw/java')
libraries = configurations.runtimeClasspath
doLast {
println "Decompiled! Note that you should only modify src/main and leave src/clean and src/raw untouched!"
}
}
task extractResources(type: ExtractResourcesTask) {
group = "fc0"
input = gameJar
output = file('src/main/resources')
}
task applyPatches(type: ApplyPatchesTask) {
group = "fc0"
patches = file('patches')
// raw -> clean
cleanSources = decompile.cleanOutput
intermediateSources = file('src/clean/java')
userSources = decompile.output
}
task generateModPatches(type: GeneratePatchesTask) {
group = "fc0"
cleanSources = applyPatches.intermediateSources
revisedSources = applyPatches.userSources
patchOutput = file('src/main/diff')
}
task generateFullPatches(type: GeneratePatchesTask) {
group = "fc0"
cleanSources = applyPatches.cleanSources
revisedSources = applyPatches.userSources
patchOutput = file('build/full-diff')
}
task setup(dependsOn: [decompile, extractResources]) {
group = "fc0"
}
task obfuscate(type: RemapJarTask, dependsOn: [deobf, jar]) {
group = "fc0"
inputJar = jar.outputs.files.singleFile
mappings = deobf.outputMappings
libraries = configurations.runtimeClasspath
outputJar = file("build/libs/${archivesBaseName}-${version}-obfuscated.jar")
from = "named"
to = "official"
}
task modJar(type: DiffJarTask, dependsOn: [deobf, generateModPatches, obfuscate]) {
group = "fc0"
originJar = gameJar
patches = files(generateModPatches.patchOutput)
modifiedJar = obfuscate.outputJar
mappings = deobf.outputMappings
output = file("build/libs/${archivesBaseName}-${version}-mod.jar")
}
task fullPatchZip(type: Zip, dependsOn: generateFullPatches) {
group = "fc0"
from fileTree(generateFullPatches.patchOutput)
archiveName "${archivesBaseName}-${project.version}-patches.zip"
destinationDir file('build/libs')
}
task runUnmoddedGame(type: JavaExec) {
group = "fc0"
classpath = configurations.game
main = "tk.valoeghese.fc0.client.Main"
workingDir = runDirectory
}
run {
workingDir = runDirectory
}
build.dependsOn modJar, fullPatchZip
task enigma(dependsOn: intermediary) {
group = "fc0"
doLast {
ant.setLifecycleLogLevel "WARN"
ant.java(
classname: 'cuchaz.enigma.Main',
classpath: configurations.enigma.asPath,
fork: true,
spawn: true
) {
jvmarg(value: "-Xmx2048m")
arg(value: '-jar')
arg(value: intermediaryJar.getAbsolutePath())
arg(value: '-mappings')
arg(value: mappingsDir.getAbsolutePath())
}
}
}
idea {
project.settings {
delegateActions {
delegateBuildRunToGradle = false
}
runConfigurations {
"Run"(org.jetbrains.gradle.ext.Application) {
mainClass = application.mainClassName
workingDirectory = runDirectory.absolutePath
moduleName = module.name + ".main"
}
}
}
}