Skip to content

Commit

Permalink
Generate mandrel.release file with mandrel version as property
Browse files Browse the repository at this point in the history
  • Loading branch information
zakkak committed Aug 7, 2023
1 parent 0da5d0f commit 8724123
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions build.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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"));
Expand All @@ -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());
Expand Down

0 comments on commit 8724123

Please sign in to comment.