Search in sources :

Example 1 with TaskOutputsInternal

use of org.gradle.api.internal.TaskOutputsInternal in project gradle by gradle.

the class ResolveTaskArtifactStateTaskExecuter method execute.

@Override
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    Timer clock = Time.startTimer();
    TaskProperties taskProperties = DefaultTaskProperties.resolve(propertyWalker, resolver, task);
    context.setTaskProperties(taskProperties);
    TaskArtifactState taskArtifactState = repository.getStateFor(task, taskProperties);
    TaskOutputsInternal outputs = task.getOutputs();
    context.setTaskArtifactState(taskArtifactState);
    outputs.setHistory(taskArtifactState.getExecutionHistory());
    LOGGER.debug("Putting task artifact state for {} into context took {}.", task, clock.getElapsed());
    try {
        executer.execute(task, state, context);
    } finally {
        outputs.setHistory(null);
        context.setTaskArtifactState(null);
        context.setTaskProperties(null);
        LOGGER.debug("Removed task artifact state for {} from context.");
    }
}
Also used : Timer(org.gradle.internal.time.Timer) TaskArtifactState(org.gradle.api.internal.changedetection.TaskArtifactState) TaskOutputsInternal(org.gradle.api.internal.TaskOutputsInternal)

Example 2 with TaskOutputsInternal

use of org.gradle.api.internal.TaskOutputsInternal in project gradle by gradle.

the class TaskExecution method execute.

