List of usage examples for org.apache.commons.exec DefaultExecutor setExitValue
public void setExitValue(final int value)
From source file:org.nanoko.coffee.mill.mojos.reporting.JsDocMojo.java
private void generateJSDOC() throws MavenReportException { if (skipJSDOC) { getLog().info("JSDoc report generation skipped"); return;/*from w w w. ja v a 2s.c o m*/ } File jsdocExec = ExecUtils.findExecutableInPath("jsdoc"); if (jsdocExec == null) { getLog().error("Cannot build jsdoc report - jsdoc not in the system path, the report is ignored."); return; } else { getLog().info("Invoking jsdoc : " + jsdocExec.getAbsolutePath()); getLog().info("Output directory : " + getOutputDirectory()); } File out = new File(getOutputDirectory()); out.mkdirs(); CommandLine cmdLine = CommandLine.parse(jsdocExec.getAbsolutePath()); // Destination cmdLine.addArgument("--destination"); cmdLine.addArgument(out.getAbsolutePath()); if (jsdocIncludePrivate) { cmdLine.addArgument("--private"); } File input = new File(project.getBuild().getDirectory(), project.getBuild().getFinalName() + ".js"); if (!input.exists()) { throw new MavenReportException("Cannot find the project's artifact : " + input.getAbsolutePath()); } cmdLine.addArgument(input.getAbsolutePath()); DefaultExecutor executor = new DefaultExecutor(); executor.setWorkingDirectory(project.getBasedir()); executor.setExitValue(0); try { getLog().info("Executing " + cmdLine.toString()); executor.execute(cmdLine); } catch (IOException e) { throw new MavenReportException("Error during jsdoc report generation", e); } }
From source file:org.nanoko.coffee.mill.processors.JpegTranProcessor.java
private void optimize(File file) throws ProcessorException { File dir = file.getParentFile(); // Build command line CommandLine cmdLine = CommandLine.parse(jpegTranExec.getAbsolutePath()); if (verbose) { cmdLine.addArgument("-verbose"); }/* w w w .j a v a 2s . co m*/ cmdLine.addArgument("-copy"); cmdLine.addArgument("none"); cmdLine.addArgument("-optimize"); cmdLine.addArgument("-outfile"); cmdLine.addArgument("out.jpeg"); cmdLine.addArgument(file.getName()); DefaultExecutor executor = new DefaultExecutor(); executor.setWorkingDirectory(dir); executor.setExitValue(0); try { getLog().info("Executing " + cmdLine.toString()); executor.execute(cmdLine); // Overwrite the original file File out = new File(dir, "out.jpeg"); if (out.exists()) { FileUtils.copyFile(new File(dir, "out.jpeg"), file); } else { throw new IOException("Output file not found : " + out.getAbsolutePath()); } getLog().info(file.getName() + " optimized"); } catch (IOException e) { throw new ProcessorException("Error during JPG optimization of " + file.getAbsolutePath(), e); } }
From source file:org.nanoko.coffee.mill.processors.OptiPNGProcessor.java
private void optimize(File file) throws ProcessorException { File dir = file.getParentFile(); // Build command line CommandLine cmdLine = CommandLine.parse(optiPNGExec.getAbsolutePath()); cmdLine.addArgument(file.getName()); if (verbose) { cmdLine.addArgument("-v"); }// w ww. j av a 2 s .com cmdLine.addArgument("-o" + level); DefaultExecutor executor = new DefaultExecutor(); executor.setWorkingDirectory(dir); executor.setExitValue(0); try { getLog().info("Executing " + cmdLine.toString()); executor.execute(cmdLine); getLog().info(file.getName() + " optimized"); } catch (IOException e) { throw new ProcessorException("Error during PNG optimization of " + file.getAbsolutePath(), e); } }
From source file:org.nanoko.coffeemill.mojos.processresources.OptiJpegMojo.java
private void optimize(File file) throws WatchingException { File dir = file.getParentFile(); // Build command line CommandLine cmdLine = CommandLine.parse(jpegTranExec.getAbsolutePath()); if (verbose) { cmdLine.addArgument("-verbose"); }//from w w w . j av a2 s .c om cmdLine.addArgument("-copy"); cmdLine.addArgument("none"); cmdLine.addArgument("-optimize"); cmdLine.addArgument("-outfile"); cmdLine.addArgument("__out.jpeg"); cmdLine.addArgument(file.getName()); DefaultExecutor executor = new DefaultExecutor(); executor.setWorkingDirectory(dir); executor.setExitValue(0); try { getLog().info("Executing " + cmdLine.toString()); executor.execute(cmdLine); // Overwrite the original file File out = new File(dir, "__out.jpeg"); getLog().info("output jpeg file : " + out.getAbsolutePath()); if (out.exists()) { FileUtils.copyFile(out, file); FileUtils.deleteQuietly(out); } else { throw new IOException("Output file not found : " + out.getAbsolutePath()); } getLog().info(file.getName() + " optimized"); } catch (IOException e) { throw new WatchingException("Error during JPG optimization of " + file.getAbsolutePath(), e); } }
From source file:org.nanoko.coffeemill.mojos.processresources.OptiPngMojo.java
private void optimize(File file) throws WatchingException { File dir = file.getParentFile(); // Build command line CommandLine cmdLine = CommandLine.parse(optiPNGExec.getAbsolutePath()); cmdLine.addArgument(file.getName()); if (verbose) { cmdLine.addArgument("-v"); }//from w ww . j a v a 2 s.com cmdLine.addArgument("-o" + level); DefaultExecutor executor = new DefaultExecutor(); executor.setWorkingDirectory(dir); executor.setExitValue(0); try { getLog().info("Executing " + cmdLine.toString()); executor.execute(cmdLine); getLog().info(file.getName() + " optimized"); } catch (IOException e) { throw new WatchingException("Error during PNG optimization of " + file.getAbsolutePath(), e); } }
From source file:org.nanoko.playframework.mojo.AbstractPlay2SimpleMojo.java
public void execute() throws MojoExecutionException, MojoFailureException { String line = this.getPlay2().getAbsolutePath(); CommandLine cmdLine = CommandLine.parse(line); this.addCommandLineArgs(cmdLine); DefaultExecutor executor = new DefaultExecutor(); if (this.timeout > 0) { ExecuteWatchdog watchdog = new ExecuteWatchdog(this.timeout); executor.setWatchdog(watchdog);/*w w w. j a v a2 s . c om*/ } executor.setExitValue(0); executor.setWorkingDirectory(this.project.getBasedir()); try { executor.execute(cmdLine, this.getEnvironment()); } catch (Exception e) { this.onExecutionException(e); } }
From source file:org.nanoko.playframework.mojo.Play2DebugMojo.java
public void execute() throws MojoExecutionException { String line = getPlay2().getAbsolutePath(); CommandLine cmdLine = CommandLine.parse(line); cmdLine.addArgument("debug"); cmdLine.addArguments(getPlay2SystemPropertiesArguments(), false); cmdLine.addArgument("run"); DefaultExecutor executor = new DefaultExecutor(); // As where not linked to a project, we can't set the working directory. // So it will use the directory where mvn was launched. executor.setExitValue(0); try {/*from w w w . ja v a2 s . c o m*/ executor.execute(cmdLine, getEnvironment()); } catch (IOException e) { // Ignore. } }
From source file:org.nanoko.playframework.mojo.Play2StartMojo.java
public void execute() throws MojoExecutionException { String line = getPlay2().getAbsolutePath(); CommandLine cmdLine = CommandLine.parse(line); cmdLine.addArguments(getPlay2SystemPropertiesArguments(), false); cmdLine.addArgument("start"); System.out.println(cmdLine.toString()); DefaultExecutor executor = new DefaultExecutor(); // As where not linked to a project, we can't set the working directory. // So it will use the directory where mvn was launched. executor.setExitValue(0); try {//w ww .j a v a 2s.co m executor.execute(cmdLine, getEnvironment()); } catch (IOException e) { // Ignore. } }
From source file:org.nanoko.playframework.mojo.Play2StopMojo.java
public void execute() throws MojoExecutionException { String line = getPlay2().getAbsolutePath(); CommandLine cmdLine = CommandLine.parse(line); cmdLine.addArguments(getPlay2SystemPropertiesArguments(), false); cmdLine.addArgument("stop"); System.out.println(cmdLine.toString()); DefaultExecutor executor = new DefaultExecutor(); // As where not linked to a project, we can't set the working directory. // So it will use the directory where mvn was launched. executor.setExitValue(0); try {/*from w w w . j a v a 2 s . c o m*/ executor.execute(cmdLine, getEnvironment()); } catch (IOException e) { // Ignore. } }
From source file:org.nanoko.playframework.mojo.Play2TestMojo.java
public void execute() throws MojoExecutionException { if (isSkipExecution()) { getLog().info("Test phase skipped"); return;/* www . ja va 2 s . c o m*/ } if (noTestFound()) { getLog().info("Test phase skipped - no tests found"); return; } String line = getPlay2().getAbsolutePath(); CommandLine cmdLine = CommandLine.parse(line); cmdLine.addArguments(getPlay2SystemPropertiesArguments(), false); cmdLine.addArgument("test"); DefaultExecutor executor = new DefaultExecutor(); if (timeout > 0) { ExecuteWatchdog watchdog = new ExecuteWatchdog(timeout); executor.setWatchdog(watchdog); } executor.setWorkingDirectory(project.getBasedir()); executor.setExitValue(0); try { executor.execute(cmdLine, getEnvironment()); } catch (IOException e) { if (testFailureIgnore) { getLog().error("Test execution failures ignored"); } else { throw new MojoExecutionException("Error during compilation", e); } } }