Skip to content

Commit

Permalink
re-added json minifier
Browse files Browse the repository at this point in the history
  • Loading branch information
mickelus committed Apr 13, 2020
1 parent 2a9428c commit 81d1b4c
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,29 @@ publishing {
url "file:///${project.projectDir}/mcmodsrepo"
}
}
}
}

processResources {
doLast {

def jsonMinifyStart = System.currentTimeMillis()
def jsonMinified = 0
def jsonBytesSaved = 0

fileTree(dir: outputs.files.asPath, include: '**/*.json').each {

File file = it
jsonMinified++
def oldLength = file.length()
try {
file.text = JsonOutput.toJson(new JsonSlurper().parse(file))
} catch(JsonException e) {
throw new JsonException("Failed to parse json in " + file.path)
}
file.text = JsonOutput.toJson(new JsonSlurper().parse(file))
jsonBytesSaved += oldLength - file.length()
}

println('Minified ' + jsonMinified + ' json files. Saved ' + jsonBytesSaved + ' bytes. Took ' + (System.currentTimeMillis() - jsonMinifyStart) + 'ms.')
}
}

0 comments on commit 81d1b4c

Please sign in to comment.