From 1f6cd5c6e11cb05ed4c2c99fe352c657d7b13fdb Mon Sep 17 00:00:00 2001 From: Mark Vieira Date: Thu, 15 Aug 2019 18:39:11 -0700 Subject: [PATCH] Fix backwards compatibility with pre-Java11 build-tools users (#45633) --- buildSrc/build.gradle | 10 ++-------- buildSrc/reaper/build.gradle | 2 ++ .../java/org/elasticsearch/gradle/ReaperService.java | 8 +++++--- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 951b013e267..8bdfd215543 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -71,12 +71,6 @@ sourceSets { minimumRuntime { } } -allprojects { - apply plugin: 'java' - targetCompatibility = 11 - sourceCompatibility = 11 -} - configurations { reaper } @@ -160,8 +154,8 @@ if (project != rootProject) { apply plugin: 'nebula.maven-scm' allprojects { - targetCompatibility = 11 - sourceCompatibility = 11 + targetCompatibility = 10 + sourceCompatibility = 10 } // groovydoc succeeds, but has some weird internal exception... diff --git a/buildSrc/reaper/build.gradle b/buildSrc/reaper/build.gradle index 0d73bbbfcb4..81b6fd9ab6d 100644 --- a/buildSrc/reaper/build.gradle +++ b/buildSrc/reaper/build.gradle @@ -1,3 +1,5 @@ +apply plugin: 'java' + jar { archiveName = "${project.name}.jar" manifest { diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/ReaperService.java b/buildSrc/src/main/java/org/elasticsearch/gradle/ReaperService.java index 596b1ca12db..c52cee026ef 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/ReaperService.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/ReaperService.java @@ -24,6 +24,7 @@ import org.gradle.api.GradleException; import org.gradle.api.logging.Logger; import org.gradle.internal.jvm.Jvm; +import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -31,6 +32,7 @@ import java.io.UncheckedIOException; import java.net.URL; import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.Paths; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -68,8 +70,8 @@ public class ReaperService { public void registerCommand(String serviceId, String... command) { ensureReaperStarted(); - try { - Files.writeString(getCmdFile(serviceId), String.join(" ", command)); + try (FileWriter writer = new FileWriter(getCmdFile(serviceId).toFile())) { + writer.write(String.join(" ", command)); } catch (IOException e) { throw new UncheckedIOException(e); } @@ -143,7 +145,7 @@ public class ReaperService { if (matcher.matches()) { String path = matcher.group(1); - return Path.of( + return Paths.get( OS.conditional() .onWindows(() -> path.substring(1)) .onUnix(() -> path)