Search in sources :

Example 1 with UniqueId

use of org.gradle.internal.id.UniqueId in project gradle by gradle.

the class TaskOutputOriginFactory method createReader.

public TaskOutputOriginReader createReader(final TaskInternal task) {
    return new TaskOutputOriginReader() {

        @Override
        public OriginTaskExecutionMetadata execute(InputStream inputStream) {
            // TODO: Replace this with something better
            Properties properties = new Properties();
            try {
                properties.load(inputStream);
            } catch (IOException e) {
                throw UncheckedException.throwAsUncheckedException(e);
            }
            if (!properties.stringPropertyNames().containsAll(METADATA_KEYS)) {
                throw new IllegalStateException("Cached result format error, corrupted origin metadata.");
            }
            LOGGER.info("Origin for {}: {}", task, properties);
            UniqueId originBuildInvocationId = UniqueId.from(properties.getProperty(BUILD_INVOCATION_ID_KEY));
            long originalExecutionTime = Long.parseLong(properties.getProperty(EXECUTION_TIME_KEY));
            return new OriginTaskExecutionMetadata(originBuildInvocationId, originalExecutionTime);
        }
    };
}
Also used : UniqueId(org.gradle.internal.id.UniqueId) InputStream(java.io.InputStream) OriginTaskExecutionMetadata(org.gradle.api.internal.tasks.OriginTaskExecutionMetadata) IOException(java.io.IOException) Properties(java.util.Properties)

Example 2 with UniqueId

use of org.gradle.internal.id.UniqueId in project gradle by gradle.

the class ExecuteTaskBuildOperationResult method getOriginBuildInvocationId.

@Nullable
@Override
public String getOriginBuildInvocationId() {
    OriginTaskExecutionMetadata originExecutionMetadata = ctx.getOriginExecutionMetadata();
    UniqueId originBuildInvocationId = originExecutionMetadata == null ? null : originExecutionMetadata.getBuildInvocationId();
    return originBuildInvocationId == null ? null : originBuildInvocationId.asString();
}
Also used : UniqueId(org.gradle.internal.id.UniqueId) OriginTaskExecutionMetadata(org.gradle.api.internal.tasks.OriginTaskExecutionMetadata) Nullable(javax.annotation.Nullable)

Aggregations

OriginTaskExecutionMetadata (org.gradle.api.internal.tasks.OriginTaskExecutionMetadata)2 UniqueId (org.gradle.internal.id.UniqueId)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Properties (java.util.Properties)1 Nullable (javax.annotation.Nullable)1