aboutsummaryrefslogtreecommitdiffstats
path: root/buildSrc
diff options
context:
space:
mode:
Diffstat (limited to 'buildSrc')
-rw-r--r--buildSrc/src/main/groovy/org.sonar.build/LicenseReader.groovy29
1 files changed, 29 insertions, 0 deletions
diff --git a/buildSrc/src/main/groovy/org.sonar.build/LicenseReader.groovy b/buildSrc/src/main/groovy/org.sonar.build/LicenseReader.groovy
new file mode 100644
index 00000000000..cb611e90497
--- /dev/null
+++ b/buildSrc/src/main/groovy/org.sonar.build/LicenseReader.groovy
@@ -0,0 +1,29 @@
+package org.sonar.build
+
+import groovy.json.JsonOutput
+import groovy.json.JsonSlurper
+
+class LicenseReader extends FilterReader {
+
+ LicenseReader(Reader fileReader) {
+ super(build(fileReader))
+ }
+
+ private static Reader build(Reader fileReader) {
+ def json = new JsonSlurper().parse(fileReader)
+
+ json.dependencies.each { dependency ->
+ if (dependency.licenses.size() > 1) {
+ def idx = dependency.licenses.findIndexOf { it.name == "Elastic License 2.0" }
+ if (idx >= 0) {
+ dependency.licenses = [dependency.licenses[idx]]
+ }
+ }
+ }
+
+ json.dependencies.sort { it.name }
+
+ def jsonText = JsonOutput.toJson(json)
+ return new StringReader(JsonOutput.prettyPrint(jsonText))
+ }
+}