Skip to content

Commit 4b3dcdc

Browse files
committed
build(gradle): fix build file
1 parent fad135b commit 4b3dcdc

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

build.gradle

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,27 @@ jar {
253253
from { ["CREDITS.md", "LICENSE.txt", "3RD_PARTY_LICENSE.txt"] } //copy files from the repository root into the jar
254254
}
255255

256+
private void minifyJsons(String fdir) {
257+
for (final def taskName in getGradle().getStartParameter().getTaskNames()) {
258+
if (taskName.toLowerCase().contains("rundata")) {
259+
return //skip minimization of jsons during any RunData tasks because they will be (re-)generated during this task and should only be minimized for builds anyways
260+
}
261+
}
262+
263+
print "minmizing jsons..."
264+
long startTime = System.nanoTime()
265+
for (File file in fileTree(dir: fdir, include: "**/*.json")) {
266+
try {
267+
file.text = JsonOutput.toJson(new JsonSlurper().parse(file))
268+
}
269+
catch (Exception e) {
270+
throw new Exception("Failed to minimize " + file, e)
271+
}
272+
}
273+
long ms = TimeUnit.MILLISECONDS.convert(System.nanoTime() - startTime, TimeUnit.NANOSECONDS)
274+
printf "%7s sec, %s ms \n", (int) (ms / 1000), ms % 1000
275+
}
276+
256277
var generateModMetadata = tasks.register("generateModMetadata", ProcessResources) {
257278
var replaceProperties = [
258279
minecraft_version : minecraft_version, minecraft_version_range: minecraft_version_range,
@@ -287,27 +308,6 @@ var generateModMetadata = tasks.register("generateModMetadata", ProcessResources
287308
}
288309
}
289310

290-
private void minifyJsons(String fdir) {
291-
for (final def taskName in getGradle().getStartParameter().getTaskNames()) {
292-
if (taskName.toLowerCase().contains("rundata")) {
293-
return //skip minimization of jsons during any RunData tasks because they will be (re-)generated during this task and should only be minimized for builds anyways
294-
}
295-
}
296-
297-
print "minmizing jsons..."
298-
long startTime = System.nanoTime()
299-
for (File file in fileTree(dir: fdir, include: "**/*.json")) {
300-
try {
301-
file.text = JsonOutput.toJson(new JsonSlurper().parse(file))
302-
}
303-
catch (Exception e) {
304-
throw new Exception("Failed to minimize " + file, e)
305-
}
306-
}
307-
long ms = TimeUnit.MILLISECONDS.convert(System.nanoTime() - startTime, TimeUnit.NANOSECONDS)
308-
printf "%7s sec, %s ms \n", (int) (ms / 1000), ms % 1000
309-
}
310-
311311
// Include the output of "generateModMetadata" as an input directory for the build
312312
// this works with both building through Gradle and the IDE.
313313
sourceSets.main.resources.srcDir generateModMetadata

0 commit comments

Comments
 (0)