Search in sources :

Example 1 with PropertiesToDaemonParametersConverter

use of org.gradle.launcher.cli.converter.PropertiesToDaemonParametersConverter in project gradle by gradle.

the class ProviderConnection method initParams.

private Parameters initParams(ProviderOperationParameters operationParameters) {
    BuildLayoutParameters layout = new BuildLayoutParameters();
    if (operationParameters.getGradleUserHomeDir() != null) {
        layout.setGradleUserHomeDir(operationParameters.getGradleUserHomeDir());
    }
    layout.setSearchUpwards(operationParameters.isSearchUpwards() != null ? operationParameters.isSearchUpwards() : true);
    layout.setProjectDir(operationParameters.getProjectDir());
    Map<String, String> properties = new HashMap<String, String>();
    new LayoutToPropertiesConverter(buildLayoutFactory).convert(layout, properties);
    DaemonParameters daemonParams = new DaemonParameters(layout);
    new PropertiesToDaemonParametersConverter().convert(properties, daemonParams);
    if (operationParameters.getDaemonBaseDir(null) != null) {
        daemonParams.setBaseDir(operationParameters.getDaemonBaseDir(null));
    }
    // override the params with the explicit settings provided by the tooling api
    List<String> jvmArguments = operationParameters.getJvmArguments();
    if (jvmArguments != null) {
        daemonParams.setJvmArgs(jvmArguments);
    }
    Map<String, String> envVariables = null;
    try {
        envVariables = operationParameters.getEnvironmentVariables();
    } catch (UnsupportedMethodException e) {
        LOGGER.debug("Environment variables customization is not supported by target Gradle instance", e);
    }
    if (envVariables != null) {
        daemonParams.setEnvironmentVariables(envVariables);
    }
    File javaHome = operationParameters.getJavaHome();
    if (javaHome != null) {
        daemonParams.setJvm(Jvm.forHome(javaHome));
    }
    daemonParams.applyDefaultsFor(jvmVersionDetector.getJavaVersion(daemonParams.getEffectiveJvm()));
    if (operationParameters.getDaemonMaxIdleTimeValue() != null && operationParameters.getDaemonMaxIdleTimeUnits() != null) {
        int idleTimeout = (int) operationParameters.getDaemonMaxIdleTimeUnits().toMillis(operationParameters.getDaemonMaxIdleTimeValue());
        daemonParams.setIdleTimeout(idleTimeout);
    }
    return new Parameters(daemonParams, properties, layout.getGradleUserHomeDir());
}
Also used : LayoutToPropertiesConverter(org.gradle.launcher.cli.converter.LayoutToPropertiesConverter) ProviderConnectionParameters(org.gradle.tooling.internal.provider.connection.ProviderConnectionParameters) BuildLayoutParameters(org.gradle.initialization.BuildLayoutParameters) ProviderOperationParameters(org.gradle.tooling.internal.provider.connection.ProviderOperationParameters) DaemonParameters(org.gradle.launcher.daemon.configuration.DaemonParameters) BuildActionParameters(org.gradle.launcher.exec.BuildActionParameters) HashMap(java.util.HashMap) UnsupportedMethodException(org.gradle.tooling.model.UnsupportedMethodException) BuildLayoutParameters(org.gradle.initialization.BuildLayoutParameters) File(java.io.File) DaemonParameters(org.gradle.launcher.daemon.configuration.DaemonParameters) PropertiesToDaemonParametersConverter(org.gradle.launcher.cli.converter.PropertiesToDaemonParametersConverter)

Aggregations

File (java.io.File)1 HashMap (java.util.HashMap)1 BuildLayoutParameters (org.gradle.initialization.BuildLayoutParameters)1 LayoutToPropertiesConverter (org.gradle.launcher.cli.converter.LayoutToPropertiesConverter)1 PropertiesToDaemonParametersConverter (org.gradle.launcher.cli.converter.PropertiesToDaemonParametersConverter)1 DaemonParameters (org.gradle.launcher.daemon.configuration.DaemonParameters)1 BuildActionParameters (org.gradle.launcher.exec.BuildActionParameters)1 ProviderConnectionParameters (org.gradle.tooling.internal.provider.connection.ProviderConnectionParameters)1 ProviderOperationParameters (org.gradle.tooling.internal.provider.connection.ProviderOperationParameters)1 UnsupportedMethodException (org.gradle.tooling.model.UnsupportedMethodException)1