/** * @param version * The spec version to execute * @param resolver * The {@link ResourceResolver} to use for resource resolving * @param task * The input {@link Task} * @return Returns the resolved input resources * @throws IOException */ public static Resources createResourceGroup(final Version version, final ResourceResolver resolver, final Task task) throws IOException { if (version.isAtLeast(Version._1_0_0)) { // Since version 1.1.0 no multi-resources return createResourceGroupImpl0(resolver, new SourceMerger(GlobalOptions.isSourceOnce(task)), new ArrayList<String>(Arrays.asList(task.getIn()))); } return createResourceGroup(resolver, task); }
@Deprecated private Result execute(final Version version, final VFS vfs, final ResourceResolver resolver, final Resources resources, final Task task) { try { validate(task); final List<ProcessorOptions> entries = setupProcessors(version, task); if (version.isAtLeast(Version._1_0_0)) { execute1_0(vfs, resolver, resources, entries, task); } else { execute0_0(vfs, resources, entries); } LOGGER.info("Finished executing pipeline"); return prepareResult(vfs, resolver, task); } catch (final IOException e) { throw new SmallerException("Failed to run processor chain", e); } }
/** * @see de.matrixweb.smaller.resource.Processor#execute(de.matrixweb.vfs.VFS, * de.matrixweb.smaller.resource.Resource, java.util.Map) */ @Override public Resource execute(final VFS vfs, final Resource resource, final Map<String, Object> options) throws IOException { // Version 1.0.0 handling if (getVersion(options).isAtLeast(Version._1_0_0)) { try { if (!(resource instanceof ResourceGroup) && resource != null && FilenameUtils.isExtension(resource.getPath(), "json")) { return executeSimpleMerge(vfs, resource, options); } return executeComplexMerge(vfs, resource, options); } catch (final IOException e) { throw new SmallerException("Failed to merge files", e); } } final VFile snapshot = vfs.stack(); try { final VFile file = vfs.find(resource.getPath()); VFSUtils.write(file, resource.getContents()); return resource.getResolver().resolve(file.getPath()); } catch (final IOException e) { vfs.rollback(snapshot); throw e; } }