@Override
public WorkOutput execute(ExecutionRequest executionRequest) {
    FileCollection previousFiles = executionRequest.getPreviouslyProducedOutputs().<FileCollection>map(previousOutputs -> new PreviousOutputFileCollection(task, fileCollectionFactory, previousOutputs)).orElseGet(fileCollectionFactory::empty);
    TaskOutputsInternal outputs = task.getOutputs();
    outputs.setPreviousOutputFiles(previousFiles);
    try {
        WorkResult didWork = executeWithPreviousOutputFiles(executionRequest.getInputChanges().orElse(null));
        return new WorkOutput() {

            @Override
            public WorkResult getDidWork() {
                return didWork;
            }

            @Override
            public Object getOutput() {
                throw new UnsupportedOperationException();
            }
        };
    } finally {
        outputs.setPreviousOutputFiles(null);
    }
}
Also used : IncrementalTaskInputsTaskAction(org.gradle.api.internal.project.taskfactory.IncrementalTaskInputsTaskAction) CurrentFileCollectionFingerprint(org.gradle.internal.fingerprint.CurrentFileCollectionFingerprint) LoggerFactory(org.slf4j.LoggerFactory) RELEASE_PROJECT_LOCKS(org.gradle.internal.work.AsyncWorkTracker.ProjectLockRetention.RELEASE_PROJECT_LOCKS) ClassLoaderHierarchyHasher(org.gradle.internal.hash.ClassLoaderHierarchyHasher) WorkValidationContext(org.gradle.internal.execution.WorkValidationContext) UncheckedException(org.gradle.internal.UncheckedException) InputFingerprinter(org.gradle.internal.execution.fingerprint.InputFingerprinter) Duration(java.time.Duration) Map(java.util.Map) DeprecationLogger(org.gradle.internal.deprecation.DeprecationLogger) FileOperations(org.gradle.api.internal.file.FileOperations) FileCollectionInternal(org.gradle.api.internal.file.FileCollectionInternal) GeneratedSubclasses(org.gradle.api.internal.GeneratedSubclasses) StopActionException(org.gradle.api.tasks.StopActionException) StopExecutionException(org.gradle.api.tasks.StopExecutionException) Collection(java.util.Collection) SnapshotTaskInputsBuildOperationType(org.gradle.api.internal.tasks.SnapshotTaskInputsBuildOperationType) ValueSnapshot(org.gradle.internal.snapshot.ValueSnapshot) RELEASE_AND_REACQUIRE_PROJECT_LOCKS(org.gradle.internal.work.AsyncWorkTracker.ProjectLockRetention.RELEASE_AND_REACQUIRE_PROJECT_LOCKS) BuildOperationDescriptor(org.gradle.internal.operations.BuildOperationDescriptor) Collectors(java.util.stream.Collectors) CachingDisabledReason(org.gradle.internal.execution.caching.CachingDisabledReason) SnapshotTaskInputsBuildOperationResult(org.gradle.api.internal.tasks.SnapshotTaskInputsBuildOperationResult) Contextual(org.gradle.internal.exceptions.Contextual) UncheckedIOException(java.io.UncheckedIOException) List(java.util.List) BuildOperationExecutor(org.gradle.internal.operations.BuildOperationExecutor) Optional(java.util.Optional) TaskProperties(org.gradle.api.internal.tasks.properties.TaskProperties) CachingState(org.gradle.internal.execution.caching.CachingState) ReservedFileSystemLocationRegistry(org.gradle.internal.file.ReservedFileSystemLocationRegistry) InputChangesAwareTaskAction(org.gradle.api.internal.tasks.InputChangesAwareTaskAction) LazilyInitializedFileCollection(org.gradle.api.internal.file.collections.LazilyInitializedFileCollection) TaskOutputsInternal(org.gradle.api.internal.TaskOutputsInternal) InputChangesInternal(org.gradle.internal.execution.history.changes.InputChangesInternal) MultiCauseException(org.gradle.internal.exceptions.MultiCauseException) OutputSnapshotter(org.gradle.internal.execution.OutputSnapshotter) DefaultMultiCauseException(org.gradle.internal.exceptions.DefaultMultiCauseException) InputFilePropertySpec(org.gradle.api.internal.tasks.properties.InputFilePropertySpec) OutputFilePropertySpec(org.gradle.api.internal.tasks.properties.OutputFilePropertySpec) FileCollection(org.gradle.api.file.FileCollection) BuildOperationRef(org.gradle.internal.operations.BuildOperationRef) ArrayList(java.util.ArrayList) TaskExecutionContext(org.gradle.api.internal.tasks.TaskExecutionContext) SnapshotUtil(org.gradle.internal.snapshot.SnapshotUtil) Lists(com.google.common.collect.Lists) Sync(org.gradle.api.tasks.Sync) RunnableBuildOperation(org.gradle.internal.operations.RunnableBuildOperation) FileCollectionFactory(org.gradle.api.internal.file.FileCollectionFactory) ExecutionHistoryStore(org.gradle.internal.execution.history.ExecutionHistoryStore) InputPropertySpec(org.gradle.api.internal.tasks.properties.InputPropertySpec) FileSystemSnapshot(org.gradle.internal.snapshot.FileSystemSnapshot) WorkspaceProvider(org.gradle.internal.execution.workspace.WorkspaceProvider) ImmutableSortedMap(com.google.common.collect.ImmutableSortedMap) OverlappingOutputs(org.gradle.internal.execution.history.OverlappingOutputs) Nullable(javax.annotation.Nullable) UnitOfWork(org.gradle.internal.execution.UnitOfWork) ImmutableSortedSet(com.google.common.collect.ImmutableSortedSet) TaskInternal(org.gradle.api.internal.TaskInternal) IncrementalInputsTaskAction(org.gradle.api.internal.project.taskfactory.IncrementalInputsTaskAction) Logger(org.slf4j.Logger) ListenerManager(org.gradle.internal.event.ListenerManager) Iterator(java.util.Iterator) TypeValidationContext(org.gradle.internal.reflect.validation.TypeValidationContext) File(java.io.File) AsyncWorkTracker(org.gradle.internal.work.AsyncWorkTracker) DefaultTaskValidationContext(org.gradle.api.internal.tasks.DefaultTaskValidationContext) InputParameterUtils(org.gradle.api.internal.tasks.properties.InputParameterUtils) CacheableTask(org.gradle.api.tasks.CacheableTask) BuildOperationContext(org.gradle.internal.operations.BuildOperationContext) DeprecationMessageBuilder(org.gradle.internal.deprecation.DeprecationMessageBuilder) Collections(java.util.Collections) Copy(org.gradle.api.tasks.Copy) LazilyInitializedFileCollection(org.gradle.api.internal.file.collections.LazilyInitializedFileCollection) FileCollection(org.gradle.api.file.FileCollection) TaskOutputsInternal(org.gradle.api.internal.TaskOutputsInternal)

Aggregations

TaskOutputsInternal (org.gradle.api.internal.TaskOutputsInternal)2 ImmutableSortedMap (com.google.common.collect.ImmutableSortedMap)1 ImmutableSortedSet (com.google.common.collect.ImmutableSortedSet)1 Lists (com.google.common.collect.Lists)1 File (java.io.File)1 UncheckedIOException (java.io.UncheckedIOException)1 Duration (java.time.Duration)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Nullable (javax.annotation.Nullable)1 FileCollection (org.gradle.api.file.FileCollection)1 GeneratedSubclasses (org.gradle.api.internal.GeneratedSubclasses)1 TaskInternal (org.gradle.api.internal.TaskInternal)1 TaskArtifactState (org.gradle.api.internal.changedetection.TaskArtifactState)1