Search in sources :

Example 1 with BuildOperationCategory

use of org.gradle.internal.operations.BuildOperationCategory in project gradle by gradle.

the class ProgressStartEventSerializer method write.

@Override
public void write(Encoder encoder, ProgressStartEvent event) throws Exception {
    byte flags = 0;
    OperationIdentifier parentProgressOperationId = event.getParentProgressOperationId();
    if (parentProgressOperationId != null) {
        flags |= PARENT_PROGRESS_ID;
    }
    String shortDescription = event.getShortDescription();
    if (shortDescription != null) {
        flags |= SHORT_DESCRIPTION;
    }
    String loggingHeader = event.getLoggingHeader();
    if (loggingHeader != null) {
        flags |= LOGGING_HEADER;
    }
    OperationIdentifier buildOperationId = event.getBuildOperationId();
    if (buildOperationId != null) {
        flags |= BUILD_OPERATION_ID;
    }
    OperationIdentifier parentBuildOperationId = event.getParentBuildOperationId();
    if (parentBuildOperationId != null) {
        flags |= PARENT_BUILD_OPERATION_ID;
    }
    BuildOperationCategory buildOperationCategory = event.getBuildOperationCategory();
    if (buildOperationCategory == BuildOperationCategory.CONFIGURE_PROJECT) {
        flags |= BUILD_OPERATION_CATEGORY_PROJECT;
    } else if (buildOperationCategory == BuildOperationCategory.TASK) {
        flags |= BUILD_OPERATION_CATEGORY_TASK;
    } else if (buildOperationCategory != BuildOperationCategory.UNCATEGORIZED) {
        throw new IllegalArgumentException("Can't handle build operation category " + buildOperationCategory);
    }
    encoder.writeByte(flags);
    encoder.writeSmallLong(event.getProgressOperationId().getId());
    if (parentProgressOperationId != null) {
        encoder.writeSmallLong(parentProgressOperationId.getId());
    }
    encoder.writeLong(event.getTimestamp());
    encoder.writeString(event.getCategory());
    encoder.writeString(event.getDescription());
    if (shortDescription != null) {
        encoder.writeString(shortDescription);
    }
    if (loggingHeader != null) {
        encoder.writeString(loggingHeader);
    }
    encoder.writeString(event.getStatus());
    encoder.writeInt(event.getTotalProgress());
    encoder.writeBoolean(event.isBuildOperationStart());
    if (buildOperationId != null) {
        encoder.writeSmallLong(buildOperationId.getId());
    }
    if (parentBuildOperationId != null) {
        encoder.writeSmallLong(parentBuildOperationId.getId());
    }
}
Also used : OperationIdentifier(org.gradle.internal.operations.OperationIdentifier) BuildOperationCategory(org.gradle.internal.operations.BuildOperationCategory)

Example 2 with BuildOperationCategory

use of org.gradle.internal.operations.BuildOperationCategory in project gradle by gradle.

the class ProgressStartEventSerializer method read.

@Override
public ProgressStartEvent read(Decoder decoder) throws Exception {
    byte flags = decoder.readByte();
    OperationIdentifier progressOperationId = new OperationIdentifier(decoder.readSmallLong());
    OperationIdentifier parentProgressOperationId = null;
    if ((flags & PARENT_PROGRESS_ID) != 0) {
        parentProgressOperationId = new OperationIdentifier(decoder.readSmallLong());
    }
    long timestamp = decoder.readLong();
    String category = decoder.readString();
    String description = decoder.readString();
    String shortDescription = null;
    if ((flags & SHORT_DESCRIPTION) != 0) {
        shortDescription = decoder.readString();
    }
    String loggingHeader = null;
    if ((flags & LOGGING_HEADER) != 0) {
        loggingHeader = decoder.readString();
    }
    String status = decoder.readString();
    int totalProgress = decoder.readInt();
    boolean buildOperationStart = decoder.readBoolean();
    OperationIdentifier buildOperationId = null;
    if ((flags & BUILD_OPERATION_ID) != 0) {
        buildOperationId = new OperationIdentifier(decoder.readSmallLong());
    }
    OperationIdentifier parentBuildOperationId = null;
    if ((flags & PARENT_BUILD_OPERATION_ID) != 0) {
        parentBuildOperationId = new OperationIdentifier(decoder.readSmallLong());
    }
    BuildOperationCategory buildOperationCategory;
    if ((flags & BUILD_OPERATION_CATEGORY_PROJECT) == BUILD_OPERATION_CATEGORY_PROJECT) {
        buildOperationCategory = BuildOperationCategory.CONFIGURE_PROJECT;
    } else if ((flags & BUILD_OPERATION_CATEGORY_TASK) == BUILD_OPERATION_CATEGORY_TASK) {
        buildOperationCategory = BuildOperationCategory.TASK;
    } else {
        buildOperationCategory = BuildOperationCategory.UNCATEGORIZED;
    }
    return new ProgressStartEvent(progressOperationId, parentProgressOperationId, timestamp, category, description, shortDescription, loggingHeader, status, totalProgress, buildOperationStart, buildOperationId, parentBuildOperationId, buildOperationCategory);
}
Also used : ProgressStartEvent(org.gradle.internal.logging.events.ProgressStartEvent) OperationIdentifier(org.gradle.internal.operations.OperationIdentifier) BuildOperationCategory(org.gradle.internal.operations.BuildOperationCategory)

Aggregations

BuildOperationCategory (org.gradle.internal.operations.BuildOperationCategory)2 OperationIdentifier (org.gradle.internal.operations.OperationIdentifier)2 ProgressStartEvent (org.gradle.internal.logging.events.ProgressStartEvent)1