Search in sources :

Example 1 with JavaInfo

use of org.gradle.internal.jvm.JavaInfo in project gradle by gradle.

the class PropertiesToDaemonParametersConverter method convert.

public void convert(Map<String, String> properties, DaemonParameters target) {
    String prop = properties.get(IDLE_TIMEOUT_PROPERTY);
    if (prop != null) {
        try {
            target.setIdleTimeout(new Integer(prop));
        } catch (NumberFormatException e) {
            throw new GradleException(String.format("Unable to parse %s property. The value should be an int but is: %s", IDLE_TIMEOUT_PROPERTY, prop));
        }
    }
    prop = properties.get(HEALTH_CHECK_INTERVAL_PROPERTY);
    if (prop != null) {
        try {
            target.setPeriodicCheckInterval(new Integer(prop));
        } catch (NumberFormatException e) {
            throw new GradleException(String.format("Unable to parse %s property. Expected an int but got: %s", HEALTH_CHECK_INTERVAL_PROPERTY, prop), e);
        }
    }
    prop = properties.get(JVM_ARGS_PROPERTY);
    if (prop != null) {
        target.setJvmArgs(JvmOptions.fromString(prop));
    }
    prop = properties.get(JAVA_HOME_PROPERTY);
    if (prop != null) {
        File javaHome = new File(prop);
        if (!javaHome.isDirectory()) {
            throw new GradleException(String.format("Java home supplied via '%s' is invalid. Invalid directory: %s", JAVA_HOME_PROPERTY, prop));
        }
        JavaInfo jvm;
        try {
            jvm = Jvm.forHome(javaHome);
        } catch (JavaHomeException e) {
            throw new GradleException(String.format("Java home supplied via '%s' seems to be invalid: %s", JAVA_HOME_PROPERTY, prop));
        }
        target.setJvm(jvm);
    }
    prop = properties.get(DAEMON_BASE_DIR_PROPERTY);
    if (prop != null) {
        target.setBaseDir(new File(prop));
    }
    String daemonEnabledPropertyValue = properties.get(DAEMON_ENABLED_PROPERTY);
    if (daemonEnabledPropertyValue != null) {
        target.setEnabled(isTrue(daemonEnabledPropertyValue));
    }
    final String debugEnabledPropertyValue = properties.get(DEBUG_MODE_PROPERTY);
    if (debugEnabledPropertyValue != null) {
        target.setDebug(isTrue(debugEnabledPropertyValue));
    }
}
Also used : GradleException(org.gradle.api.GradleException) JavaInfo(org.gradle.internal.jvm.JavaInfo) JavaHomeException(org.gradle.internal.jvm.JavaHomeException) File(java.io.File)

Aggregations

File (java.io.File)1 GradleException (org.gradle.api.GradleException)1 JavaHomeException (org.gradle.internal.jvm.JavaHomeException)1 JavaInfo (org.gradle.internal.jvm.JavaInfo)1