aboutsummaryrefslogtreecommitdiffstats
path: root/buildSrc
diff options
context:
space:
mode:
authorOlaf Śnieżek <osniezek@gradle.com>2022-11-17 12:53:52 +0100
committersonartech <sonartech@sonarsource.com>2023-02-14 20:02:48 +0000
commite88ee19ed1c747f18901f4806ac78c8722780998 (patch)
treef2d4470d1f5f67d677cd3255050a13f721742461 /buildSrc
parent92b1f5513e74831427c8ab2d60ec8f5e173fc8fe (diff)
downloadsonarqube-e88ee19ed1c747f18901f4806ac78c8722780998.tar.gz
sonarqube-e88ee19ed1c747f18901f4806ac78c8722780998.zip
Optimize gradle build to use the incremental build feature
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))
+ }
+}