1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-27 00:38:11 -07:00

Don't require $JAVA_HOME any more.

This commit is contained in:
Cedric Beust 2015-11-05 01:44:24 -08:00
parent 46cf29d393
commit 023d8a5e04
3 changed files with 13 additions and 12 deletions

View file

@ -95,10 +95,13 @@ public open class Jvm constructor(
// }
override public fun findExecutable(command: String): File {
val exec = File(javaHome, "bin/" + command)
val executable = java.io.File(os.getExecutableName(exec.getAbsolutePath()))
if (executable.isFile()) {
return executable
if (javaHome != null) {
val jdkHome = if (javaHome!!.endsWith("jre")) javaHome!!.parentFile else javaHome
val exec = File(jdkHome, "bin/" + command)
var executable = File(os.getExecutableName(exec.absolutePath))
if (executable.isFile) {
return executable
}
}
// if (userSupplied) {
@ -108,12 +111,12 @@ public open class Jvm constructor(
val pathExecutable = os.findInPath(command)
if (pathExecutable != null) {
log(1, "Unable to find the ${command} executable using home: " +
"%{javaHome}. We found it on the PATH: ${pathExecutable}.")
log(1, "Unable to find the $command executable using home: " +
"%{javaHome}. We found it on the PATH: $pathExecutable.")
return pathExecutable
}
warn("Unable to find the ${command} executable. Tried the java home: ${javaHome}" +
warn("Unable to find the $command executable. Tried the java home: $javaHome" +
" and the PATH. We will assume the executable can be ran in the current " +
"working folder.")
return java.io.File(os.getExecutableName(command))

View file

@ -1,11 +1,9 @@
package com.beust.kobalt
import java.util.concurrent.locks.ReentrantLock
import javax.inject.Inject
public class SystemProperties {
companion object {
val javaBase = System.getenv("JAVA_HOME") ?: throw IllegalArgumentException("JAVA_HOME not defined")
val javaBase = System.getProperty("java.home") ?:
(System.getenv("JAVA_HOME") ?: throw IllegalArgumentException("JAVA_HOME not defined"))
val javaVersion = System.getProperty("java.version")
val homeDir = System.getProperty("user.home")
val tmpDir = System.getProperty("java.io.tmpdir")