/** * This is a migration method for global to processor options. Currently used * by the merge-processor which gets the 'source:once' option from the global * scope. */ private Map<String, Object> injectGlobalOptionsFallback( final Version version, final Manifest manifest, final String name, final Map<String, Object> options) { final Map<String, Object> copy = new HashMap<String, Object>(options); copy.put("version", version.toString()); if (manifest != null) { if ("merge".equals(name)) { copy.put("source", GlobalOptions.isSourceOnce(manifest) ? "once" : ""); } } return copy; }
/** * @param processor * The processor name to get the task options for * @return Returns a map with options */ public Map<String, Object> getOptionsFor(final String processor) { if (this.parsedOptions == null) { this.parsedOptions = new HashMap<String, Map<String, Object>>(); if (this.optionsDefinition != null) { for (final String byProcessor : this.optionsDefinition.split(";")) { StringTokenizer tokenizer = new StringTokenizer(byProcessor, ":"); final String name = tokenizer.nextToken(); this.parsedOptions.put(name, new HashMap<String, Object>()); for (final String option : tokenizer.nextToken().split(",")) { tokenizer = new StringTokenizer(option, "="); this.parsedOptions.get(name).put(tokenizer.nextToken(), tokenizer.nextToken()); } } } } final Map<String, Object> options = getProcessOrOptions(processor); if (!options.containsKey("source-maps")) { options.put("source-maps", Boolean.toString(GlobalOptions .isGenerateSourceMaps(getProcessOrOptions("global") .get("source-maps")))); } return options; }
private void writeResults(final VFS vfs, final File outputDir, final Manifest manifest) throws IOException { if (!GlobalOptions.isOutOnly(manifest)) { vfs.exportFS(outputDir); } for (final ProcessDescription processDescription : manifest .getProcessDescriptions()) { if (processDescription.getOutputFile() != null) { FileUtils .writeStringToFile( new File(outputDir, processDescription.getOutputFile()), VFSUtils.readToString(vfs.find(processDescription .getOutputFile()))); } } }
/** * @param resolver * @param task * @return Returns a list of input resources resolved from the given * {@link Task} * @throws IOException */ @Deprecated public static Resources createResourceGroup(final ResourceResolver resolver, final Task task) throws IOException { return createResourceGroupImpl1(resolver, new SourceMerger(GlobalOptions.isSourceOnce(task)), new ArrayList<String>(Arrays.asList(task.getIn()))); }
/** * @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 void execute1_0(final VFS vfs, final ResourceResolver resolver, final Resources resources, final List<ProcessorOptions> entries, final Task task) throws IOException { for (final ProcessorOptions entry : entries) { for (final Type type : Type.values()) { final List<Resource> res = resources.getByType(type); if (entry.processor.supportsType(type)) { LOGGER.info("Executing processor {} for type {}", entry.name, type); final List<Resource> results = new ArrayList<Resource>(); // TODO: SourceMerger should not be required here final ResourceGroup group = new ResourceGroup(res, new SourceMerger( GlobalOptions.isSourceOnce(task))); group.apply(vfs, entry.processor, entry.options); results.addAll(group.getResources()); resources.replace(res, results); } } } }