/** * @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); }
private Map<String, Object> addVersionToOptions( final Map<String, Object> options, final Version version) { options.put("version", version.toString()); return options; }
private final void setupBinary() { try { this.workingDir = File.createTempFile("nodejs-v" + this.version, ".dir"); this.workingDir.delete(); this.workingDir.mkdirs(); extractBinary(this.workingDir); } catch (final IOException e) { throw new SmallerException("Unable to setup the node folder", e); } }
@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); } }
/** * @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); }
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()))); } } }
/** * 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 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 manifest * @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>. */ public static boolean isOutOnly(final Manifest manifest) { final Object value = manifest.getOptions().get("output:out-only"); return BooleanUtils.toBoolean(value != null ? value.toString() : "false"); }
/** * @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 configFile * @return Returns a new {@link Manifest} * @deprecated Use {@link Manifest#fromConfigFile(ConfigFile)} instead */ @Deprecated public Manifest convertConfigFileToManifest(final ConfigFile configFile) { return Manifest.fromConfigFile(configFile); }
/** * @param str * @return Return the given str as {@link Version} of {@link #UNDEFINED} if * not parsable. */ public static Version getVersion(final String str) { try { final String[] parts = str.split("\\."); final String ver = "_" + parts[0] + "_" + parts[1] + "_" + parts[2]; return valueOf(ver); } catch (final Exception e) { // In any error case return undefined } return UNDEFINED; }
/** * @param out * The output stream to write to * @param dir * The directory to zip * @throws IOException */ public static void zip(final OutputStream out, final File dir) throws IOException { final ZipOutputStream zos = new ZipOutputStream(out); recursiveZip(zos, dir, dir); zos.close(); }
private Version getVersion(final Map<String, Object> options) { final Object value = options.get("version"); return value == null ? Version.UNDEFINED : Version.getVersion(value .toString()); }
/** * @param version * The {@link Version} to compare this to * @return Returns true if this {@link Version} is at least the given * {@link Version}, false otherwise */ public boolean isAtLeast(final Version version) { final List<Version> versions = Arrays.asList(Version.values()); return versions.indexOf(this) >= versions.indexOf(version); }
/** * @see de.matrixweb.smaller.javascript.JavaScriptExecutor#addScriptFile(java.net.URL) */ @Override public void addScriptFile(final URL url) { try { addScriptSource(IOUtils.toString(url), url.getFile()); } catch (final IOException e) { throw new SmallerException("Failed to include script file", e); } }
/** * @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 manifest * @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>. */ public static boolean isSourceOnce(final Manifest manifest) { final Object value = manifest.getOptions().get("source:once"); return BooleanUtils.toBoolean(value != null ? value.toString() : "false"); }
/** * @see de.matrixweb.smaller.resource.ResourceResolver#resolve(java.lang.String) */ @Override public Resource resolve(final String path) { try { return new VFSResource(this, this.vfs.find(path.startsWith("/") ? path : '/' + path)); } catch (final IOException e) { throw new SmallerException("Failed to resolve '" + path + "'", e); } }