From 8724123c53e710fa253885778a3676d95d413064 Mon Sep 17 00:00:00 2001 From: Foivos Zakkak Date: Tue, 25 Jul 2023 14:14:21 +0300 Subject: [PATCH] Generate `mandrel.release` file with mandrel version as property Closes https://github.com/graalvm/mandrel-packaging/issues/353 --- build.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/build.java b/build.java index 030ce0df..fc4a9c9c 100644 --- a/build.java +++ b/build.java @@ -44,6 +44,7 @@ public class build public static final boolean IS_WINDOWS = System.getProperty("os.name").matches(".*[Ww]indows.*"); public static final boolean IS_MAC = System.getProperty("os.name").matches(".*[Mm]ac.*"); public static final String JDK_VERSION = "jdk" + Runtime.version().feature(); + private static final String MANDREL_RELEASE_FILE = "mandrel.release"; public static void main(String... args) throws IOException { @@ -235,6 +236,8 @@ public static void main(String... args) throws IOException logger.debugf("Build native agents..."); buildAgents(nativeImage, fs, os); } + + generateMandrelReleaseFile(mandrelVersionUntilSpace, mandrelHome); } logger.info("Congratulations you successfully built Mandrel " + mandrelVersionUntilSpace + " based on Java " + System.getProperty("java.runtime.version")); @@ -248,6 +251,20 @@ public static void main(String... args) throws IOException } } + private static void generateMandrelReleaseFile(String mandrelVersion, Path mandrelHome) + { + final String content = String.format("GRAALVM_VERSION=%s%nMANDREL_VERSION=%s%n", mandrelVersion, mandrelVersion); + final Path mandrelReleaseFile = mandrelHome.resolve(Path.of(MANDREL_RELEASE_FILE)); + try + { + Files.writeString(mandrelReleaseFile, content, StandardCharsets.UTF_8); + } + catch (IOException e) + { + throw new RuntimeException("Failed to write " + MANDREL_RELEASE_FILE + " file", e); + } + } + private static void buildAgents(Path nativeImage, FileSystem fs, OperatingSystem os) { final Tasks.Exec agent = Tasks.Exec.of(Arrays.asList(nativeImage.toString(), "--macro:native-image-agent-library"), fs.workingDir());