From 5eb6692b0f703d8fa6a4bef3981fe59523e559e4 Mon Sep 17 00:00:00 2001 From: Mark Vieira Date: Tue, 16 Jun 2020 15:07:28 -0700 Subject: [PATCH] Add OpenJDK distribution to external dependency report (#58187) --- .../elasticsearch/gradle/ConcatFilesTask.java | 17 +++++++++++++++++ distribution/build.gradle | 6 ++++++ 2 files changed, 23 insertions(+) diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/ConcatFilesTask.java b/buildSrc/src/main/java/org/elasticsearch/gradle/ConcatFilesTask.java index ac5f030e7e8..bc711ac2b53 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/ConcatFilesTask.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/ConcatFilesTask.java @@ -23,7 +23,9 @@ import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.StandardOpenOption; +import java.util.ArrayList; import java.util.LinkedHashSet; +import java.util.List; import org.gradle.api.DefaultTask; import org.gradle.api.file.FileTree; @@ -50,6 +52,8 @@ public class ConcatFilesTask extends DefaultTask { private File target; + private List additionalLines = new ArrayList<>(); + public void setFiles(FileTree files) { this.files = files; } @@ -78,6 +82,15 @@ public class ConcatFilesTask extends DefaultTask { return target; } + @Input + public List getAdditionalLines() { + return additionalLines; + } + + public void setAdditionalLines(List additionalLines) { + this.additionalLines = additionalLines; + } + @TaskAction public void concatFiles() throws IOException { if (getHeaderLine() != null) { @@ -90,6 +103,10 @@ public class ConcatFilesTask extends DefaultTask { uniqueLines.addAll(Files.readAllLines(f.toPath(), StandardCharsets.UTF_8)); } Files.write(getTarget().toPath(), uniqueLines, StandardCharsets.UTF_8, StandardOpenOption.APPEND); + + for (String additionalLine : additionalLines) { + Files.write(getTarget().toPath(), (additionalLine + '\n').getBytes(StandardCharsets.UTF_8), StandardOpenOption.APPEND); + } } } diff --git a/distribution/build.gradle b/distribution/build.gradle index 9f621cabc04..98d2aca505e 100644 --- a/distribution/build.gradle +++ b/distribution/build.gradle @@ -41,6 +41,12 @@ tasks.register("generateDependenciesReport", ConcatFilesTask) { files = fileTree(dir: project.rootDir, include: '**/dependencies.csv') headerLine = "name,version,url,license,sourceURL" target = new File(System.getProperty('csv') ?: "${project.buildDir}/reports/dependencies/es-dependencies.csv") + + // explicitly add our dependency on the JDK + String jdkVersion = VersionProperties.versions.get('bundled_jdk') + String jdkMajorVersion = jdkVersion.split('[+.]')[0] + String sourceUrl = "http://hg.openjdk.java.net/jdk-updates/jdk${jdkMajorVersion}u/archive/jdk-${jdkVersion}.tar.gz" + additionalLines << "OpenJDK,${jdkVersion},https://openjdk.java.net/,GPL-2.0-with-classpath-exception,${sourceUrl}".toString() } /*****************************************************************************