Search in sources :

Example 1 with BuildOperationExecutor

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

the class RunAsBuildOperationBuildActionRunner method run.

@Override
public void run(final BuildAction action, final BuildController buildController) {
    BuildOperationExecutor buildOperationExecutor = buildController.getGradle().getServices().get(BuildOperationExecutor.class);
    buildOperationExecutor.run(new RunnableBuildOperation() {

        @Override
        public void run(BuildOperationContext context) {
            delegate.run(action, buildController);
            context.setResult(RESULT);
        }

        @Override
        public BuildOperationDescriptor.Builder description() {
            return BuildOperationDescriptor.displayName("Run build").details(DETAILS);
        }
    });
}
Also used : BuildOperationContext(org.gradle.internal.operations.BuildOperationContext) RunnableBuildOperation(org.gradle.internal.operations.RunnableBuildOperation) BuildOperationExecutor(org.gradle.internal.operations.BuildOperationExecutor)

Example 2 with BuildOperationExecutor

use of org.gradle.internal.operations.BuildOperationExecutor 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)

Example 3 with BuildOperationExecutor

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

the class GradleBuildController method doBuild.

private GradleInternal doBuild(final Callable<GradleInternal> build) {
    GradleInternal gradle = getGradle();
    BuildOperationExecutor buildOperationExecutor = gradle.getServices().get(BuildOperationExecutor.class);
    gradle.setBuildOperation(buildOperationExecutor.getCurrentOperation());
    try {
        // TODO:pm Move this to RunAsBuildOperationBuildActionRunner when BuildOperationWorkerRegistry scope is changed
        return workerLeaseService.withLocks(Collections.singleton(workerLeaseService.getWorkerLease()), build);
    } finally {
        gradle.setBuildOperation(null);
        state = State.Completed;
    }
}
Also used : GradleInternal(org.gradle.api.internal.GradleInternal) BuildOperationExecutor(org.gradle.internal.operations.BuildOperationExecutor)

Example 4 with BuildOperationExecutor

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

the class JvmTestSuiteBasePlugin method configureRuntimeClasspath.

@Finalize
public void configureRuntimeClasspath(@Each JvmTestSuiteBinarySpecInternal testBinary, ServiceRegistry serviceRegistry, ModelSchemaStore modelSchemaStore) {
    ArtifactDependencyResolver dependencyResolver = serviceRegistry.get(ArtifactDependencyResolver.class);
    RepositoryHandler repositories = serviceRegistry.get(RepositoryHandler.class);
    List<ResolutionAwareRepository> resolutionAwareRepositories = CollectionUtils.collect(repositories, Transformers.cast(ResolutionAwareRepository.class));
    ModelSchema<? extends JvmTestSuiteBinarySpec> schema = Cast.uncheckedCast(modelSchemaStore.getSchema(((BinarySpecInternal) testBinary).getPublicType()));
    AttributesSchemaInternal attributesSchema = serviceRegistry.get(AttributesSchemaInternal.class);
    ImmutableModuleIdentifierFactory moduleIdentifierFactory = serviceRegistry.get(ImmutableModuleIdentifierFactory.class);
    BuildOperationExecutor buildOperationExecutor = serviceRegistry.get(BuildOperationExecutor.class);
    BuildIdentity buildIdentity = serviceRegistry.get(BuildIdentity.class);
    testBinary.setRuntimeClasspath(configureRuntimeClasspath(testBinary, dependencyResolver, resolutionAwareRepositories, schema, attributesSchema, moduleIdentifierFactory, buildOperationExecutor, buildIdentity));
}
Also used : ArtifactDependencyResolver(org.gradle.api.internal.artifacts.ArtifactDependencyResolver) ImmutableModuleIdentifierFactory(org.gradle.api.internal.artifacts.ImmutableModuleIdentifierFactory) BuildIdentity(org.gradle.initialization.BuildIdentity) BinarySpecInternal(org.gradle.platform.base.internal.BinarySpecInternal) JvmBinarySpecInternal(org.gradle.jvm.internal.JvmBinarySpecInternal) JvmTestSuiteBinarySpecInternal(org.gradle.jvm.test.internal.JvmTestSuiteBinarySpecInternal) ResolutionAwareRepository(org.gradle.api.internal.artifacts.repositories.ResolutionAwareRepository) RepositoryHandler(org.gradle.api.artifacts.dsl.RepositoryHandler) AttributesSchemaInternal(org.gradle.api.internal.attributes.AttributesSchemaInternal) BuildOperationExecutor(org.gradle.internal.operations.BuildOperationExecutor) Finalize(org.gradle.model.Finalize)

