From 05dc88ba8178da90cdadf1e6cc06a21645910585 Mon Sep 17 00:00:00 2001 From: Zipeng WU Date: Mon, 25 Oct 2021 13:33:30 +0200 Subject: [PATCH] SONAR-15485 Handle Elastic license and prettify json --- sonar-application/build.gradle | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/sonar-application/build.gradle b/sonar-application/build.gradle index 2d84c89e269..700f057ac8f 100644 --- a/sonar-application/build.gradle +++ b/sonar-application/build.gradle @@ -1,3 +1,5 @@ +import groovy.json.JsonOutput +import groovy.json.JsonSlurper import org.apache.tools.ant.filters.ReplaceTokens plugins { @@ -82,6 +84,20 @@ task zip(type: Zip, dependsOn: [configurations.compile, tasks.downloadLicenses]) into("${archiveDir}/") { from(tasks.downloadLicenses.outputs) { include 'dependency-license.json' + eachFile { jsonFile -> + def json = new JsonSlurper().parse(jsonFile.file) + 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) + jsonFile.file.text = JsonOutput.prettyPrint(jsonText) + } } from file('src/main/assembly') exclude 'conf/sonar.properties' @@ -141,7 +157,7 @@ task zip(type: Zip, dependsOn: [configurations.compile, tasks.downloadLicenses]) 'sqversion': version ]) } - + into("${archiveDir}/elasticsearch/") { from file('src/main/assembly/elasticsearch-patch') include 'bin/elasticsearch' -- 2.39.5