Search in sources :

Example 1 with BuildActionParameters

use of org.gradle.launcher.exec.BuildActionParameters in project gradle by gradle.

the class BuildActionsFactory method runBuildAndCloseServices.

private Runnable runBuildAndCloseServices(StartParameter startParameter, DaemonParameters daemonParameters, BuildActionExecuter<BuildActionParameters> executer, ServiceRegistry sharedServices, Object... stopBeforeSharedServices) {
    BuildActionParameters parameters = createBuildActionParamters(startParameter, daemonParameters);
    Stoppable stoppable = new CompositeStoppable().add(stopBeforeSharedServices).add(sharedServices);
    return new RunBuildAction(executer, startParameter, clientMetaData(), getBuildStartTime(), parameters, sharedServices, stoppable);
}
Also used : BuildActionParameters(org.gradle.launcher.exec.BuildActionParameters) DefaultBuildActionParameters(org.gradle.launcher.exec.DefaultBuildActionParameters) CompositeStoppable(org.gradle.internal.concurrent.CompositeStoppable) Stoppable(org.gradle.internal.concurrent.Stoppable) CompositeStoppable(org.gradle.internal.concurrent.CompositeStoppable)

Example 2 with BuildActionParameters

use of org.gradle.launcher.exec.BuildActionParameters in project gradle by gradle.

the class BuildActionsFactory method runBuildAndCloseServices.

private Runnable runBuildAndCloseServices(StartParameterInternal startParameter, DaemonParameters daemonParameters, BuildActionExecuter<BuildActionParameters> executer, ServiceRegistry sharedServices, Object... stopBeforeSharedServices) {
    BuildActionParameters parameters = createBuildActionParameters(startParameter, daemonParameters);
    Stoppable stoppable = new CompositeStoppable().add(stopBeforeSharedServices).add(sharedServices);
    return new RunBuildAction(executer, startParameter, clientMetaData(), getBuildStartTime(), parameters, sharedServices, stoppable);
}
Also used : BuildActionParameters(org.gradle.launcher.exec.BuildActionParameters) DefaultBuildActionParameters(org.gradle.launcher.exec.DefaultBuildActionParameters) CompositeStoppable(org.gradle.internal.concurrent.CompositeStoppable) Stoppable(org.gradle.internal.concurrent.Stoppable) CompositeStoppable(org.gradle.internal.concurrent.CompositeStoppable)

Example 3 with BuildActionParameters

use of org.gradle.launcher.exec.BuildActionParameters in project gradle by gradle.

the class InProcessGradleExecuter method executeBuild.