Example 5 with BuildOperationExecutor

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

the class DefaultSignatureVerificationServiceFactory method create.

@Override
public SignatureVerificationService create(BuildTreeDefinedKeys keyrings, List<URI> keyServers, boolean useKeyServers) {
    boolean refreshKeys = this.refreshKeys || !useKeyServers;
    ExternalResourceRepository repository = transportFactory.createTransport("https", "https", Collections.emptyList(), redirectLocations -> {
    }).getRepository();
    PublicKeyService keyService;
    if (useKeyServers) {
        PublicKeyDownloadService keyDownloadService = new PublicKeyDownloadService(ImmutableList.copyOf(keyServers), repository);
        keyService = new CrossBuildCachingKeyService(cacheRepository, decoratorFactory, buildOperationExecutor, keyDownloadService, timeProvider, refreshKeys);
    } else {
        keyService = EmptyPublicKeyService.getInstance();
    }
    keyService = keyrings.applyTo(keyService);
    File effectiveKeyringsFile = keyrings.getEffectiveKeyringsFile();
    HashCode keyringFileHash = effectiveKeyringsFile != null && effectiveKeyringsFile.exists() ? fileHasher.hash(effectiveKeyringsFile) : NO_KEYRING_FILE_HASH;
    DefaultSignatureVerificationService delegate = new DefaultSignatureVerificationService(keyService);
    return new CrossBuildSignatureVerificationService(delegate, fileHasher, buildScopedCache, decoratorFactory, timeProvider, refreshKeys, useKeyServers, keyringFileHash);
}
Also used : Hashing(org.gradle.internal.hash.Hashing) BuildCommencedTimeProvider(org.gradle.util.internal.BuildCommencedTimeProvider) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) FileHasher(org.gradle.internal.hash.FileHasher) UncheckedException(org.gradle.internal.UncheckedException) ImmutableList(com.google.common.collect.ImmutableList) PublicKeyService(org.gradle.security.internal.PublicKeyService) BuildScopedCache(org.gradle.cache.scopes.BuildScopedCache) PGPPublicKeyRing(org.bouncycastle.openpgp.PGPPublicKeyRing) InMemoryCacheDecoratorFactory(org.gradle.cache.internal.InMemoryCacheDecoratorFactory) PublicKeyDownloadService(org.gradle.security.internal.PublicKeyDownloadService) URI(java.net.URI) Fingerprint(org.gradle.security.internal.Fingerprint) PGPException(org.bouncycastle.openpgp.PGPException) RepositoryTransportFactory(org.gradle.api.internal.artifacts.repositories.transport.RepositoryTransportFactory) Scopes(org.gradle.internal.service.scopes.Scopes) PGPSignatureList(org.bouncycastle.openpgp.PGPSignatureList) PublicKeyResultBuilder(org.gradle.security.internal.PublicKeyResultBuilder) SecuritySupport.toLongIdHexString(org.gradle.security.internal.SecuritySupport.toLongIdHexString) ExternalResourceRepository(org.gradle.internal.resource.ExternalResourceRepository) PGPSignature(org.bouncycastle.openpgp.PGPSignature) Set(java.util.Set) PGPPublicKey(org.bouncycastle.openpgp.PGPPublicKey) IOException(java.io.IOException) ServiceScope(org.gradle.internal.service.scopes.ServiceScope) HashCode(org.gradle.internal.hash.HashCode) File(java.io.File) UncheckedIOException(java.io.UncheckedIOException) List(java.util.List) BuildOperationExecutor(org.gradle.internal.operations.BuildOperationExecutor) SecuritySupport(org.gradle.security.internal.SecuritySupport) GlobalScopedCache(org.gradle.cache.scopes.GlobalScopedCache) EmptyPublicKeyService(org.gradle.security.internal.EmptyPublicKeyService) Collections(java.util.Collections) HashCode(org.gradle.internal.hash.HashCode) PublicKeyService(org.gradle.security.internal.PublicKeyService) EmptyPublicKeyService(org.gradle.security.internal.EmptyPublicKeyService) PublicKeyDownloadService(org.gradle.security.internal.PublicKeyDownloadService) File(java.io.File) ExternalResourceRepository(org.gradle.internal.resource.ExternalResourceRepository)

Aggregations

BuildOperationExecutor (org.gradle.internal.operations.BuildOperationExecutor)6 BuildOperationContext (org.gradle.internal.operations.BuildOperationContext)3 ImmutableList (com.google.common.collect.ImmutableList)2 File (java.io.File)2 GradleInternal (org.gradle.api.internal.GradleInternal)2 IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 URI (java.net.URI)1 Duration (java.time.Duration)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)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