Search in sources :

Example 1 with ContinuousExecutionGate

use of org.gradle.deployment.internal.ContinuousExecutionGate in project gradle by gradle.

the class ContinuousBuildActionExecutor method waitForDeployments.

private void waitForDeployments(BuildAction action, BuildRequestMetaData requestContext, BuildSessionContext buildSession, BuildCancellationToken cancellationToken, CancellableOperationManager cancellableOperationManager) {
    if (!deploymentRegistry.getRunningDeployments().isEmpty()) {
        // Deployments are considered outOfDate until initial execution with file watching
        for (Deployment deployment : deploymentRegistry.getRunningDeployments()) {
            ((DeploymentInternal) deployment).outOfDate();
        }
        logger.println().println("Reloadable deployment detected. Entering continuous build.");
        resetBuildStartedTime();
        ContinuousExecutionGate deploymentRequestExecutionGate = deploymentRegistry.getExecutionGate();
        executeMultipleBuilds(action, requestContext, buildSession, cancellationToken, cancellableOperationManager, deploymentRequestExecutionGate);
    }
    cancellableOperationManager.closeInput();
}
Also used : ContinuousExecutionGate(org.gradle.deployment.internal.ContinuousExecutionGate) DefaultContinuousExecutionGate(org.gradle.deployment.internal.DefaultContinuousExecutionGate) Deployment(org.gradle.deployment.internal.Deployment) DeploymentInternal(org.gradle.deployment.internal.DeploymentInternal)

Example 2 with ContinuousExecutionGate

use of org.gradle.deployment.internal.ContinuousExecutionGate in project gradle by gradle.

the class ContinuousBuildActionExecutor method executeMultipleBuilds.

