use of org.gradle.launcher.cli.converter.LayoutToPropertiesConverter 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().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());
}
Aggregations