in src/main/java/org/apache/maven/plugins/jmod/AbstractJModMojo.java [74:135]
protected String getJModExecutable() throws IOException {
Toolchain tc = getToolchain();
String jModExecutable = null;
if (tc != null) {
jModExecutable = tc.findTool("jmod");
}
String jModCommand = "jmod" + (Os.isFamily(Os.FAMILY_WINDOWS) ? ".exe" : "");
File jModExe;
if (StringUtils.isNotEmpty(jModExecutable)) {
jModExe = new File(jModExecutable);
if (jModExe.isDirectory()) {
jModExe = new File(jModExe, jModCommand);
}
if (Os.isFamily(Os.FAMILY_WINDOWS) && jModExe.getName().indexOf('.') < 0) {
jModExe = new File(jModExe.getPath() + ".exe");
}
if (!jModExe.isFile()) {
throw new IOException("The jmod executable '" + jModExe + "' doesn't exist or is not a file.");
}
return jModExe.getAbsolutePath();
}
// ----------------------------------------------------------------------
// Try to find jmod from System.getProperty( "java.home" )
// By default, System.getProperty( "java.home" ) = JRE_HOME and JRE_HOME
// should be in the JDK_HOME
// ----------------------------------------------------------------------
jModExe =
new File(System.getProperty("java.home") + File.separator + ".." + File.separator + "bin", jModCommand);
// ----------------------------------------------------------------------
// Try to find jmod from JAVA_HOME environment variable
// ----------------------------------------------------------------------
if (!jModExe.exists() || !jModExe.isFile()) {
Properties env = CommandLineUtils.getSystemEnvVars();
String javaHome = env.getProperty("JAVA_HOME");
if (StringUtils.isEmpty(javaHome)) {
throw new IOException("The environment variable JAVA_HOME is not correctly set.");
}
if ((!new File(javaHome).getCanonicalFile().exists())
|| (new File(javaHome).getCanonicalFile().isFile())) {
throw new IOException("The environment variable JAVA_HOME=" + javaHome
+ " doesn't exist or is not a valid directory.");
}
jModExe = new File(javaHome + File.separator + "bin", jModCommand);
}
if (!jModExe.getCanonicalFile().exists() || !jModExe.getCanonicalFile().isFile()) {
throw new IOException("The jmod executable '" + jModExe
+ "' doesn't exist or is not a file. Verify the JAVA_HOME environment variable.");
}
return jModExe.getAbsolutePath();
}