Search in sources :

Example 1 with ProgressCompleteEvent

use of org.gradle.internal.logging.events.ProgressCompleteEvent in project gradle by gradle.

the class ProgressCompleteEventSerializer method read.

@Override
public ProgressCompleteEvent read(Decoder decoder) throws Exception {
    OperationIdentifier id = new OperationIdentifier(decoder.readSmallLong());
    long timestamp = decoder.readLong();
    String status = decoder.readString();
    boolean failed = decoder.readBoolean();
    return new ProgressCompleteEvent(id, timestamp, status, failed);
}
Also used : OperationIdentifier(org.gradle.internal.operations.OperationIdentifier) ProgressCompleteEvent(org.gradle.internal.logging.events.ProgressCompleteEvent)

Example 2 with ProgressCompleteEvent

use of org.gradle.internal.logging.events.ProgressCompleteEvent in project gradle by gradle.

the class WorkInProgressRenderer method renderNow.

private void renderNow() {
    if (queue.isEmpty()) {
        return;
    }
    // Skip processing of any operations that both start and complete in the queue
    Set<OperationIdentifier> completeEventOperationIds = toOperationIdSet(Iterables.filter(queue, ProgressCompleteEvent.class));
    Set<OperationIdentifier> operationIdsToSkip = new HashSet<OperationIdentifier>();
    for (OutputEvent event : queue) {
        if (event instanceof ProgressStartEvent) {
            progressArea.setVisible(true);
            ProgressStartEvent startEvent = (ProgressStartEvent) event;
            if (completeEventOperationIds.contains(startEvent.getProgressOperationId())) {
                operationIdsToSkip.add(startEvent.getProgressOperationId());
            // Don't attach to any labels
            } else {
                attach(operations.start(startEvent.getStatus(), startEvent.getCategory(), startEvent.getProgressOperationId(), startEvent.getParentProgressOperationId()));
            }
        } else if (event instanceof ProgressCompleteEvent) {
            ProgressCompleteEvent completeEvent = (ProgressCompleteEvent) event;
            if (!operationIdsToSkip.contains(completeEvent.getProgressOperationId())) {
                detach(operations.complete(completeEvent.getProgressOperationId()));
            }
        } else if (event instanceof ProgressEvent) {
            ProgressEvent progressEvent = (ProgressEvent) event;
            if (!operationIdsToSkip.contains(progressEvent.getProgressOperationId())) {
                operations.progress(progressEvent.getStatus(), progressEvent.getProgressOperationId());
            }
        }
    }
    queue.clear();
    for (AssociationLabel associatedLabel : operationIdToAssignedLabels.values()) {
        associatedLabel.renderNow();
    }
    for (StyledLabel emptyLabel : unusedProgressLabels) {
        emptyLabel.setText(labelFormatter.format());
    }
}
Also used : OutputEvent(org.gradle.internal.logging.events.OutputEvent) EndOutputEvent(org.gradle.internal.logging.events.EndOutputEvent) ProgressStartEvent(org.gradle.internal.logging.events.ProgressStartEvent) OperationIdentifier(org.gradle.internal.operations.OperationIdentifier) ProgressCompleteEvent(org.gradle.internal.logging.events.ProgressCompleteEvent) ProgressEvent(org.gradle.internal.logging.events.ProgressEvent) HashSet(java.util.HashSet)

Example 3 with ProgressCompleteEvent

use of org.gradle.internal.logging.events.ProgressCompleteEvent in project gradle by gradle.

the class OutputEventTransformer method onOutput.