private BuildActionRunner.Result executeMultipleBuilds(BuildAction action, BuildRequestMetaData requestContext, BuildSessionContext buildSession, BuildCancellationToken cancellationToken, CancellableOperationManager cancellableOperationManager, ContinuousExecutionGate continuousExecutionGate) {
    BuildActionRunner.Result lastResult;
    PendingChangesListener pendingChangesListener = listenerManager.getBroadcaster(PendingChangesListener.class);
    while (true) {
        BuildInputHierarchy buildInputs = new BuildInputHierarchy(caseSensitivity, stat);
        ContinuousBuildTriggerHandler continuousBuildTriggerHandler = new ContinuousBuildTriggerHandler(cancellationToken, continuousExecutionGate, action.getStartParameter().getContinuousBuildQuietPeriod());
        SingleFirePendingChangesListener singleFirePendingChangesListener = new SingleFirePendingChangesListener(pendingChangesListener);
        FileEventCollector fileEventCollector = new FileEventCollector(buildInputs, () -> {
            continuousBuildTriggerHandler.notifyFileChangeArrived();
            singleFirePendingChangesListener.onPendingChanges();
        });
        try {
            fileChangeListeners.addListener(fileEventCollector);
            lastResult = executeBuildAndAccumulateInputs(action, new AccumulateBuildInputsListener(buildInputs), buildSession);
            if (buildInputs.isEmpty()) {
                logger.println().withStyle(StyledTextOutput.Style.Failure).println("Exiting continuous build as Gradle did not detect any file system inputs.");
                return lastResult;
            } else if (!continuousBuildTriggerHandler.hasBeenTriggered() && !fileSystemWatchingInformation.isWatchingAnyLocations()) {
                logger.println().withStyle(StyledTextOutput.Style.Failure).println("Exiting continuous build as Gradle does not watch any file system locations.");
                return lastResult;
            } else {
                cancellableOperationManager.monitorInput(operationToken -> {
                    continuousBuildTriggerHandler.wait(() -> logger.println().println("Waiting for changes to input files..." + determineExitHint(requestContext)));
                    if (!operationToken.isCancellationRequested()) {
                        fileEventCollector.reportChanges(logger);
                    }
                });
            }
        } finally {
            fileChangeListeners.removeListener(fileEventCollector);
        }
        if (cancellationToken.isCancellationRequested()) {
            break;
        } else {
            logger.println("Change detected, executing build...").println();
            resetBuildStartedTime();
        }
    }
    logger.println("Build cancelled.");
    return lastResult;
}
Also used : DefaultCancellableOperationManager(org.gradle.execution.DefaultCancellableOperationManager) BuildRequestMetaData(org.gradle.initialization.BuildRequestMetaData) ExecutorFactory(org.gradle.internal.concurrent.ExecutorFactory) Supplier(java.util.function.Supplier) DeploymentRegistryInternal(org.gradle.deployment.internal.DeploymentRegistryInternal) BuildSessionActionExecutor(org.gradle.internal.session.BuildSessionActionExecutor) WorkInputListeners(org.gradle.internal.execution.WorkInputListeners) ContinuousExecutionGate(org.gradle.deployment.internal.ContinuousExecutionGate) Clock(org.gradle.internal.time.Clock) WorkInputListener(org.gradle.internal.execution.WorkInputListener) DisconnectableInputStream(org.gradle.util.internal.DisconnectableInputStream) PassThruCancellableOperationManager(org.gradle.execution.PassThruCancellableOperationManager) Deployment(org.gradle.deployment.internal.Deployment) CancellableOperationManager(org.gradle.execution.CancellableOperationManager) BuildActionRunner(org.gradle.internal.buildtree.BuildActionRunner) LogLevel(org.gradle.api.logging.LogLevel) BuildCancellationToken(org.gradle.initialization.BuildCancellationToken) ListenerManager(org.gradle.internal.event.ListenerManager) CaseSensitivity(org.gradle.internal.snapshot.CaseSensitivity) Stat(org.gradle.internal.file.Stat) StyledTextOutput(org.gradle.internal.logging.text.StyledTextOutput) FileSystemWatchingInformation(org.gradle.internal.watch.vfs.FileSystemWatchingInformation) DeploymentInternal(org.gradle.deployment.internal.DeploymentInternal) OperatingSystem(org.gradle.internal.os.OperatingSystem) DefaultContinuousExecutionGate(org.gradle.deployment.internal.DefaultContinuousExecutionGate) FileChangeListeners(org.gradle.internal.watch.vfs.FileChangeListeners) PendingChangesListener(org.gradle.deployment.internal.PendingChangesListener) BuildAction(org.gradle.internal.invocation.BuildAction) BuildStartedTime(org.gradle.internal.buildevents.BuildStartedTime) BuildSessionContext(org.gradle.internal.session.BuildSessionContext) StyledTextOutputFactory(org.gradle.internal.logging.text.StyledTextOutputFactory) PendingChangesListener(org.gradle.deployment.internal.PendingChangesListener) BuildActionRunner(org.gradle.internal.buildtree.BuildActionRunner)

Aggregations

ContinuousExecutionGate (org.gradle.deployment.internal.ContinuousExecutionGate)2 DefaultContinuousExecutionGate (org.gradle.deployment.internal.DefaultContinuousExecutionGate)2 Deployment (org.gradle.deployment.internal.Deployment)2 DeploymentInternal (org.gradle.deployment.internal.DeploymentInternal)2 Supplier (java.util.function.Supplier)1 LogLevel (org.gradle.api.logging.LogLevel)1 DeploymentRegistryInternal (org.gradle.deployment.internal.DeploymentRegistryInternal)1 PendingChangesListener (org.gradle.deployment.internal.PendingChangesListener)1 CancellableOperationManager (org.gradle.execution.CancellableOperationManager)1 DefaultCancellableOperationManager (org.gradle.execution.DefaultCancellableOperationManager)1 PassThruCancellableOperationManager (org.gradle.execution.PassThruCancellableOperationManager)1 BuildCancellationToken (org.gradle.initialization.BuildCancellationToken)1 BuildRequestMetaData (org.gradle.initialization.BuildRequestMetaData)1 BuildStartedTime (org.gradle.internal.buildevents.BuildStartedTime)1 BuildActionRunner (org.gradle.internal.buildtree.BuildActionRunner)1 ExecutorFactory (org.gradle.internal.concurrent.ExecutorFactory)1 ListenerManager (org.gradle.internal.event.ListenerManager)1 WorkInputListener (org.gradle.internal.execution.WorkInputListener)1 WorkInputListeners (org.gradle.internal.execution.WorkInputListeners)1 Stat (org.gradle.internal.file.Stat)1