Search in sources :

Example 11 with RunnableBuildOperation

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

the class BuildOperationScriptPlugin method apply.

@Override
public void apply(final Object target) {
    TextResource resource = getSource().getResource();
    if (resource.isContentCached() && resource.getHasEmptyContent()) {
        // no operation, if there is no script code provided
        decorated.apply(target);
    } else {
        userCodeApplicationContext.apply(getSource().getShortDisplayName(), userCodeApplicationId -> buildOperationExecutor.run(new RunnableBuildOperation() {

            @Override
            public void run(BuildOperationContext context) {
                decorated.apply(target);
                context.setResult(OPERATION_RESULT);
            }

            @Override
            public BuildOperationDescriptor.Builder description() {
                final ScriptSource source = getSource();
                final ResourceLocation resourceLocation = source.getResource().getLocation();
                final File file = resourceLocation.getFile();
                String name = "Apply " + source.getShortDisplayName();
                final String displayName = name + " to " + target;
                return BuildOperationDescriptor.displayName(displayName).name(name).details(new OperationDetails(file, resourceLocation, ConfigurationTargetIdentifier.of(target), userCodeApplicationId));
            }
        }));
    }
}
Also used : TextResource(org.gradle.internal.resource.TextResource) BuildOperationContext(org.gradle.internal.operations.BuildOperationContext) BuildOperationDescriptor(org.gradle.internal.operations.BuildOperationDescriptor) ResourceLocation(org.gradle.internal.resource.ResourceLocation) RunnableBuildOperation(org.gradle.internal.operations.RunnableBuildOperation) ScriptSource(org.gradle.groovy.scripts.ScriptSource) File(java.io.File)

Example 12 with RunnableBuildOperation

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

the class NotifyingBuildLoader method load.

@Override
public void load(final SettingsInternal settings, final GradleInternal gradle) {
    final String buildPath = gradle.getIdentityPath().toString();
    buildOperationExecutor.call(new CallableBuildOperation<Void>() {

        @Override
        public BuildOperationDescriptor.Builder description() {
            // noinspection Convert2Lambda
            return BuildOperationDescriptor.displayName("Load projects").progressDisplayName("Loading projects").details(new LoadProjectsBuildOperationType.Details() {

                @Override
                public String getBuildPath() {
                    return buildPath;
                }
            });
        }

        @Override
        public Void call(BuildOperationContext context) {
            buildLoader.load(settings, gradle);
            context.setResult(createOperationResult(gradle, buildPath));
            return null;
        }
    });
    buildOperationExecutor.run(new RunnableBuildOperation() {

        @Override
        public void run(BuildOperationContext context) {
            gradle.getBuildListenerBroadcaster().projectsLoaded(gradle);
            context.setResult(PROJECTS_LOADED_OP_RESULT);
        }

        @Override
        public BuildOperationDescriptor.Builder description() {
            // noinspection Convert2Lambda
            return BuildOperationDescriptor.displayName(gradle.contextualize("Notify projectsLoaded listeners")).details(new NotifyProjectsLoadedBuildOperationType.Details() {

                @Override
                public String getBuildPath() {
                    return buildPath;
                }
            });
        }
    });
}
Also used : BuildOperationContext(org.gradle.internal.operations.BuildOperationContext) RunnableBuildOperation(org.gradle.internal.operations.RunnableBuildOperation)

Aggregations

BuildOperationContext (org.gradle.internal.operations.BuildOperationContext)12 RunnableBuildOperation (org.gradle.internal.operations.RunnableBuildOperation)12 File (java.io.File)8 BuildOperationDescriptor (org.gradle.internal.operations.BuildOperationDescriptor)3 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 List (java.util.List)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 Action (org.gradle.api.Action)2 FileCollection (org.gradle.api.file.FileCollection)2 ImmutableList (com.google.common.collect.ImmutableList)1 LinkedHashMultimap (com.google.common.collect.LinkedHashMultimap)1 Multimap (com.google.common.collect.Multimap)1 Queues (com.google.common.collect.Queues)1 Sets (com.google.common.collect.Sets)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 FilenameFilter (java.io.FilenameFilter)1 URI (java.net.URI)1 Collection (java.util.Collection)1