private BuildResult executeBuild(GradleInvocation invocation, OutputStream outputStream, OutputStream errorStream, BuildListenerImpl listener) {
    // Augment the environment for the execution
    System.setIn(connectStdIn());
    processEnvironment.maybeSetProcessDir(getWorkingDir());
    for (Map.Entry<String, String> entry : invocation.environmentVars.entrySet()) {
        processEnvironment.maybeSetEnvironmentVariable(entry.getKey(), entry.getValue());
    }
    Map<String, String> implicitJvmSystemProperties = getImplicitJvmSystemProperties();
    System.getProperties().putAll(implicitJvmSystemProperties);
    // TODO: Reuse more of CommandlineActionFactory
    CommandLineParser parser = new CommandLineParser();
    FileCollectionFactory fileCollectionFactory = TestFiles.fileCollectionFactory();
    ParametersConverter parametersConverter = new ParametersConverter(new BuildLayoutFactory(), fileCollectionFactory);
    parametersConverter.configure(parser);
    Parameters parameters = parametersConverter.convert(parser.parse(getAllArgs()), getWorkingDir());
    BuildActionExecuter<BuildActionParameters, BuildRequestContext> actionExecuter = GLOBAL_SERVICES.get(BuildActionExecuter.class);
    ListenerManager listenerManager = GLOBAL_SERVICES.get(ListenerManager.class);
    listenerManager.addListener(listener);
    try {
        // TODO: Reuse more of BuildActionsFactory
        StartParameterInternal startParameter = parameters.getStartParameter();
        BuildAction action = new ExecuteBuildAction(startParameter);
        BuildActionParameters buildActionParameters = createBuildActionParameters(startParameter);
        BuildRequestContext buildRequestContext = createBuildRequestContext();
        LoggingManagerInternal loggingManager = createLoggingManager(startParameter, outputStream, errorStream);
        loggingManager.start();
        try {
            startMeasurement();
            try {
                BuildActionResult result = actionExecuter.execute(action, buildActionParameters, buildRequestContext);
                if (result.getException() != null) {
                    return new BuildResult(null, result.getException());
                }
                if (result.getFailure() != null) {
                    PayloadSerializer payloadSerializer = new PayloadSerializer(new TestClassLoaderRegistry());
                    return new BuildResult(null, (RuntimeException) payloadSerializer.deserialize(result.getFailure()));
                }
                return new BuildResult(null, null);
            } finally {
                stopMeasurement();
            }
        } finally {
            loggingManager.stop();
        }
    } finally {
        listenerManager.removeListener(listener);
    }
}
Also used : LoggingManagerInternal(org.gradle.internal.logging.LoggingManagerInternal) DefaultBuildActionParameters(org.gradle.launcher.exec.DefaultBuildActionParameters) BuildActionParameters(org.gradle.launcher.exec.BuildActionParameters) Parameters(org.gradle.launcher.cli.Parameters) PayloadSerializer(org.gradle.tooling.internal.provider.serialization.PayloadSerializer) DefaultBuildActionParameters(org.gradle.launcher.exec.DefaultBuildActionParameters) BuildActionParameters(org.gradle.launcher.exec.BuildActionParameters) ExecuteBuildAction(org.gradle.tooling.internal.provider.action.ExecuteBuildAction) Hashing.hashString(org.gradle.internal.hash.Hashing.hashString) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) BuildLayoutFactory(org.gradle.initialization.layout.BuildLayoutFactory) DefaultBuildRequestContext(org.gradle.initialization.DefaultBuildRequestContext) BuildRequestContext(org.gradle.initialization.BuildRequestContext) BuildResult(org.gradle.BuildResult) ParametersConverter(org.gradle.launcher.cli.ParametersConverter) StartParameterInternal(org.gradle.api.internal.StartParameterInternal) BuildActionResult(org.gradle.launcher.exec.BuildActionResult) CommandLineParser(org.gradle.cli.CommandLineParser) SerializeMap(org.gradle.tooling.internal.provider.serialization.SerializeMap) Map(java.util.Map) DeserializeMap(org.gradle.tooling.internal.provider.serialization.DeserializeMap) HashMap(java.util.HashMap) ExecuteBuildAction(org.gradle.tooling.internal.provider.action.ExecuteBuildAction) BuildAction(org.gradle.internal.invocation.BuildAction) FileCollectionFactory(org.gradle.api.internal.file.FileCollectionFactory) ListenerManager(org.gradle.internal.event.ListenerManager)

Example 4 with BuildActionParameters

use of org.gradle.launcher.exec.BuildActionParameters in project gradle by gradle.

the class BuildActionsFactory method runBuildAndCloseServices.

private Runnable runBuildAndCloseServices(StartParameterInternal startParameter, DaemonParameters daemonParameters, BuildActionExecuter<BuildActionParameters, BuildRequestContext> executer, ServiceRegistry sharedServices, Object... stopBeforeSharedServices) {
    BuildActionParameters parameters = createBuildActionParameters(startParameter, daemonParameters);
    Stoppable stoppable = new CompositeStoppable().add(stopBeforeSharedServices).add(sharedServices);
    return new RunBuildAction(executer, startParameter, clientMetaData(), getBuildStartTime(), parameters, sharedServices, stoppable);
}
Also used : BuildActionParameters(org.gradle.launcher.exec.BuildActionParameters) DefaultBuildActionParameters(org.gradle.launcher.exec.DefaultBuildActionParameters) CompositeStoppable(org.gradle.internal.concurrent.CompositeStoppable) Stoppable(org.gradle.internal.concurrent.Stoppable) CompositeStoppable(org.gradle.internal.concurrent.CompositeStoppable)

