Search in sources :

Example 1 with ConsumerOperationParameters

use of org.gradle.tooling.internal.consumer.parameters.ConsumerOperationParameters in project gradle by gradle.

the class DefaultBuildLauncher method run.

public void run(final ResultHandler<? super Void> handler) {
    final ConsumerOperationParameters operationParameters = getConsumerOperationParameters();
    connection.run(new ConsumerAction<Void>() {

        public ConsumerOperationParameters getParameters() {
            return operationParameters;
        }

        public Void run(ConsumerConnection connection) {
            Void sink = connection.run(Void.class, operationParameters);
            return sink;
        }
    }, new ResultHandlerAdapter(handler));
}
Also used : ConsumerOperationParameters(org.gradle.tooling.internal.consumer.parameters.ConsumerOperationParameters) ConsumerConnection(org.gradle.tooling.internal.consumer.connection.ConsumerConnection)

Example 2 with ConsumerOperationParameters

use of org.gradle.tooling.internal.consumer.parameters.ConsumerOperationParameters in project gradle by gradle.

the class DefaultTestLauncher method run.

public void run(final ResultHandler<? super Void> handler) {
    if (operationDescriptors.isEmpty() && internalJvmTestRequests.isEmpty()) {
        throw new TestExecutionException("No test declared for execution.");
    }
    final ConsumerOperationParameters operationParameters = getConsumerOperationParameters();
    final TestExecutionRequest testExecutionRequest = new TestExecutionRequest(operationDescriptors, ImmutableList.copyOf(testClassNames), ImmutableSet.copyOf(internalJvmTestRequests));
    connection.run(new ConsumerAction<Void>() {

        public ConsumerOperationParameters getParameters() {
            return operationParameters;
        }

        public Void run(ConsumerConnection connection) {
            connection.runTests(testExecutionRequest, getParameters());
            return null;
        }
    }, new ResultHandlerAdapter(handler));
}
Also used : TestExecutionException(org.gradle.tooling.TestExecutionException) ConsumerOperationParameters(org.gradle.tooling.internal.consumer.parameters.ConsumerOperationParameters) ConsumerConnection(org.gradle.tooling.internal.consumer.connection.ConsumerConnection)

Example 3 with ConsumerOperationParameters

use of org.gradle.tooling.internal.consumer.parameters.ConsumerOperationParameters in project gradle by gradle.

the class LazyConsumerActionExecutor method run.

public <T> T run(ConsumerAction<T> action) throws UnsupportedOperationException, IllegalStateException {
    try {
        ConsumerOperationParameters parameters = action.getParameters();
        BuildCancellationToken cancellationToken = parameters.getCancellationToken();
        InternalBuildProgressListener buildProgressListener = parameters.getBuildProgressListener();
        ConsumerConnection connection = onStartAction(cancellationToken, buildProgressListener);
        return action.run(connection);
    } finally {
        onEndAction();
    }
}
Also used : InternalBuildProgressListener(org.gradle.tooling.internal.protocol.InternalBuildProgressListener) ConsumerOperationParameters(org.gradle.tooling.internal.consumer.parameters.ConsumerOperationParameters) BuildCancellationToken(org.gradle.initialization.BuildCancellationToken)

Example 4 with ConsumerOperationParameters

use of org.gradle.tooling.internal.consumer.parameters.ConsumerOperationParameters in project gradle by gradle.

the class ProgressLoggingConsumerActionExecutor method run.

public <T> T run(ConsumerAction<T> action) throws UnsupportedOperationException, IllegalStateException {
    ConsumerOperationParameters parameters = action.getParameters();
    ProgressListenerAdapter listener = new ProgressListenerAdapter(parameters.getProgressListener());
    ListenerManager listenerManager = loggingProvider.getListenerManager();
    listenerManager.addListener(listener);
    try {
        ProgressLogger progressLogger = loggingProvider.getProgressLoggerFactory().newOperation(ProgressLoggingConsumerActionExecutor.class);
        progressLogger.setDescription("Build");
        progressLogger.started();
        try {
            return actionExecutor.run(action);
        } finally {
            progressLogger.completed();
        }
    } finally {
        listenerManager.removeListener(listener);
    }
}
Also used : ConsumerOperationParameters(org.gradle.tooling.internal.consumer.parameters.ConsumerOperationParameters) ProgressLogger(org.gradle.internal.logging.progress.ProgressLogger) ListenerManager(org.gradle.internal.event.ListenerManager)

Example 5 with ConsumerOperationParameters

use of org.gradle.tooling.internal.consumer.parameters.ConsumerOperationParameters in project gradle by gradle.

the class DefaultBuildActionExecuter method run.

public void run(ResultHandler<? super T> handler) throws IllegalStateException {
    final ConsumerOperationParameters operationParameters = getConsumerOperationParameters();
    connection.run(new ConsumerAction<T>() {

        public ConsumerOperationParameters getParameters() {
            return operationParameters;
        }

        public T run(ConsumerConnection connection) {
            T result = connection.run(buildAction, operationParameters);
            return result;
        }
    }, new ResultHandlerAdapter<T>(handler, new ExceptionTransformer(new Transformer<String, Throwable>() {

        @Override
        public String transform(Throwable throwable) {
            return String.format("Could not run build action using %s.", connection.getDisplayName());
        }
    })));
}
Also used : ConsumerOperationParameters(org.gradle.tooling.internal.consumer.parameters.ConsumerOperationParameters) ConsumerConnection(org.gradle.tooling.internal.consumer.connection.ConsumerConnection)

Aggregations

ConsumerOperationParameters (org.gradle.tooling.internal.consumer.parameters.ConsumerOperationParameters)6 ConsumerConnection (org.gradle.tooling.internal.consumer.connection.ConsumerConnection)4 BuildCancellationToken (org.gradle.initialization.BuildCancellationToken)1 ListenerManager (org.gradle.internal.event.ListenerManager)1 ProgressLogger (org.gradle.internal.logging.progress.ProgressLogger)1 TestExecutionException (org.gradle.tooling.TestExecutionException)1 InternalBuildProgressListener (org.gradle.tooling.internal.protocol.InternalBuildProgressListener)1