@Override
public void onOutput(OutputEvent event) {
    if (event instanceof ProgressStartEvent) {
        ProgressStartEvent startEvent = (ProgressStartEvent) event;
        if (!startEvent.isBuildOperationStart()) {
            forwarded.add(startEvent.getProgressOperationId());
            OperationIdentifier parentProgressOperationId = startEvent.getParentProgressOperationId();
            if (parentProgressOperationId != null) {
                OperationIdentifier mappedId = effectiveProgressOperation.get(parentProgressOperationId);
                if (mappedId != null) {
                    startEvent = startEvent.withParentProgressOperation(mappedId);
                }
            }
            listener.onOutput(startEvent);
            return;
        }
        if (startEvent.getParentProgressOperationId() == null || GUtil.isTrue(startEvent.getLoggingHeader()) || GUtil.isTrue(startEvent.getStatus()) || startEvent.getBuildOperationCategory() != BuildOperationCategory.UNCATEGORIZED) {
            forwarded.add(startEvent.getProgressOperationId());
            OperationIdentifier parentProgressOperationId = startEvent.getParentProgressOperationId();
            if (parentProgressOperationId != null) {
                OperationIdentifier mappedId = effectiveProgressOperation.get(parentProgressOperationId);
                if (mappedId != null) {
                    startEvent = startEvent.withParentProgressOperation(mappedId);
                }
            }
            listener.onOutput(startEvent);
        } else {
            // Ignore this progress operation, and map any reference to it to its parent (or whatever its parent is mapped to)
            OperationIdentifier mappedParent = effectiveProgressOperation.get(startEvent.getParentProgressOperationId());
            if (mappedParent == null) {
                mappedParent = startEvent.getParentProgressOperationId();
            }
            effectiveProgressOperation.put(startEvent.getProgressOperationId(), mappedParent);
        }
    } else if (event instanceof ProgressCompleteEvent) {
        ProgressCompleteEvent completeEvent = (ProgressCompleteEvent) event;
        OperationIdentifier mappedEvent = effectiveProgressOperation.remove(completeEvent.getProgressOperationId());
        if (mappedEvent == null && forwarded.remove(completeEvent.getProgressOperationId())) {
            listener.onOutput(event);
        }
    } else if (event instanceof ProgressEvent) {
        ProgressEvent progressEvent = (ProgressEvent) event;
        if (forwarded.contains(progressEvent.getProgressOperationId())) {
            listener.onOutput(event);
        }
    } else if (event instanceof RenderableOutputEvent) {
        RenderableOutputEvent outputEvent = (RenderableOutputEvent) event;
        OperationIdentifier operationId = outputEvent.getBuildOperationId();
        if (operationId != null) {
            OperationIdentifier mappedId = effectiveProgressOperation.get(operationId);
            if (mappedId != null) {
                outputEvent = outputEvent.withBuildOperationId(mappedId);
            }
        }
        listener.onOutput(outputEvent);
    } else {
        listener.onOutput(event);
    }
}
Also used : ProgressStartEvent(org.gradle.internal.logging.events.ProgressStartEvent) OperationIdentifier(org.gradle.internal.operations.OperationIdentifier) ProgressCompleteEvent(org.gradle.internal.logging.events.ProgressCompleteEvent) RenderableOutputEvent(org.gradle.internal.logging.events.RenderableOutputEvent) ProgressEvent(org.gradle.internal.logging.events.ProgressEvent)

Example 4 with ProgressCompleteEvent

use of org.gradle.internal.logging.events.ProgressCompleteEvent in project gradle by gradle.

the class WorkInProgressRenderer method onOutput.

@Override
public void onOutput(OutputEvent event) {
    if (event instanceof ProgressStartEvent) {
        progressArea.setVisible(true);
        ProgressStartEvent startEvent = (ProgressStartEvent) event;
        ProgressOperation op = operations.start(startEvent.getShortDescription(), startEvent.getStatus(), startEvent.getCategory(), startEvent.getOperationId(), startEvent.getParentId());
        attach(op);
    } else if (event instanceof ProgressCompleteEvent) {
        ProgressCompleteEvent completeEvent = (ProgressCompleteEvent) event;
        detach(operations.complete(completeEvent.getOperationId()));
    } else if (event instanceof ProgressEvent) {
        ProgressEvent progressEvent = (ProgressEvent) event;
        operations.progress(progressEvent.getStatus(), progressEvent.getOperationId());
    } else if (event instanceof EndOutputEvent) {
        progressArea.setVisible(false);
    }
    listener.onOutput(event);
}
Also used : ProgressStartEvent(org.gradle.internal.logging.events.ProgressStartEvent) ProgressCompleteEvent(org.gradle.internal.logging.events.ProgressCompleteEvent) ProgressEvent(org.gradle.internal.logging.events.ProgressEvent) EndOutputEvent(org.gradle.internal.logging.events.EndOutputEvent)

Example 5 with ProgressCompleteEvent

use of org.gradle.internal.logging.events.ProgressCompleteEvent in project gradle by gradle.

