--- /dev/null
+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))
+ }
+}
-import groovy.json.JsonOutput
-import groovy.json.JsonSlurper
import org.apache.tools.ant.filters.ReplaceTokens
+import org.sonar.build.LicenseReader
plugins {
id "com.github.hierynomus.license-report"
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)
- }
+ filter(LicenseReader)
}
}
}
}
// Create the empty dir (plugins) required by elasticsearch
into("${archiveDir}/elasticsearch/") {
- from "$buildDir/elasticsearch"
+ // Create the empty dir required by elasticsearch
+ from {
+ new File(buildDir, 'elasticsearch/plugins').mkdirs()
+ "$buildDir/elasticsearch"
+ }
}
into("${archiveDir}/lib/extensions/") {
from configurations.bundledPlugin
from configurations.shutdowner
}
}
-// Create the empty dir required by elasticsearch
-zip.doFirst {
- new File(buildDir, 'elasticsearch/plugins').mkdirs()
-}
+
// Check the size of the archive
zip.doLast {
def minLength = 320000000