if ( workingDirectory != null && workingDirectory.exists() ) commandline.setWorkingDirectory( workingDirectory.getAbsolutePath() ); + commandline.toString() + ", Result = " + result ); + commandline.toString() + ", Error message = " + e.getMessage() );
/** * Gets the architecure for system by executing <i>rpm -E %{_arch}</i>. */ public String getArch() throws MojoExecutionException { final Commandline cl = new Commandline(); cl.setExecutable( "rpm" ); cl.addArguments( new String[] { "-E", "%{_arch}" } ); final StringStreamConsumer stdConsumer = new StringStreamConsumer(); final StreamConsumer errConsumer = new LogStreamConsumer( LogStreamConsumer.INFO, mojo.getLog() ); try { if ( mojo.getLog().isDebugEnabled() ) mojo.getLog().debug( "About to execute \'" + cl.toString() + "\'" ); final int result = CommandLineUtils.executeCommandLine( cl, stdConsumer, errConsumer ); if ( result != 0 ) throw new MojoExecutionException( "rpm -E %{_arch} returned: \'" + result + "\' executing \'" + cl.toString() + "\'" ); } catch ( CommandLineException e ) { throw new MojoExecutionException( "Unable get system architecture", e ); } return stdConsumer.getOutput().trim(); } }
/** {@inheritDoc} */ protected AddScmResult executeCvsCommand( Commandline cl, List<ScmFile> addedFiles ) throws ScmException { CvsLogListener logListener = new CvsLogListener(); try { boolean isSuccess = CvsConnection.processCommand( cl.getArguments(), cl.getWorkingDirectory().getAbsolutePath(), logListener, getLogger() ); // TODO: actually it may have partially succeeded - should we cvs update the files and parse "A " responses? if ( !isSuccess ) { return new AddScmResult( cl.toString(), "The cvs command failed.", logListener.getStdout().toString(), false ); } return new AddScmResult( cl.toString(), addedFiles ); } catch ( Exception e ) { e.printStackTrace(); return new AddScmResult( cl.toString(), "The cvs command failed.", logListener.getStdout().toString(), false ); } } }
/** {@inheritDoc} */ protected AddScmResult executeCvsCommand( Commandline cl, List<ScmFile> addedFiles ) throws ScmException { CommandLineUtils.StringStreamConsumer consumer = new CommandLineUtils.StringStreamConsumer(); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode; try { exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing command.", ex ); } // TODO: actually it may have partially succeeded - should we cvs update the files and parse "A " responses? if ( exitCode != 0 ) { return new AddScmResult( cl.toString(), "The cvs command failed.", stderr.getOutput(), false ); } return new AddScmResult( cl.toString(), addedFiles ); } }
/** {@inheritDoc} */ protected AddScmResult executeCvsCommand( Commandline cl, List<ScmFile> addedFiles ) throws ScmException { CvsLogListener logListener = new CvsLogListener(); try { boolean isSuccess = CvsConnection.processCommand( cl.getArguments(), cl.getWorkingDirectory().getAbsolutePath(), logListener, getLogger() ); // TODO: actually it may have partially succeeded - should we cvs update the files and parse "A " responses? if ( !isSuccess ) { return new AddScmResult( cl.toString(), "The cvs command failed.", logListener.getStdout().toString(), false ); } return new AddScmResult( cl.toString(), addedFiles ); } catch ( Exception e ) { e.printStackTrace(); return new AddScmResult( cl.toString(), "The cvs command failed.", logListener.getStdout().toString(), false ); } } }
/** {@inheritDoc} */ protected RemoveScmResult executeCvsCommand( Commandline cl, List<ScmFile> removedFiles ) throws ScmException { CommandLineUtils.StringStreamConsumer consumer = new CommandLineUtils.StringStreamConsumer(); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode; try { exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing command.", ex ); } // TODO: actually it may have partially succeeded - should we cvs update the files and parse "A " responses? if ( exitCode != 0 ) { return new RemoveScmResult( cl.toString(), "The cvs command failed.", stderr.getOutput(), false ); } return new RemoveScmResult( cl.toString(), removedFiles ); } }
cl.getWorkingDirectory().getAbsolutePath(), logListener, getLogger() ); return new StatusScmResult( cl.toString(), "The cvs command failed.", logListener.getStderr().toString(), false ); return new StatusScmResult( cl.toString(), "The cvs command failed.", logListener.getStderr().toString(), false ); return new StatusScmResult( cl.toString(), consumer.getChangedFiles() );
@Override protected ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) throws ScmException { GitInfoConsumer consumer = new GitInfoConsumer( getLogger(), fileSet ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); Commandline cli = createCommandLine( repository, fileSet, parameters ); int exitCode = GitCommandLineUtils.execute( cli, consumer, stderr, getLogger() ); if ( exitCode != 0 ) { return new InfoScmResult( cli.toString(), "The git rev-parse command failed.", stderr.getOutput(), false ); } return new InfoScmResult( cli.toString(), consumer.getInfoItems() ); }
/** {@inheritDoc} */ protected ScmResult executeTagCommand( ScmProviderRepository repo, ScmFileSet fileSet, String tag, ScmTagParameters scmTagParameters ) throws ScmException { if ( !fileSet.getFileList().isEmpty() ) { throw new ScmException( "This provider doesn't support tagging subsets of a directory" ); } if ( tag == null || tag.trim().length() == 0 ) { throw new ScmException( "tag must be specified" ); } if ( getLogger().isInfoEnabled() ) { getLogger().info( "Working directory: " + fileSet.getBasedir().getAbsolutePath() ); } StarteamScmProviderRepository repository = (StarteamScmProviderRepository) repo; StarteamTagConsumer consumer = new StarteamTagConsumer( getLogger() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); Commandline cl = createCommandLine( repository, fileSet.getBasedir(), tag ); int exitCode = StarteamCommandLineUtils.executeCommandline( cl, consumer, stderr, getLogger() ); if ( exitCode != 0 ) { return new TagScmResult( cl.toString(), "The starteam command failed.", stderr.getOutput(), false ); } return new TagScmResult( cl.toString(), consumer.getTaggedFiles() ); }
@Override protected ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) throws ScmException { GitInfoConsumer consumer = new GitInfoConsumer( getLogger(), fileSet ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); Commandline cli = createCommandLine( repository, fileSet, parameters ); int exitCode = GitCommandLineUtils.execute( cli, consumer, stderr, getLogger() ); if ( exitCode != 0 ) { return new InfoScmResult( cli.toString(), "The git rev-parse command failed.", stderr.getOutput(), false ); } return new InfoScmResult( cli.toString(), consumer.getInfoItems() ); }
/** {@inheritDoc} */ protected ScmResult executeTagCommand( ScmProviderRepository repo, ScmFileSet fileSet, String tag, ScmTagParameters scmTagParameters ) throws ScmException { if ( !fileSet.getFileList().isEmpty() ) { throw new ScmException( "This provider doesn't support tagging subsets of a directory" ); } if ( tag == null || tag.trim().length() == 0 ) { throw new ScmException( "tag must be specified" ); } if ( getLogger().isInfoEnabled() ) { getLogger().info( "Working directory: " + fileSet.getBasedir().getAbsolutePath() ); } StarteamScmProviderRepository repository = (StarteamScmProviderRepository) repo; StarteamTagConsumer consumer = new StarteamTagConsumer( getLogger() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); Commandline cl = createCommandLine( repository, fileSet.getBasedir(), tag ); int exitCode = StarteamCommandLineUtils.executeCommandline( cl, consumer, stderr, getLogger() ); if ( exitCode != 0 ) { return new TagScmResult( cl.toString(), "The starteam command failed.", stderr.getOutput(), false ); } return new TagScmResult( cl.toString(), consumer.getTaggedFiles() ); }
/** {@inheritDoc} */ protected CheckOutScmResult executeCvsCommand( Commandline cl ) throws ScmException { CvsCheckOutConsumer consumer = new CvsCheckOutConsumer( getLogger() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode; try { exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing command.", ex ); } if ( exitCode != 0 ) { return new CheckOutScmResult( cl.toString(), "The cvs command failed.", stderr.getOutput(), false ); } return new CheckOutScmResult( cl.toString(), consumer.getCheckedOutFiles() ); } }
/** {@inheritDoc} */ protected StatusScmResult executeStatusCommand( ScmProviderRepository repo, ScmFileSet fileSet ) throws ScmException { if ( getLogger().isInfoEnabled() ) { getLogger().info( "Working directory: " + fileSet.getBasedir().getAbsolutePath() ); } if ( fileSet.getFileList().size() != 0 ) { throw new ScmException( "This provider doesn't support checking status of a subsets of a directory" ); } StarteamScmProviderRepository repository = (StarteamScmProviderRepository) repo; StarteamStatusConsumer consumer = new StarteamStatusConsumer( getLogger(), fileSet.getBasedir() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); Commandline cl = createCommandLine( repository, fileSet ); int exitCode = StarteamCommandLineUtils.executeCommandline( cl, consumer, stderr, getLogger() ); if ( exitCode != 0 ) { return new StatusScmResult( cl.toString(), "The starteam command failed.", stderr.getOutput(), false ); } return new StatusScmResult( cl.toString(), consumer.getChangedFiles() ); }
/** {@inheritDoc} */ protected UpdateScmResult executeCvsCommand( Commandline cl ) throws ScmException { CvsUpdateConsumer consumer = new CvsUpdateConsumer( getLogger() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode; try { exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing command.", ex ); } if ( exitCode != 0 ) { return new UpdateScmResult( cl.toString(), "The cvs command failed.", stderr.getOutput(), false ); } return new UpdateScmResult( cl.toString(), consumer.getUpdatedFiles() ); }
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); "Executing: " + cl.getWorkingDirectory().getAbsolutePath() + ">>" + cl.toString() ); return new UpdateScmResult( cl.toString(), "The cleartool command failed.", stderr.getOutput(), false ); return new UpdateScmResult( cl.toString(), consumer.getUpdatedFiles() );
/** {@inheritDoc} */ protected ListScmResult executeCvsCommand( Commandline cl ) throws ScmException { CvsListConsumer consumer = new CvsListConsumer( getLogger() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode; try { exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing command.", ex ); } if ( exitCode != 0 ) { return new ListScmResult( cl.toString(), "The cvs command failed.", stderr.getOutput(), false ); } return new ListScmResult( cl.toString(), consumer.getEntries() ); } }
public BlameScmResult executeBlameCommand( ScmProviderRepository repo, ScmFileSet workingDirectory, String filename ) throws ScmException { if ( getLogger().isDebugEnabled() ) { getLogger().debug( "executing blame command..." ); } Commandline cl = createCommandLine( workingDirectory.getBasedir(), filename ); ClearCaseBlameConsumer consumer = new ClearCaseBlameConsumer( getLogger() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode; try { if ( getLogger().isDebugEnabled() ) { getLogger().debug( "Executing: " + cl.getWorkingDirectory().getAbsolutePath() + ">>" + cl.toString() ); } exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing cvs command.", ex ); } if ( exitCode != 0 ) { return new BlameScmResult( cl.toString(), "The cleartool command failed.", stderr.getOutput(), false ); } return new BlameScmResult( cl.toString(), consumer.getLines() ); }
/** {@inheritDoc} */ protected BranchScmResult executeCvsCommand( Commandline cl ) throws ScmException { int exitCode; CvsBranchConsumer consumer = new CvsBranchConsumer( getLogger() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); try { exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing command.", ex ); } if ( exitCode != 0 ) { return new BranchScmResult( cl.toString(), "The cvs branch command failed.", stderr.getOutput(), false ); } return new BranchScmResult( cl.toString(), consumer.getTaggedFiles() ); } }
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); "Executing: " + cl.getWorkingDirectory().getAbsolutePath() + ">>" + cl.toString() ); return new UpdateScmResult( cl.toString(), "The cleartool command failed.", stderr.getOutput(), false ); return new UpdateScmResult( cl.toString(), consumer.getUpdatedFiles() );
/** {@inheritDoc} */ protected TagScmResult executeCvsCommand( Commandline cl ) throws ScmException { int exitCode; CvsTagConsumer consumer = new CvsTagConsumer( getLogger() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); try { exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing command.", ex ); } if ( exitCode != 0 ) { // TODO: Improve this error message return new TagScmResult( cl.toString(), "The cvs tag command failed.", stderr.getOutput(), false ); } return new TagScmResult( cl.toString(), consumer.getTaggedFiles() ); } }