/** * @param extensions * The extensions to filter for * @return Returns a list of input files filtered by given extensions */ public final String[] getIn(final String... extensions) { final List<String> list = new ArrayList<String>(); for (final String s : getIn()) { for (final String ext : extensions) { if (s.endsWith(ext)) { list.add(s); } } } return list.toArray(new String[list.size()]); }
/** * @param task * @return Returns <code>true</code> if the <code>once</code> option for the * <code>source</code> processor is set to <code>true</code> or * <code>yes</code>. * @deprecated */ @Deprecated public static boolean isSourceOnce(final Task task) { final Object value = task.getOptionsFor("source").get("once"); return value == null ? false : BooleanUtils.toBoolean(value.toString()); }
@Deprecated private List<ProcessorOptions> setupProcessors(final Version version, final Task task) { final List<ProcessorOptions> list = new ArrayList<Pipeline.ProcessorOptions>(); boolean hasJsMerger = false; boolean hasCssMerger = false; final String processors = task.getProcessor(); LOGGER.info("Building processor chain: {}", processors); for (final String name : processors.split(",")) { final Processor processor = this.processorFactory.getProcessor(name); if (processor != null) { hasJsMerger |= processor instanceof MergingProcessor && processor.supportsType(Type.JS); hasCssMerger |= processor instanceof MergingProcessor && processor.supportsType(Type.CSS); list.add(new ProcessorOptions(name, processor, addVersionToOptions( task.getOptionsFor(name), version))); } } // Since version 1.0.0 no implicit merger if (version == Version.UNDEFINED) { if (!hasJsMerger) { list.add(0, createTypeMerger(Type.JS)); } if (!hasCssMerger) { list.add(0, createTypeMerger(Type.CSS)); } } return list; }
@Deprecated private boolean validate(final Task task) { if (CollectionUtils.exists( CollectionUtils.getCardinalityMap( CollectionUtils.collect(Arrays.asList(task.getOut()), new Transformer() { @Override public Object transform(final Object input) { return FilenameUtils.getExtension(input.toString()); } })).values(), new Predicate() { @Override public boolean evaluate(final Object object) { return ((Integer) object).intValue() > 1; } })) { throw new SmallerException("Each output type must exist only once"); } final String[] processors = task.getProcessor().toLowerCase().split(","); boolean cssembedFound = false; for (final String processor : processors) { if (processor.equals("cssembed")) { cssembedFound = true; } else if (processor.equals("yuicompressor") && cssembedFound) { throw new SmallerException("yuiCompressor must run before cssembed"); } } return true; }
/** * @param processor * @param in * @param out * @param optionsDefinition */ public Task(final String processor, final String in, final String out, final String optionsDefinition) { this(processor, in, out); setOptionsDefinition(optionsDefinition); }
/** * @param processor * @param in * @param out * @param options * @deprecated Replaced by {@link Task#Task(String, String, String, String)} */ @Deprecated public Task(final String processor, final String in, final String out, final Set<Task.Options> options) { this(processor, in, out); setOptions(options); }
/** * @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; }
@Deprecated private Result prepareResult(final VFS vfs, final ResourceResolver resolver, final Task task) throws IOException { final Resources resources = new Resources(); for (final String out : task.getOut()) { LOGGER.info("Preparing output file: {}", out); final String ext = FilenameUtils.getExtension(out); final VFile file = findLastModified(vfs.find("/"), ext); if (file != null) { final VFile target = vfs.find('/' + out); LOGGER.info("Copy '{}' -> '{}'", file, target); VFSUtils.copy(file, target); resources.addResource(resolver.resolve(target.getPath())); } } return new Result(resources); }
/** * @param options * the optionsDefinition to set * @deprecated Replaced by the more flexible * {@link #setOptionsDefinition(String)} */ @Deprecated public final void setOptions(final Set<Task.Options> options) { if (options != null && options.contains(Options.OUT_ONLY)) { setOptionsDefinition("output:out-only=true"); } }
/** * @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 task * @return Returns <code>true</code> if the <code>out-only</code> option for * the <code>output</code> processor is set to <code>true</code> or * <code>yes</code>. * @deprecated */ @Deprecated public static boolean isOutOnly(final Task task) { final Object value = task.getOptionsFor("output").get("out-only"); return value == null ? false : BooleanUtils.toBoolean(value.toString()); }
/** * @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); }