in atomos.utils/atomos.utils.substrate.impl/src/main/java/org/apache/felix/atomos/utils/substrate/impl/NativeImageCliUtil.java [54:97]
public static Path execute(final Path nativeImageExec, final Path executionDir,
final NativeImageArguments arguments) throws Exception
{
final Optional<Path> exec = findNativeImageExecutable(nativeImageExec);
if (exec.isEmpty())
{
throw new Exception("Missing native image executable. Set '" + GRAALVM_HOME
+ "' with the path as an environment variable");
}
String resultFileName = arguments.name();
if (isWindows()) {
resultFileName += ".exe";
}
final Path resultFile = executionDir.resolve(resultFileName);
final List<String> commands = new ArrayList<>();
commands.add(exec.get().toAbsolutePath().toString());
commands.addAll(arguments.arguments());
final ProcessBuilder pB = new ProcessBuilder(commands);
pB.inheritIO();
pB.directory(executionDir.toFile());
final String cmds = pB.command().stream().collect(Collectors.joining(" "));
System.out.println(cmds);
final Process process = pB.start();
final int exitValue = process.waitFor();
if (exitValue != 0)
{
throw new Exception("native-image returns exit value: " + exitValue);
}
if (Files.exists(resultFile))
{
return resultFile;
}
throw new Exception(
"native-image could not be found: " + resultFile.toAbsolutePath().toString());
}