the class BuildStatusRenderer method onOutput.

@Override
public void onOutput(OutputEvent event) {
    if (event instanceof ProgressStartEvent) {
        ProgressStartEvent startEvent = (ProgressStartEvent) event;
        if (startEvent.isBuildOperationStart()) {
            if (buildStartTimestamp == 0 && startEvent.getParentProgressOperationId() == null) {
                // The very first event starts the Initializing phase
                // TODO - should use BuildRequestMetaData to determine the build start time
                buildStartTimestamp = startEvent.getTimestamp();
                buildProgressOperationId = startEvent.getProgressOperationId();
                phaseStarted(startEvent, Phase.Initializing);
            } else if (startEvent.getBuildOperationCategory() == BuildOperationCategory.CONFIGURE_ROOT_BUILD) {
                // Once the root build starts configuring, we are in Configuring phase
                phaseStarted(startEvent, Phase.Configuring);
            } else if (startEvent.getBuildOperationCategory() == BuildOperationCategory.CONFIGURE_BUILD && currentPhase == Phase.Configuring) {
                // Any configuring event received from nested or buildSrc builds before the root build starts configuring is ignored
                phaseHasMoreProgress(startEvent);
            } else if (startEvent.getBuildOperationCategory() == BuildOperationCategory.CONFIGURE_PROJECT && currentPhase == Phase.Configuring) {
                // Any configuring event received from nested or buildSrc builds before the root build starts configuring is ignored
                currentPhaseChildren.add(startEvent.getProgressOperationId());
            } else if (startEvent.getBuildOperationCategory() == BuildOperationCategory.RUN_MAIN_TASKS) {
                phaseStarted(startEvent, Phase.Executing);
            } else if (startEvent.getBuildOperationCategory() == BuildOperationCategory.RUN_WORK && currentPhase == Phase.Executing) {
                // Any work execution happening in nested or buildSrc builds before the root build has started executing work is ignored
                phaseHasMoreProgress(startEvent);
            } else if (startEvent.getBuildOperationCategory().isTopLevelWorkItem() && currentPhase == Phase.Executing) {
                // Any work execution happening in nested or buildSrc builds before the root build has started executing work is ignored
                currentPhaseChildren.add(startEvent.getProgressOperationId());
            }
        }
    } else if (event instanceof ProgressCompleteEvent) {
        ProgressCompleteEvent completeEvent = (ProgressCompleteEvent) event;
        if (completeEvent.getProgressOperationId().equals(buildProgressOperationId)) {
            buildEnded();
        } else if (currentPhaseChildren.remove(completeEvent.getProgressOperationId())) {
            phaseProgressed(completeEvent);
        }
    }
    listener.onOutput(event);
    if (event instanceof UpdateNowEvent) {
        currentTimePeriod = ((UpdateNowEvent) event).getTimestamp();
        renderNow(currentTimePeriod);
    } else if (event instanceof EndOutputEvent || event instanceof FlushOutputEvent) {
        renderNow(currentTimePeriod);
    }
}
Also used : UpdateNowEvent(org.gradle.internal.logging.events.UpdateNowEvent) ProgressStartEvent(org.gradle.internal.logging.events.ProgressStartEvent) FlushOutputEvent(org.gradle.internal.logging.events.FlushOutputEvent) ProgressCompleteEvent(org.gradle.internal.logging.events.ProgressCompleteEvent) EndOutputEvent(org.gradle.internal.logging.events.EndOutputEvent)

Aggregations

ProgressCompleteEvent (org.gradle.internal.logging.events.ProgressCompleteEvent)5 ProgressStartEvent (org.gradle.internal.logging.events.ProgressStartEvent)4 EndOutputEvent (org.gradle.internal.logging.events.EndOutputEvent)3 ProgressEvent (org.gradle.internal.logging.events.ProgressEvent)3 OperationIdentifier (org.gradle.internal.operations.OperationIdentifier)3 HashSet (java.util.HashSet)1 FlushOutputEvent (org.gradle.internal.logging.events.FlushOutputEvent)1 OutputEvent (org.gradle.internal.logging.events.OutputEvent)1 RenderableOutputEvent (org.gradle.internal.logging.events.RenderableOutputEvent)1 UpdateNowEvent (org.gradle.internal.logging.events.UpdateNowEvent)1