From 5157f5d2f6bd8b0782699d63cbae005ea4062327 Mon Sep 17 00:00:00 2001 From: Matthew de Detrich Date: Thu, 25 Jan 2024 00:00:59 +1100 Subject: [PATCH] Close gradle build stream in finally block --- gradle-plugin/build.gradle | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/gradle-plugin/build.gradle b/gradle-plugin/build.gradle index 628af1b5..7156ed5e 100644 --- a/gradle-plugin/build.gradle +++ b/gradle-plugin/build.gradle @@ -19,13 +19,16 @@ group = "org.apache.pekko" def getVersionFromParentSbtBuild() { ByteArrayOutputStream os = new ByteArrayOutputStream() - String parentDir = project.rootDir.getParentFile().getPath() - exec { - workingDir parentDir - commandLine 'sbt', '--no-colors', '--error', 'set aggregate := false; print version' - standardOutput os + try { + String parentDir = project.rootDir.getParentFile().getPath() + exec { + workingDir parentDir + commandLine 'sbt', '--no-colors', '--error', 'set aggregate := false; print version' + standardOutput os + } + } finally { + os.close() } - os.close() String finalVersion = os.toString().trim() project.logger.info("Derived gradle version from parent sbt build: $finalVersion") return finalVersion