in src/main/java/org/apache/maven/plugins/jlink/AbstractJLinkToolchainExecutor.java [110:146]
private String getJLinkExecutable() {
Optional<Toolchain> toolchain = getToolchain();
if (!toolchain.isPresent()) {
getLog().error("Either JDK9+ or a toolchain "
+ "pointing to a JDK9+ containing a jlink binary is required.");
getLog().info("See https://maven.apache.org/guides/mini/guide-using-toolchains.html "
+ "for mor information.");
throw new IllegalStateException("Running on JDK8 and no toolchain found.");
}
String jLinkExecutable =
toolchain.orElseThrow(NoSuchElementException::new).findTool("jlink");
if (jLinkExecutable.isEmpty()) {
throw new IllegalStateException(
"The jlink executable '" + jLinkExecutable + "' doesn't exist or is not a file.");
}
// TODO: Check if there exist a more elegant way?
String jLinkCommand = "jlink" + (SystemUtils.IS_OS_WINDOWS ? ".exe" : "");
File jLinkExe = new File(jLinkExecutable);
if (jLinkExe.isDirectory()) {
jLinkExe = new File(jLinkExe, jLinkCommand);
}
if (SystemUtils.IS_OS_WINDOWS && jLinkExe.getName().indexOf('.') < 0) {
jLinkExe = new File(jLinkExe.getPath() + ".exe");
}
if (!jLinkExe.isFile()) {
throw new IllegalStateException("The jlink executable '" + jLinkExe + "' doesn't exist or is not a file.");
}
return jLinkExe.getAbsolutePath();
}