Search in sources :

Example 6 with TextResource

use of org.gradle.internal.resource.TextResource 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)

Aggregations

TextResource (org.gradle.internal.resource.TextResource)6 File (java.io.File)5 ScriptSource (org.gradle.groovy.scripts.ScriptSource)4 TextResourceScriptSource (org.gradle.groovy.scripts.TextResourceScriptSource)4 BuildOperationContext (org.gradle.internal.operations.BuildOperationContext)2 RunnableBuildOperation (org.gradle.internal.operations.RunnableBuildOperation)2 FileNotFoundException (java.io.FileNotFoundException)1 URI (java.net.URI)1 UncheckedIOException (org.gradle.api.UncheckedIOException)1 ScriptHandler (org.gradle.api.initialization.dsl.ScriptHandler)1 ClassLoaderScope (org.gradle.api.internal.initialization.ClassLoaderScope)1 ScriptPlugin (org.gradle.configuration.ScriptPlugin)1 DependenciesAccessors (org.gradle.initialization.DependenciesAccessors)1 FileHasher (org.gradle.internal.hash.FileHasher)1 Hasher (org.gradle.internal.hash.Hasher)1 DependencyResolutionManagementInternal (org.gradle.internal.management.DependencyResolutionManagementInternal)1 BuildOperationDescriptor (org.gradle.internal.operations.BuildOperationDescriptor)1 ResourceLocation (org.gradle.internal.resource.ResourceLocation)1 HttpRedirectVerifier (org.gradle.internal.verifier.HttpRedirectVerifier)1