Search in sources :

Example 1 with ProgressEvent

use of org.gradle.internal.logging.events.ProgressEvent 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 2 with ProgressEvent

use of org.gradle.internal.logging.events.ProgressEvent 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 3 with ProgressEvent

use of org.gradle.internal.logging.events.ProgressEvent 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 4 with ProgressEvent

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

the class ProgressEventSerializer method read.

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

Aggregations

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