Skip to content

Commit 0f2a8c6

Browse files
committed
Minify .json files in built .jar files
1 parent 4bb6640 commit 0f2a8c6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

build.gradle

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ dependencies {
154154
implementation "com.eclipsesource.minimal-json:minimal-json:${project.minimalJsonVersion}"
155155
}
156156

157+
import groovy.json.JsonOutput
158+
import groovy.json.JsonSlurper
159+
157160
processResources {
158161
inputs.property 'version', project.version // Redo this task when version value changes.
159162
inputs.property 'versionWithMetadata', versionWithMetadata
@@ -162,6 +165,15 @@ processResources {
162165
// replace build variables
163166
expand 'version': versionWithMetadata, 'tag': gitTag
164167
}
168+
169+
// Minify .json files in built .jar
170+
doLast {
171+
fileTree(dir: outputs.files.asPath, includes: [
172+
"**/*.json"
173+
]).each { final File file ->
174+
file.text = JsonOutput.toJson(new JsonSlurper().parse(file))
175+
}
176+
}
165177
}
166178

167179
// Ensures that the encoding of source files is set to UTF-8, see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html

0 commit comments

Comments
 (0)