List of usage examples for org.apache.commons.exec CommandLine CommandLine
public CommandLine(final CommandLine other)
From source file:org.silverpeas.core.viewer.service.SwfToolManager.java
@Override public synchronized void init() { // SwfTools settings for (final Map.Entry<String, String> entry : System.getenv().entrySet()) { if ("path".equalsIgnoreCase(entry.getKey())) { try { CommandLine commandLine = new CommandLine("pdf2swf"); commandLine.addArgument("--version"); ExternalExecution.exec(commandLine, Config.init().doNotDisplayErrorTrace()); isActivated = true;// w w w . ja v a 2 s. c om } catch (final Exception e) { // SwfTool is not installed SilverLogger.getLogger(this).warn("pdf2swf is not installed"); } } } }
From source file:org.silverpeas.core.viewer.util.JsonPdfUtil.java
static CommandLine buildJsonPdfCommandLine(File inputFile, File outputFile) { Map<String, File> files = new HashMap<String, File>(2); files.put("inputFile", inputFile); files.put("outputFile", outputFile); CommandLine commandLine = new CommandLine("pdf2json"); commandLine.addArgument("${inputFile}", false); commandLine.addArguments(PDF_TO_JSON_COMMON_PARAMS, false); commandLine.addArgument("${outputFile}", false); commandLine.setSubstitutionMap(files); return commandLine; }
From source file:org.silverpeas.core.viewer.util.SwfUtil.java
static CommandLine buildPdfToSwfCommandLine(final String endingCommand, File inputFile, File outputFile) { Map<String, File> files = new HashMap<>(2); files.put("inputFile", inputFile); files.put("outputFile", outputFile); CommandLine commandLine = new CommandLine("pdf2swf"); commandLine.addArgument("${inputFile}", false); commandLine.addArgument(OUTPUT_COMMAND); commandLine.addArgument("${outputFile}", false); commandLine.addArguments(TO_SWF_ENDING_COMMAND, false); if (StringUtil.isDefined(endingCommand)) { commandLine.addArguments(endingCommand, false); }// ww w.j a v a2s. com commandLine.setSubstitutionMap(files); return commandLine; }
From source file:org.silverpeas.media.video.ffmpeg.FFmpegUtil.java
static CommandLine buildFFmpegThumbnailExtractorCommandLine(File inputFile, File outputFile, int seconds) { Map<String, File> files = new HashMap<String, File>(2); files.put("inputFile", inputFile); files.put("outputFile", outputFile); CommandLine commandLine = new CommandLine("ffmpeg"); // Time of extract in seconds commandLine.addArgument("-ss", false); commandLine.addArgument(Integer.toString(seconds), false); commandLine.addArgument("-i", false); commandLine.addArgument("${inputFile}", false); // Only one frame commandLine.addArgument("-vframes", false); commandLine.addArgument("1", false); // Resize/scale of output picture keeping aspect ratio commandLine.addArgument("-vf", false); commandLine.addArgument("scale=600:-1", false); commandLine.addArgument("${outputFile}", false); commandLine.setSubstitutionMap(files); return commandLine; }
From source file:org.silverpeas.viewer.util.SwfUtil.java
static CommandLine buildPdfToSwfCommandLine(final String endingCommand, File inputFile, File outputFile) { Map<String, File> files = new HashMap<String, File>(2); files.put("inputFile", inputFile); files.put("outputFile", outputFile); CommandLine commandLine = new CommandLine("pdf2swf"); commandLine.addArgument("${inputFile}", false); commandLine.addArgument(OUTPUT_COMMAND); commandLine.addArgument("${outputFile}", false); commandLine.addArguments(TO_SWF_ENDING_COMMAND, false); if (StringUtil.isDefined(endingCommand)) { commandLine.addArguments(endingCommand, false); }/*w w w. j a v a 2 s . c o m*/ commandLine.setSubstitutionMap(files); return commandLine; }
From source file:org.silverpeas.viewer.util.SwfUtil.java
static CommandLine buildPdfDocumentInfoCommandLine(File file) { Map<String, File> files = new HashMap<String, File>(1); files.put("file", file); CommandLine commandLine = new CommandLine("pdf2swf"); commandLine.addArgument("-qq"); commandLine.addArgument("${file}", false); commandLine.addArgument("--info"); commandLine.setSubstitutionMap(files); return commandLine; }
From source file:org.silverpeas.viewer.util.SwfUtil.java
static CommandLine buildSwfToImageCommandLine(File inputFile, File outputFile) { Map<String, File> files = new HashMap<String, File>(2); files.put("inputFile", inputFile); files.put("outputFile", outputFile); CommandLine commandLine = new CommandLine("swfrender"); commandLine.addArgument("${inputFile}", false); commandLine.addArgument(OUTPUT_COMMAND); commandLine.addArgument("${outputFile}", false); commandLine.setSubstitutionMap(files); return commandLine; }
From source file:org.sonar.plugins.ideainspections.IdeaExecutor.java
/** * Execute Idea Inspections and return the generated XML report. * @return File a directory with the inspection results or null if the project was not found *///from w w w .j a v a2s.c o m public File execute() { if (!project.exists()) { LOG.info("Cannot find: " + project + ". Skipping..."); return null; } TimeProfiler profiler = new TimeProfiler().start("Execute Idea Inspections " + IdeaVersion.getVersion()); CommandLine cmdLine = new CommandLine(jdkHome + "/bin/java"); cmdLine.addArgument("-XX:-UseGCOverheadLimit"); cmdLine.addArgument("-Xmx" + memory); cmdLine.addArgument("-XX:MaxPermSize=" + permSize); cmdLine.addArgument("-Xbootclasspath/a:" + bootJar.getPath()); cmdLine.addArgument("-Djdk." + jdkName + "=" + jdkHome); cmdLine.addArgument("-cp"); cmdLine.addArgument(buildClassPath()); cmdLine.addArgument(IDEA_MAIN_CLASS_NAME); cmdLine.addArgument("inspect"); cmdLine.addArgument(project.getPath()); cmdLine.addArgument(profile.getPath()); cmdLine.addArgument(reportDirectory.getPath()); DefaultExecutor executor = new DefaultExecutor(); executor.setExitValue(0); //ExecuteWatchdog watchdog = new ExecuteWatchdog(60000); //executor.setWatchdog(watchdog); try { LOG.info("About to execute: \n" + cmdLine.toString()); executor.execute(cmdLine); } catch (Exception e) { throw new SonarException("Can not execute Idea Inspections", e); } finally { profiler.stop(); } return reportDirectory; }
From source file:org.sonatype.sisu.bl.support.DefaultDropwizardBundle.java
@Override protected void startApplication() { File bundleDirectory = getBundleDirectory(); List<String> javaOptions = getConfiguration().getJavaOptions(); List<String> javaAgentOptions = getJavaAgentOptions(); CommandLine cmdLine = new CommandLine(new File(System.getProperty("java.home"), "/bin/java")); if (javaAgentOptions.size() > 0) { cmdLine.addArguments(javaAgentOptions.toArray(new String[javaAgentOptions.size()])); }/*from w w w . j a va 2s. co m*/ if (javaOptions.size() > 0) { cmdLine.addArguments(javaOptions.toArray(new String[javaOptions.size()])); } cmdLine.addArgument("-jar").addArgument(getJarName()).addArguments(getConfiguration().arguments()) .addArgument("config.yaml"); log.debug("Launching: {}", cmdLine.toString()); DefaultExecutor executor = new DefaultExecutor(); executor.setWorkingDirectory(bundleDirectory); executor.setWatchdog(watchdog = new ExecuteWatchdog(Time.minutes(5).toMillis())); try { executor.setStreamHandler(streamHandler = new PumpStreamHandler( new FileOutputStream(new File(bundleDirectory, "output.log")))); executor.execute(cmdLine, new DefaultExecuteResultHandler()); } catch (IOException e) { throw Throwables.propagate(e); } }
From source file:org.spiffyui.maven.plugins.GwtCompileMojo.java
@Override public void execute() throws MojoExecutionException, MojoFailureException { Properties p = project.getProperties(); if (skip || "pom".equals(project.getPackaging())) { getLog().debug("GWT compilation is skipped"); return;/* w ww. j av a2 s . co m*/ } if (!outputDirectory.exists()) { outputDirectory.mkdirs(); } else if (!force) { String name = gwtModuleName; if (name.endsWith(InitializeMojo.SPIFFY_TMP_SUFFIX)) { name = name.substring(0, name.length() - InitializeMojo.SPIFFY_TMP_SUFFIX.length()); } if (Math.max(getNewestModifiedTime(resources, -1), getNewestModifiedTime(new File(compileSourceRoots.get(0)), -1)) < getOldestModifiedTime( new File(outputDirectory, name), -1)) { /* Then the GWT build is up to date and we can skip it */ getLog().info("GWT files are up to date. Skipping GWT build."); return; } } CommandLine cmd = new CommandLine("java"); ClassBuilder cb = new ClassBuilder(project); cb.add(p.getProperty("spiffyui.generated-source")); cb.add(resources.getAbsolutePath()); for (String sourceRoot : compileSourceRoots) { cb.add(sourceRoot); } cmd.addArgument("-cp").addArgument(cb.toString()).addArgument(extraJvmArgs) .addArgument("com.google.gwt.dev.Compiler").addArgument("-gen").addArgument(gen.getAbsolutePath()) .addArgument("-logLevel").addArgument(logLevel).addArgument("-style").addArgument(style) .addArgument("-war").addArgument(outputDirectory.getAbsolutePath()).addArgument("-localWorkers") .addArgument(String.valueOf(getLocalWorkers())); // optional advanced arguments if (enableAssertions) { cmd.addArgument("-ea"); } if (draftCompile) { cmd.addArgument("-draftCompile"); } if (validateOnly) { cmd.addArgument("-validateOnly"); } if (treeLogger) { cmd.addArgument("-treeLogger"); } if (disableClassMetadata) { cmd.addArgument("-XdisableClassMetadata"); } if (disableCastChecking) { cmd.addArgument("-XdisableCastChecking"); } if (strict) { cmd.addArgument("-strict"); } if (soycDetailed) { cmd.addArgument("-XsoycDetailed"); } if (optimizationLevel >= 0) { cmd.addArgument("-optimize").addArgument(Integer.toString(optimizationLevel)); } if (extraParam || compileReport) { getLog().debug("create extra directory "); if (!extra.exists()) { extra.mkdirs(); } cmd.addArgument("-extra").addArgument(extra.getAbsolutePath()); } else { getLog().debug("NOT create extra directory "); } if (compileReport) { cmd.addArgument("-compileReport"); } if (workDir != null) { cmd.addArgument("-workDir").addArgument(String.valueOf(workDir)); } cmd.addArgument(gwtModuleName); try { DefaultExecutor executor = new DefaultExecutor(); getLog().debug("Exec: " + cmd.toString()); int ret = executor.execute(cmd, CommandLineUtils.getSystemEnvVars()); if (ret != 0) { throw new MojoExecutionException("Exec failed: " + Integer.toString(ret)); } } catch (IOException e) { throw new MojoExecutionException(e.getMessage()); } moveJSDir(); }