Example 5 with BuildActionParameters

use of org.gradle.launcher.exec.BuildActionParameters in project gradle by gradle.

the class ProviderConnection method createExecuter.

private BuildActionExecuter<ConnectionOperationParameters, BuildRequestContext> createExecuter(ProviderOperationParameters operationParameters, Parameters params) {
    LoggingManagerInternal loggingManager;
    BuildActionExecuter<BuildActionParameters, BuildRequestContext> executer;
    InputStream standardInput = operationParameters.getStandardInput();
    if (standardInput == null) {
        standardInput = SafeStreams.emptyInput();
    }
    if (Boolean.TRUE.equals(operationParameters.isEmbedded())) {
        loggingManager = sharedServices.getFactory(LoggingManagerInternal.class).create();
        loggingManager.captureSystemSources();
        executer = new StdInSwapExecuter(standardInput, embeddedExecutor);
    } else {
        LoggingServiceRegistry loggingServices = LoggingServiceRegistry.newNestedLogging();
        loggingManager = loggingServices.getFactory(LoggingManagerInternal.class).create();
        ServiceRegistry clientServices = daemonClientFactory.createBuildClientServices(loggingServices.get(OutputEventListener.class), params.daemonParams, standardInput);
        executer = clientServices.get(DaemonClient.class);
    }
    return new LoggingBridgingBuildActionExecuter(new DaemonBuildActionExecuter(executer), loggingManager);
}
Also used : LoggingManagerInternal(org.gradle.internal.logging.LoggingManagerInternal) DaemonClient(org.gradle.launcher.daemon.client.DaemonClient) InputStream(java.io.InputStream) BuildActionParameters(org.gradle.launcher.exec.BuildActionParameters) LoggingServiceRegistry(org.gradle.internal.logging.services.LoggingServiceRegistry) ServiceRegistry(org.gradle.internal.service.ServiceRegistry) OutputEventListener(org.gradle.internal.logging.events.OutputEventListener) DefaultBuildRequestContext(org.gradle.initialization.DefaultBuildRequestContext) BuildRequestContext(org.gradle.initialization.BuildRequestContext) LoggingServiceRegistry(org.gradle.internal.logging.services.LoggingServiceRegistry)

Aggregations

BuildActionParameters (org.gradle.launcher.exec.BuildActionParameters)8 DefaultBuildActionParameters (org.gradle.launcher.exec.DefaultBuildActionParameters)7 BuildRequestContext (org.gradle.initialization.BuildRequestContext)3 DefaultBuildRequestContext (org.gradle.initialization.DefaultBuildRequestContext)3 CompositeStoppable (org.gradle.internal.concurrent.CompositeStoppable)3 Stoppable (org.gradle.internal.concurrent.Stoppable)3 LoggingManagerInternal (org.gradle.internal.logging.LoggingManagerInternal)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 BuildResult (org.gradle.BuildResult)2 StartParameterInternal (org.gradle.api.internal.StartParameterInternal)2 CommandLineParser (org.gradle.cli.CommandLineParser)2 ReportedException (org.gradle.initialization.ReportedException)2 BuildLayoutFactory (org.gradle.initialization.layout.BuildLayoutFactory)2 ClassPath (org.gradle.internal.classpath.ClassPath)2 DefaultClassPath (org.gradle.internal.classpath.DefaultClassPath)2 ListenerManager (org.gradle.internal.event.ListenerManager)2 BuildAction (org.gradle.internal.invocation.BuildAction)2 Parameters (org.gradle.launcher.cli.Parameters)2 ParametersConverter (org.gradle.launcher.cli.ParametersConverter)2