use of org.gradle.tooling.internal.provider.connection.ProviderOperationParameters in project gradle by gradle.
the class ProviderConnection method runClientAction.
public Object runClientAction(Object clientAction, BuildCancellationToken cancellationToken, ProviderOperationParameters providerParameters) {
List<String> tasks = providerParameters.getTasks();
SerializedPayload serializedAction = payloadSerializer.serialize(clientAction);
Parameters params = initParams(providerParameters);
StartParameterInternal startParameter = new ProviderStartParameterConverter().toStartParameter(providerParameters, params.properties);
ProgressListenerConfiguration listenerConfig = ProgressListenerConfiguration.from(providerParameters);
BuildAction action = new ClientProvidedBuildAction(startParameter, serializedAction, tasks != null, listenerConfig.clientSubscriptions);
return run(action, cancellationToken, listenerConfig, providerParameters, params);
}
use of org.gradle.tooling.internal.provider.connection.ProviderOperationParameters 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());
}
use of org.gradle.tooling.internal.provider.connection.ProviderOperationParameters in project gradle by gradle.
the class ProviderConnection method run.
private Object run(BuildAction action, BuildCancellationToken cancellationToken, ProgressListenerConfiguration progressListenerConfiguration, ProviderOperationParameters providerParameters, Parameters parameters) {
try {
BuildActionExecuter<ProviderOperationParameters> executer = createExecuter(providerParameters, parameters);
BuildRequestContext buildRequestContext = new DefaultBuildRequestContext(new DefaultBuildRequestMetaData(providerParameters.getStartTime()), cancellationToken, progressListenerConfiguration.buildEventConsumer);
BuildActionResult result = (BuildActionResult) executer.execute(action, buildRequestContext, providerParameters, sharedServices);
if (result.failure != null) {
throw (RuntimeException) payloadSerializer.deserialize(result.failure);
}
return payloadSerializer.deserialize(result.result);
} finally {
progressListenerConfiguration.failsafeWrapper.rethrowErrors();
}
}
use of org.gradle.tooling.internal.provider.connection.ProviderOperationParameters in project gradle by gradle.
the class DefaultConnection method validateAndConvert.
private ProviderOperationParameters validateAndConvert(BuildParameters buildParameters) {
LOGGER.info("Tooling API is using target Gradle version: {}.", GradleVersion.current().getVersion());
assertUsingJava7();
checkUnsupportedTapiVersion();
ProviderOperationParameters parameters = adapter.builder(ProviderOperationParameters.class).mixInTo(ProviderOperationParameters.class, BuildLogLevelMixIn.class).build(buildParameters);
checkDeprecatedTapiVersion(parameters);
DeprecationLogger.reset();
return parameters;
}
use of org.gradle.tooling.internal.provider.connection.ProviderOperationParameters in project gradle by gradle.
the class DefaultConnection method getModel.
/**
* This is used by consumers 2.1-rc-1 and later
*/
public BuildResult<?> getModel(ModelIdentifier modelIdentifier, InternalCancellationToken cancellationToken, BuildParameters operationParameters) throws BuildExceptionVersion1, InternalUnsupportedModelException, InternalUnsupportedBuildArgumentException, IllegalStateException {
ProviderOperationParameters providerParameters = validateAndConvert(operationParameters);
BuildCancellationToken buildCancellationToken = new InternalCancellationTokenAdapter(cancellationToken);
Object result = connection.run(modelIdentifier.getName(), buildCancellationToken, providerParameters);
return new ProviderBuildResult<Object>(result);
}
Aggregations