Search in sources :

Example 6 with ProviderOperationParameters

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);
}
Also used : SerializedPayload(org.gradle.tooling.internal.provider.serialization.SerializedPayload) 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) StartParameterInternal(org.gradle.api.internal.StartParameterInternal) InternalBuildAction(org.gradle.tooling.internal.protocol.InternalBuildAction) BuildAction(org.gradle.internal.invocation.BuildAction)

Example 7 with ProviderOperationParameters

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());
}
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)

Example 8 with ProviderOperationParameters

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();
    }
}
Also used : DefaultBuildRequestContext(org.gradle.initialization.DefaultBuildRequestContext) DefaultBuildRequestMetaData(org.gradle.initialization.DefaultBuildRequestMetaData) ProviderOperationParameters(org.gradle.tooling.internal.provider.connection.ProviderOperationParameters) DefaultBuildRequestContext(org.gradle.initialization.DefaultBuildRequestContext) BuildRequestContext(org.gradle.initialization.BuildRequestContext)

Example 9 with ProviderOperationParameters

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;
}
Also used : ProviderOperationParameters(org.gradle.tooling.internal.provider.connection.ProviderOperationParameters) BuildLogLevelMixIn(org.gradle.tooling.internal.provider.connection.BuildLogLevelMixIn)

Example 10 with ProviderOperationParameters

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);
}
Also used : ProviderOperationParameters(org.gradle.tooling.internal.provider.connection.ProviderOperationParameters) ProviderBuildResult(org.gradle.tooling.internal.provider.connection.ProviderBuildResult) DefaultBuildCancellationToken(org.gradle.initialization.DefaultBuildCancellationToken) BuildCancellationToken(org.gradle.initialization.BuildCancellationToken)

Aggregations

ProviderOperationParameters (org.gradle.tooling.internal.provider.connection.ProviderOperationParameters)13 DefaultBuildCancellationToken (org.gradle.initialization.DefaultBuildCancellationToken)6 ProviderBuildResult (org.gradle.tooling.internal.provider.connection.ProviderBuildResult)6 BuildLayoutParameters (org.gradle.initialization.BuildLayoutParameters)5 DaemonParameters (org.gradle.launcher.daemon.configuration.DaemonParameters)5 BuildActionParameters (org.gradle.launcher.exec.BuildActionParameters)5 ProviderConnectionParameters (org.gradle.tooling.internal.provider.connection.ProviderConnectionParameters)5 BuildCancellationToken (org.gradle.initialization.BuildCancellationToken)4 StartParameterInternal (org.gradle.api.internal.StartParameterInternal)3 BuildAction (org.gradle.internal.invocation.BuildAction)3 InternalBuildAction (org.gradle.tooling.internal.protocol.InternalBuildAction)3 SerializedPayload (org.gradle.tooling.internal.provider.serialization.SerializedPayload)2 File (java.io.File)1 HashMap (java.util.HashMap)1 StartParameter (org.gradle.StartParameter)1 BuildRequestContext (org.gradle.initialization.BuildRequestContext)1 DefaultBuildRequestContext (org.gradle.initialization.DefaultBuildRequestContext)1 DefaultBuildRequestMetaData (org.gradle.initialization.DefaultBuildRequestMetaData)1 LayoutToPropertiesConverter (org.gradle.launcher.cli.converter.LayoutToPropertiesConverter)1 PropertiesToDaemonParametersConverter (org.gradle.launcher.cli.converter.PropertiesToDaemonParametersConverter)1