Search in sources :

Example 1 with FILE

use of org.gradle.internal.file.TreeType.FILE in project gradle by gradle.

the class DefaultTransformerInvocationFactory method createInvocation.

@Override
public CacheableInvocation<ImmutableList<File>> createInvocation(Transformer transformer, File inputArtifact, ArtifactTransformDependencies dependencies, TransformationSubject subject, InputFingerprinter inputFingerprinter) {
    ProjectInternal producerProject = determineProducerProject(subject);
    TransformationWorkspaceServices workspaceServices = determineWorkspaceServices(producerProject);
    UnitOfWork execution;
    if (producerProject == null) {
        execution = new ImmutableTransformerExecution(transformer, inputArtifact, dependencies, buildOperationExecutor, fileCollectionFactory, inputFingerprinter, fileSystemAccess, workspaceServices);
    } else {
        execution = new MutableTransformerExecution(transformer, inputArtifact, dependencies, buildOperationExecutor, fileCollectionFactory, inputFingerprinter, workspaceServices);
    }
    return executionEngine.createRequest(execution).withIdentityCache(workspaceServices.getIdentityCache()).getOrDeferExecution(new DeferredExecutionHandler<TransformationResult, CacheableInvocation<ImmutableList<File>>>() {

        @Override
        public CacheableInvocation<ImmutableList<File>> processCachedOutput(Try<TransformationResult> cachedOutput) {
            return CacheableInvocation.cached(mapResult(cachedOutput));
        }

        @Override
        public CacheableInvocation<ImmutableList<File>> processDeferredOutput(Supplier<Try<TransformationResult>> deferredExecution) {
            return CacheableInvocation.nonCached(() -> fireTransformListeners(transformer, subject, () -> mapResult(deferredExecution.get())));
        }

        @Nonnull
        private Try<ImmutableList<File>> mapResult(Try<TransformationResult> cachedOutput) {
            return cachedOutput.map(result -> result.resolveOutputsForInputArtifact(inputArtifact)).mapFailure(failure -> new TransformException(String.format("Execution failed for %s.", execution.getDisplayName()), failure));
        }
    });
}
Also used : InputChangesInternal(org.gradle.internal.execution.history.changes.InputChangesInternal) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier) ProjectStateRegistry(org.gradle.api.internal.project.ProjectStateRegistry) CurrentFileCollectionFingerprint(org.gradle.internal.fingerprint.CurrentFileCollectionFingerprint) Hashing(org.gradle.internal.hash.Hashing) Function(java.util.function.Function) Supplier(java.util.function.Supplier) ComponentIdentifier(org.gradle.api.artifacts.component.ComponentIdentifier) INCREMENTAL(org.gradle.internal.execution.fingerprint.InputFingerprinter.InputPropertyType.INCREMENTAL) FileValueSupplier(org.gradle.internal.execution.fingerprint.InputFingerprinter.FileValueSupplier) Provider(org.gradle.api.provider.Provider) ExecutionEngine(org.gradle.internal.execution.ExecutionEngine) ImmutableList(com.google.common.collect.ImmutableList) InputFingerprinter(org.gradle.internal.execution.fingerprint.InputFingerprinter) FileCollectionFactory(org.gradle.api.internal.file.FileCollectionFactory) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) Duration(java.time.Duration) Map(java.util.Map) DeferredExecutionHandler(org.gradle.internal.execution.DeferredExecutionHandler) WorkspaceProvider(org.gradle.internal.execution.workspace.WorkspaceProvider) Providers(org.gradle.api.internal.provider.Providers) DefaultFileNormalizationSpec(org.gradle.internal.execution.fingerprint.impl.DefaultFileNormalizationSpec) Nonnull(javax.annotation.Nonnull) OverlappingOutputs(org.gradle.internal.execution.history.OverlappingOutputs) Nullable(javax.annotation.Nullable) UnitOfWork(org.gradle.internal.execution.UnitOfWork) FileSystemLocation(org.gradle.api.file.FileSystemLocation) OverridingMethodsMustInvokeSuper(javax.annotation.OverridingMethodsMustInvokeSuper) FileSystemLocationSnapshot(org.gradle.internal.snapshot.FileSystemLocationSnapshot) InputVisitor(org.gradle.internal.execution.fingerprint.InputFingerprinter.InputVisitor) CallableBuildOperation(org.gradle.internal.operations.CallableBuildOperation) ValueSnapshot(org.gradle.internal.snapshot.ValueSnapshot) Hasher(org.gradle.internal.hash.Hasher) BuildOperationDescriptor(org.gradle.internal.operations.BuildOperationDescriptor) FileSystemAccess(org.gradle.internal.vfs.FileSystemAccess) FileCollectionFingerprinter(org.gradle.internal.execution.fingerprint.FileCollectionFingerprinter) HashCode(org.gradle.internal.hash.HashCode) File(java.io.File) CachingDisabledReason(org.gradle.internal.execution.caching.CachingDisabledReason) BuildOperationExecutor(org.gradle.internal.operations.BuildOperationExecutor) FILE(org.gradle.internal.file.TreeType.FILE) Try(org.gradle.internal.Try) CachingDisabledReasonCategory(org.gradle.internal.execution.caching.CachingDisabledReasonCategory) DIRECTORY(org.gradle.internal.file.TreeType.DIRECTORY) BuildOperationContext(org.gradle.internal.operations.BuildOperationContext) Optional(java.util.Optional) DefaultFileSystemLocation(org.gradle.api.internal.file.DefaultFileSystemLocation) NON_INCREMENTAL(org.gradle.internal.execution.fingerprint.InputFingerprinter.InputPropertyType.NON_INCREMENTAL) UnitOfWork(org.gradle.internal.execution.UnitOfWork) Nonnull(javax.annotation.Nonnull) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) Try(org.gradle.internal.Try) File(java.io.File)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 File (java.io.File)1 Duration (java.time.Duration)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Function (java.util.function.Function)1 Supplier (java.util.function.Supplier)1 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1 OverridingMethodsMustInvokeSuper (javax.annotation.OverridingMethodsMustInvokeSuper)1 ComponentIdentifier (org.gradle.api.artifacts.component.ComponentIdentifier)1 ProjectComponentIdentifier (org.gradle.api.artifacts.component.ProjectComponentIdentifier)1 FileSystemLocation (org.gradle.api.file.FileSystemLocation)1 DefaultFileSystemLocation (org.gradle.api.internal.file.DefaultFileSystemLocation)1 FileCollectionFactory (org.gradle.api.internal.file.FileCollectionFactory)1 ProjectInternal (org.gradle.api.internal.project.ProjectInternal)1 ProjectStateRegistry (org.gradle.api.internal.project.ProjectStateRegistry)1 Providers (org.gradle.api.internal.provider.Providers)1 Provider (org.gradle.api.provider.Provider)1 Try (org.gradle.internal.Try)1