Search in sources :

Example 1 with ResourceLocation

use of org.gradle.internal.resource.ResourceLocation in project gradle by gradle.

the class UriScriptSource method getFileName.

public String getFileName() {
    ResourceLocation location = resource.getLocation();
    File sourceFile = location.getFile();
    URI sourceUri = location.getURI();
    return sourceFile != null ? sourceFile.getPath() : sourceUri.toString();
}
Also used : ResourceLocation(org.gradle.internal.resource.ResourceLocation) File(java.io.File) URI(java.net.URI)

Example 2 with ResourceLocation

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

File (java.io.File)2 ResourceLocation (org.gradle.internal.resource.ResourceLocation)2 URI (java.net.URI)1 ScriptSource (org.gradle.groovy.scripts.ScriptSource)1 BuildOperationContext (org.gradle.internal.operations.BuildOperationContext)1 BuildOperationDescriptor (org.gradle.internal.operations.BuildOperationDescriptor)1 RunnableBuildOperation (org.gradle.internal.operations.RunnableBuildOperation)1 TextResource (org.gradle.internal.resource.TextResource)1