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())); }
+ commandline.toString() + ", Error message = " + e.getMessage() );
/** * 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 ); } }
/** * 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 ); } }
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); } }
@Override public void execute(ExecutionContext context) throws MojoExecutionException, MojoFailureException { this.log.info("Starting release build."); try { InvocationRequest request = setupInvocationRequest(); Invoker invoker = setupInvoker(); InvocationResult result = invoker.execute(request); if (result.getExitCode() != 0) { CommandLineException executionException = result.getExecutionException(); if (executionException != null) { throw new MojoFailureException("Error during project build: " + executionException.getMessage(), executionException); } else { throw new MojoFailureException("Error during project build: " + result.getExitCode()); } } } catch (MavenInvocationException e) { throw new MojoFailureException(e.getMessage(), e); } }
@Override public void execute(ExecutionContext context) throws MojoExecutionException, MojoFailureException { this.log.info("Starting release build."); try { InvocationRequest request = setupInvocationRequest(); Invoker invoker = setupInvoker(); InvocationResult result = invoker.execute(request); if (result.getExitCode() != 0) { CommandLineException executionException = result.getExecutionException(); if (executionException != null) { throw new MojoFailureException("Error during project build: " + executionException.getMessage(), executionException); } else { throw new MojoFailureException("Error during project build: " + result.getExitCode()); } } } catch (MavenInvocationException e) { throw new MojoFailureException(e.getMessage(), e); } }
/** * TODO replace with calling getExecutorConfiguratorVersion * * @see org.apache.maven.continuum.installation.InstallationService#getJdkInformations(org.apache.maven.continuum.model.system.Installation) */ public List<String> getJdkInformations( Installation installation ) throws InstallationException { if ( installation == null ) { return getDefaultJdkInformations(); } if ( StringUtils.isEmpty( installation.getVarValue() ) ) { return getDefaultJdkInformations(); } try { return getJavaHomeInformations( installation.getVarValue() ); } catch ( CommandLineException e ) { throw new InstallationException( 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; }
/** * TODO replace with calling getExecutorConfiguratorVersion * * @see org.apache.maven.continuum.installation.InstallationService#getJdkInformations(org.apache.maven.continuum.model.system.Installation) */ public List<String> getJdkInformations( Installation installation ) throws InstallationException { if ( installation == null ) { return getDefaultJdkInformations(); } if ( StringUtils.isEmpty( installation.getVarValue() ) ) { return getDefaultJdkInformations(); } try { return getJavaHomeInformations( installation.getVarValue() ); } catch ( CommandLineException e ) { throw new InstallationException( e.getMessage(), e ); } }
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 ); } }
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 ); } }
/** * {@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() ); }
/** * {@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() ); }
throw new NativeBuildException( e.getMessage(), e );
/** {@inheritDoc} */ protected ScmResult executeAddCommand( ScmProviderRepository repo, ScmFileSet files, String message, boolean binary ) throws ScmException { Commandline cl = createCommandLine( (PerforceScmProviderRepository) repo, files.getBasedir(), files ); PerforceAddConsumer consumer = new PerforceAddConsumer(); 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 ) { if ( getLogger().isErrorEnabled() ) { getLogger().error( "CommandLineException " + e.getMessage(), e ); } } return new AddScmResult( cl.toString(), consumer.getAdditions() ); }
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 ); } } }
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 ); } } }
private Commandline readOpened( PerforceScmProviderRepository prepo, ScmFileSet files, PerforceStatusConsumer consumer ) { Commandline cl = createOpenedCommandLine( prepo, files.getBasedir(), actualLocation ); 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 ); } } return cl; }
private Commandline readOpened( PerforceScmProviderRepository prepo, ScmFileSet files, PerforceStatusConsumer consumer ) { Commandline cl = createOpenedCommandLine( prepo, files.getBasedir(), actualLocation ); 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 ); } } return cl; }