Search in sources :

Example 6 with BuildOperationExecutor

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

the class RootOfNestedBuildTree method run.

@Override
public <T> T run(Function<? super BuildTreeLifecycleController, T> action) {
    final GradleInternal gradle = getBuildController().getGradle();
    ServiceRegistry services = gradle.getServices();
    BuildOperationExecutor executor = services.get(BuildOperationExecutor.class);
    return executor.call(new CallableBuildOperation<T>() {

        @Override
        public T call(BuildOperationContext context) {
            gradle.addBuildListener(new InternalBuildAdapter() {

                @Override
                public void settingsEvaluated(Settings settings) {
                    buildName = settings.getRootProject().getName();
                }
            });
            T result = action.apply(buildTreeLifecycleController);
            context.setResult(new RunNestedBuildBuildOperationType.Result() {
            });
            return result;
        }

        @Override
        public BuildOperationDescriptor.Builder description() {
            return BuildOperationDescriptor.displayName("Run nested build").details(new RunNestedBuildBuildOperationType.Details() {

                @Override
                public String getBuildPath() {
                    return gradle.getIdentityPath().getPath();
                }
            });
        }
    });
}
Also used : BuildOperationContext(org.gradle.internal.operations.BuildOperationContext) GradleInternal(org.gradle.api.internal.GradleInternal) ServiceRegistry(org.gradle.internal.service.ServiceRegistry) InternalBuildAdapter(org.gradle.internal.InternalBuildAdapter) Settings(org.gradle.api.initialization.Settings) BuildOperationExecutor(org.gradle.internal.operations.BuildOperationExecutor)

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