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));
}
}));
}
}
Aggregations