commandline = new Commandline(); if ( customShell != null ) commandline.setShell( customShell ); commandline.setExecutable( executable ); result = CommandLineUtils.executeCommandLine( commandline, stdOut, stdErr ); if ( logger != null ) + commandline.toString() + ", Error message = " + e.getMessage() ); setPid( commandline.getPid() );
verifyShellState(); String[] environment = getEnvironmentVariables(); process = Runtime.getRuntime().exec( getCommandline(), environment, workingDir ); throw new CommandLineException( "Working directory \"" + workingDir.getPath() + "\" does not exist!" ); throw new CommandLineException( "Path \"" + workingDir.getPath() + "\" does not specify a directory." ); throw new CommandLineException( "Error while executing process.", ex );
private void syncLabel( ScmProviderRepository repo, ScmFileSet files, String tag, PerforceTagConsumer consumer ) { Commandline cl = createLabelsyncCommandLine( (PerforceScmProviderRepository) repo, files.getBasedir(), files, tag ); try { if ( getLogger().isDebugEnabled() ) { getLogger().debug( PerforceScmProvider.clean( "Executing: " + cl.toString() ) ); } CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer(); int exitCode = CommandLineUtils.executeCommandLine( cl, consumer, err ); if ( exitCode != 0 ) { String cmdLine = CommandLineUtils.toString( cl.getCommandline() ); StringBuilder msg = new StringBuilder( "Exit code: " + exitCode + " - " + err.getOutput() ); msg.append( '\n' ); msg.append( "Command line was:" + cmdLine ); throw new CommandLineException( msg.toString() ); } } catch ( CommandLineException e ) { if ( getLogger().isErrorEnabled() ) { getLogger().error( "CommandLineException " + e.getMessage(), e ); } } }
throws ScmException Commandline shell = new Commandline(); shell.setWorkingDirectory( workingDirectory.getBasedir() ); shell.setExecutable( "si" ); shell.createArg().setValue( "connect" ); shell.createArg().setValue( "--hostname=" + iRepo.getHost() ); shell.createArg().setValue( "--batch" ); shell.createArg().setValue( "--password=" + iRepo.getPassword() ); CommandLineUtils.StringStreamConsumer shellConsumer = new CommandLineUtils.StringStreamConsumer(); getLogger().debug( "Executing: " + CommandLineUtils.toString( shell.getCommandline() ) ); int exitCode = CommandLineUtils.executeCommandLine( shell, shellConsumer, shellConsumer ); if ( exitCode != 0 ) getLogger().error( "Command Line Connect Exception: " + cle.getMessage() ); throw new ScmException( "Can't login to integrity. Message : " + cle.getMessage() );
final String[] args = arguments.toArray(new String[arguments.size()]); Commandline commandline = new Commandline(); commandline.setWorkingDirectory(project.getBuild().getDirectory()); commandline.setExecutable(Paths.get(System.getProperty("java.home"), "bin", "java").toString()); commandline.addEnvironment("CLASSPATH", cp); commandline.addArguments(args); log.debug("Arguments: " + CommandLineUtils.toString(args)); result = CommandLineUtils.executeCommandLine(commandline, new StreamConsumer() { @Override throw new MojoExecutionException(e.getMessage(), e);
private CharSequence resolveExternalJreVersion() { Artifact pluginArtifact = mojoExecution.getMojoDescriptor().getPluginDescriptor().getPluginArtifact(); pluginArtifact.getFile(); Commandline commandLine = new Commandline(); commandLine.setExecutable( new File( javaHome, "bin/java" ).getAbsolutePath() ); commandLine.createArg().setValue( "-cp" ); commandLine.createArg().setFile( pluginArtifact.getFile() ); commandLine.createArg().setValue( SystemPropertyPrinter.class.getName() ); commandLine.createArg().setValue( "java.version" ); final StringBuilder actualJreVersion = new StringBuilder(); StreamConsumer consumer = new StreamConsumer() { public void consumeLine( String line ) { actualJreVersion.append( line ); } }; try { CommandLineUtils.executeCommandLine( commandLine, consumer, null ); } catch ( CommandLineException e ) { getLog().warn( e.getMessage() ); } return actualJreVersion; }
try Commandline commandline = new Commandline(); if ( StringUtils.isNotEmpty( path ) ) commandline.addEnvironment( executorConfigurator.getEnvVar(), path ); commandline.addEnvironment( key, value ); final List<String> cliOutput = new ArrayList<String>(); int result = CommandLineUtils.executeCommandLine( commandline, new StreamConsumer() throw new InstallationException( e.getMessage(), e );
throws CommandLineException Commandline commandline = new Commandline(); commandline.setExecutable( executable ); commandline.addArguments( new String[]{"-version"} ); final List<String> cliOutput = new ArrayList<String>(); int result = CommandLineUtils.executeCommandLine( commandline, new StreamConsumer() if ( result != 0 ) throw new CommandLineException( "cli to get JAVA_HOME informations return code " + result );
Commandline cmd = new Commandline(); cmd.setExecutable( javadocExe.getAbsolutePath() ); cmd.setWorkingDirectory( javadocExe.getParentFile() ); cmd.createArg().setValue( "-J-version" ); CommandLineUtils.StringStreamConsumer err = new JavadocOutputStreamConsumer(); int exitCode = CommandLineUtils.executeCommandLine( cmd, out, err ); StringBuilder msg = new StringBuilder( "Exit code: " + exitCode + " - " + err.getOutput() ); msg.append( '\n' ); msg.append( "Command line was:" + CommandLineUtils.toString( cmd.getCommandline() ) ); throw new CommandLineException( msg.toString() ); if ( StringUtils.isNotEmpty( err.getOutput() ) ) return JavaVersion.parse( extractJavadocVersion( err.getOutput() ) ); else if ( StringUtils.isNotEmpty( out.getOutput() ) )
protected void forkJavaVM(String[] args) throws MojoExecutionException { try { final Commandline commandLine = new Commandline(); commandLine.setExecutable(getJavaExecutable().getAbsolutePath()); commandLine.setWorkingDirectory(workingDirectory.getAbsolutePath()); commandLine.addArguments(args); final StreamConsumer stdout = new StreamConsumer() { public void consumeLine(String line) { getLog().info(line); } }; final StreamConsumer stderr = new StreamConsumer() { public void consumeLine(String line) { getLog().error(line); } }; int ret = CommandLineUtils.executeCommandLine(commandLine, stdout, stderr); if (ret != 0) { throw new MojoExecutionException("RubyRunMain exited with status code: " + ret); } } catch (CommandLineException ex) { throw new MojoExecutionException(ex.getMessage(), ex); } }
throws CommandLineException, InterruptedException Commandline cli = new Commandline(); cli.setExecutable( "mvn" ); cli.createArg().setLine( "--settings \'" + settings.getAbsolutePath() + "\'" ); throw new CommandLineException( "Process failed: \n" + cli.toString() + "\nProcess exit status was: " + status + "Process output:\n" + consoleOutput ); throw new CommandLineException( "Process failed: \n" + cli.toString() + "\nBUILD ERROR token found\n" + "Process output:\n" + consoleOutput ); throw new CommandLineException( "Process failed: \n" + cli.toString() + "\nFATAL ERROR token found\n" + "Process output:\n" + consoleOutput );
/** * {@inheritDoc} */ protected ScmResult executeRemoveCommand( ScmProviderRepository repo, ScmFileSet files, String message ) throws ScmException { Commandline cl = createCommandLine( (PerforceScmProviderRepository) repo, files.getBasedir(), files ); PerforceRemoveConsumer consumer = new PerforceRemoveConsumer(); try { CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer(); int exitCode = CommandLineUtils.executeCommandLine( cl, consumer, err ); if ( exitCode != 0 ) { String cmdLine = CommandLineUtils.toString( cl.getCommandline() ); StringBuilder msg = new StringBuilder( "Exit code: " + exitCode + " - " + err.getOutput() ); msg.append( '\n' ); msg.append( "Command line was:" + cmdLine ); throw new CommandLineException( msg.toString() ); } } catch ( CommandLineException e ) { throw new ScmException( "CommandLineException " + e.getMessage(), e ); } return new RemoveScmResult( cl.toString(), consumer.getRemovals() ); }
command.createArg().setValue( "where" ); command.createArg().setValue( filepath ); if ( logger.isDebugEnabled() ) logger.debug( PerforceScmProvider.clean( "Executing: " + command.toString() ) ); Process proc = command.execute(); if ( logger.isErrorEnabled() ) logger.error( line ); logger.error( e ); throw new RuntimeException( e.getLocalizedMessage() );
private void createLabel( ScmProviderRepository repo, ScmFileSet files, String tag, PerforceTagConsumer consumer, boolean lock ) Commandline cl = createLabelCommandLine( (PerforceScmProviderRepository) repo, files.getBasedir() ); DataOutputStream dos = null; InputStreamReader isReader = null; try if ( getLogger().isDebugEnabled() ) getLogger().debug( PerforceScmProvider.clean( "Executing: " + cl.toString() ) ); Process proc = cl.execute(); OutputStream out = proc.getOutputStream(); dos = new DataOutputStream( out ); String label = createLabelSpecification( (PerforceScmProviderRepository) repo, tag, lock ); if ( getLogger().isDebugEnabled() ) getLogger().debug( "LabelSpec: " + NEWLINE + label ); if ( getLogger().isErrorEnabled() ) getLogger().error( "CommandLineException " + e.getMessage(), e );
command.createArg().setValue( "info" ); if ( getLogger().isDebugEnabled() ) getLogger().debug( PerforceScmProvider.clean( "Executing: " + command.toString() ) ); Process proc = command.execute(); isReader = new InputStreamReader( proc.getInputStream() ); BufferedReader br = new BufferedReader( isReader ); if ( getLogger().isDebugEnabled() ) getLogger().debug( "Cannot find client." ); throw new ScmException( e.getLocalizedMessage() );
try { final Commandline cl = createBaseCommandline(messages); final Arg outPutFileArg = cl.createArg(); final Arg dartFileArg = cl.createArg(); final File dartOutputFile = createOutputFileArgument(messages, outPutFileArg, dartSourceFile); createDartFileArgument(messages, dartFileArg, dartSourceFile); messages.add("debug#" + cl.toString()); final StreamConsumer output = new WriterStreamConsumer(writer); final int returnValue = CommandLineUtils.executeCommandLine(cl, output, output); messages.add("error#dart2js error: " + e.getMessage()); getLog().error("dart2js error", e);
getLog().debug( CommandLineUtils.toString( cmd.getCommandline() ).replaceAll( "'", "" ) ); if ( debug ) cmdLine = CommandLineUtils.toString( cmd.getCommandline() ).replaceAll( "'", "" ); cmdLine = JavadocUtil.hideProxyPassword( cmdLine, settings ); CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer(); CommandLineUtils.StringStreamConsumer out = new CommandLineUtils.StringStreamConsumer(); try int exitCode = CommandLineUtils.executeCommandLine( cmd, out, err ); String output = ( StringUtils.isEmpty( out.getOutput() ) ? null : '\n' + out.getOutput().trim() ); cmdLine = CommandLineUtils.toString( cmd.getCommandline() ).replaceAll( "'", "" ); cmdLine = JavadocUtil.hideProxyPassword( cmdLine, settings ); throw new MavenReportException( "Unable to execute javadoc command: " + e.getMessage(), e );
/** * TODO replace with calling getExecutorConfiguratorVersion * * @see org.apache.maven.continuum.installation.InstallationService#getDefaultJdkInformations() */ public List<String> getDefaultJdkInformations() throws InstallationException { try { Properties systemEnvVars = CommandLineUtils.getSystemEnvVars( false ); String javaHome = (String) systemEnvVars.get( "JAVA_HOME" ); // olamy : JAVA_HOME can not exists with a mac user if ( StringUtils.isEmpty( javaHome ) ) { return getJavaHomeInformations( System.getProperty( "java.home" ) ); } return getJavaHomeInformations( javaHome ); } catch ( IOException e ) { throw new InstallationException( e.getMessage(), e ); } catch ( CommandLineException e ) { throw new InstallationException( e.getMessage(), e ); } }
private AddMvnCommandResult getResult(InvocationResult invocationResult, List<Dependency> dependencies) { if (invocationResult.getExitCode() != 0) { if (invocationResult.getExecutionException() != null) { return AddMvnCommandResult.error(invocationResult.getExecutionException().getMessage()); } StringBuilder errorMsgBuilder = new StringBuilder("Could not resolve dependencies for:"); for (Dependency dependency : dependencies) { errorMsgBuilder .append("\n").append(dependency.groupId).append(" : ") .append(dependency.artifactId).append(" : ") .append(dependency.version).append(" : ") .append(dependency.type); } return AddMvnCommandResult.error(errorMsgBuilder.toString()); } return AddMvnCommandResult.success(transformFromMavenRepoToKernelRepo(mavenBuildClasspath(), jarsFromRepo())); }
private void executeCommandLine( Commandline cli ) throws AppBooterServiceException { Process p = null; if ( streamConsumer == null ) { streamConsumer = new StreamConsumer() { public void consumeLine( String line ) { getLogger().info( line ); } }; } try { p = cli.execute(); outPumper = new StreamPumper( p.getInputStream(), streamConsumer ); errPumper = new StreamPumper( p.getErrorStream(), streamConsumer ); outPumper.setPriority( Thread.MIN_PRIORITY + 1 ); errPumper.setPriority( Thread.MIN_PRIORITY + 1 ); outPumper.start(); errPumper.start(); } catch ( CommandLineException e ) { throw new AppBooterServiceException( "Failed to execute plexus application: " + e.getMessage(), e ); } }