public Process start() throws ExecutionException { Commandline commandline = getCommandLine(); String[] shellCommandline = commandline.getShellCommandline(); if (LOGGER.isDebugEnabled()) { LOGGER.debug(PHANTOMJS_COMMAND, Arrays.asList(shellCommandline)); } ProcessBuilder processBuilder = new ProcessBuilder(shellCommandline); if (commandline.getWorkingDirectory() != null) { processBuilder.directory(commandline.getWorkingDirectory()); } try { return processBuilder.start(); } catch(IOException e) { throw new ExecutionException(UNABLE_TO_START,e); } }
public ExecutionResult executeShellCommand( File workingDirectory, String executable, String[] arguments, File output, long idCommand, Map<String, String> environments ) throws Exception { Commandline cl = createCommandline( workingDirectory, executable, arguments, idCommand, environments ); log.info( "Executing: " + cl ); log.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); log.debug( "EnvironmentVariables " + Arrays.asList( cl.getEnvironmentVariables() ) ); // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- //CommandLineUtils.StringStreamConsumer consumer = new CommandLineUtils.StringStreamConsumer(); Writer writer = new FileWriter( output ); StreamConsumer consumer = new WriterStreamConsumer( writer ); int exitCode = CommandLineUtils.executeCommandLine( cl, consumer, consumer ); writer.flush(); writer.close(); // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- return new ExecutionResult( exitCode ); }
public static int execute( Commandline cl, StreamConsumer consumer, CommandLineUtils.StringStreamConsumer stderr, ScmLogger logger ) throws ScmException { if ( logger.isInfoEnabled() ) { logger.info( "Executing: " + cl ); logger.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); } int exitCode; try { exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing command.", ex ); } return exitCode; }
public static int execute( Commandline cl, CommandLineUtils.StringStreamConsumer stdout, CommandLineUtils.StringStreamConsumer stderr, ScmLogger logger ) throws ScmException { if ( logger.isInfoEnabled() ) { logger.info( "Executing: " + cl ); logger.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); } int exitCode; try { exitCode = CommandLineUtils.executeCommandLine( cl, stdout, stderr ); } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing command.", ex ); } return exitCode; }
public static int execute( Commandline cl, StreamConsumer consumer, CommandLineUtils.StringStreamConsumer stderr, ScmLogger logger ) throws ScmException { if ( logger.isInfoEnabled() ) { logger.info( "Executing: " + cl ); logger.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); } int exitCode; try { exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing command.", ex ); } return exitCode; }
public static int execute( Commandline cl, CommandLineUtils.StringStreamConsumer stdout, CommandLineUtils.StringStreamConsumer stderr, ScmLogger logger ) throws ScmException { if ( logger.isInfoEnabled() ) { logger.info( "Executing: " + cl ); logger.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); } int exitCode; try { exitCode = CommandLineUtils.executeCommandLine( cl, stdout, stderr ); } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing command.", ex ); } return exitCode; }
private static int checkIfCleanUpIsNeeded( int exitCode, Commandline cl, StreamConsumer consumer, CommandLineUtils.StringStreamConsumer stderr, ScmLogger logger ) throws CommandLineException { if ( exitCode != 0 && stderr.getOutput() != null && stderr.getOutput().indexOf( "'svn cleanup'" ) > 0 && stderr.getOutput().indexOf( "'svn help cleanup'" ) > 0 ) { if ( logger.isInfoEnabled() ) { logger.info( "Svn command failed due to some locks in working copy. We try to run a 'svn cleanup'." ); } if ( executeCleanUp( cl.getWorkingDirectory(), consumer, stderr, logger ) == 0 ) { exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); } } return exitCode; }
private static int checkIfCleanUpIsNeeded( int exitCode, Commandline cl, StreamConsumer consumer, CommandLineUtils.StringStreamConsumer stderr, ScmLogger logger ) throws CommandLineException { if ( exitCode != 0 && stderr.getOutput() != null && stderr.getOutput().indexOf( "'svn cleanup'" ) > 0 && stderr.getOutput().indexOf( "'svn help cleanup'" ) > 0 ) { if ( logger.isInfoEnabled() ) { logger.info( "Svn command failed due to some locks in working copy. We try to run a 'svn cleanup'." ); } if ( executeCleanUp( cl.getWorkingDirectory(), consumer, stderr, logger ) == 0 ) { exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); } } return exitCode; }
public static int executeCommandline( Commandline cl, StreamConsumer consumer, CommandLineUtils.StringStreamConsumer stderr, ScmLogger logger ) throws ScmException { try { if ( logger.isInfoEnabled() ) { logger.info( "Executing: " + cl ); logger.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); } int exitcode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); if ( logger.isDebugEnabled() ) { logger.debug( "VSS Command Exit_Code: " + exitcode ); } return exitcode; } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing command.", ex ); } }
public static int executeCleanUp( File workinDirectory, StreamConsumer stdout, StreamConsumer stderr, ScmLogger logger ) throws CommandLineException { Commandline cl = new Commandline(); cl.setExecutable( "svn" ); cl.setWorkingDirectory( workinDirectory.getAbsolutePath() ); if ( logger != null ) { if ( logger.isInfoEnabled() ) { logger.info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) ); if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) { logger.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); } } } return CommandLineUtils.executeCommandLine( cl, stdout, stderr ); }
public static int executeCleanUp( File workinDirectory, StreamConsumer stdout, StreamConsumer stderr, ScmLogger logger ) throws CommandLineException { Commandline cl = new Commandline(); cl.setExecutable( "svn" ); cl.setWorkingDirectory( workinDirectory.getAbsolutePath() ); if ( logger != null ) { if ( logger.isInfoEnabled() ) { logger.info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) ); if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) { logger.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); } } } return CommandLineUtils.executeCommandLine( cl, stdout, stderr ); }
/** {@inheritDoc} */ protected ScmResult executeRemoveCommand( ScmProviderRepository repo, ScmFileSet fileSet, String message ) throws ScmException { CvsScmProviderRepository repository = (CvsScmProviderRepository) repo; Commandline cl = CvsCommandUtils.getBaseCommand( "remove", repository, fileSet ); cl.createArg().setValue( "-f" ); cl.createArg().setValue( "-l" ); List<File> files = fileSet.getFileList(); List<ScmFile> removedFiles = new ArrayList<ScmFile>(); for ( File file : files ) { String path = file.getPath().replace( '\\', '/' ); cl.createArg().setValue( path ); removedFiles.add( new ScmFile( path, ScmFileStatus.DELETED ) ); } if ( getLogger().isInfoEnabled() ) { getLogger().info( "Executing: " + cl ); getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); } return executeCvsCommand( cl, removedFiles ); }
/** {@inheritDoc} */ protected StatusScmResult executeStatusCommand( ScmProviderRepository repo, ScmFileSet fileSet ) throws ScmException { CvsScmProviderRepository repository = (CvsScmProviderRepository) repo; Commandline cl = CvsCommandUtils.getBaseCommand( "update", repository, fileSet, "-n" ); cl.createArg().setValue( "-d" ); if ( getLogger().isInfoEnabled() ) { getLogger().info( "Executing: " + cl ); getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); } return executeCvsCommand( cl ); }
/** {@inheritDoc} */ protected StatusScmResult executeStatusCommand( ScmProviderRepository repo, ScmFileSet fileSet ) throws ScmException { CvsScmProviderRepository repository = (CvsScmProviderRepository) repo; Commandline cl = CvsCommandUtils.getBaseCommand( "update", repository, fileSet, "-n" ); cl.createArg().setValue( "-d" ); if ( getLogger().isInfoEnabled() ) { getLogger().info( "Executing: " + cl ); getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); } return executeCvsCommand( cl ); }
/** * {@inheritDoc} */ public BlameScmResult executeBlameCommand( ScmProviderRepository repo, ScmFileSet fileSet, String filename ) throws ScmException { CvsScmProviderRepository repository = (CvsScmProviderRepository) repo; Commandline cl = CvsCommandUtils.getBaseCommand( "annotate", repository, fileSet ); cl.createArg().setValue( filename ); if ( getLogger().isInfoEnabled() ) { getLogger().info( "Executing: " + cl ); getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); } return executeCvsCommand( cl, repository ); }
/** * {@inheritDoc} */ public BlameScmResult executeBlameCommand( ScmProviderRepository repo, ScmFileSet fileSet, String filename ) throws ScmException { CvsScmProviderRepository repository = (CvsScmProviderRepository) repo; Commandline cl = CvsCommandUtils.getBaseCommand( "annotate", repository, fileSet ); cl.createArg().setValue( filename ); if ( getLogger().isInfoEnabled() ) { getLogger().info( "Executing: " + cl ); getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); } return executeCvsCommand( cl, repository ); }
/** {@inheritDoc} */ protected ScmResult executeBranchCommand( ScmProviderRepository repo, ScmFileSet fileSet, String branchName, String message ) throws ScmException { CvsScmProviderRepository repository = (CvsScmProviderRepository) repo; Commandline cl = CvsCommandUtils.getBaseCommand( "tag", repository, fileSet, false ); cl.createArg().setValue( "-b" ); cl.createArg().setValue( "-F" ); cl.createArg().setValue( "-c" ); cl.createArg().setValue( branchName ); if ( getLogger().isInfoEnabled() ) { getLogger().info( "Executing: " + cl ); getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); } return executeCvsCommand( cl ); }
/** {@inheritDoc} */ protected ScmResult executeBranchCommand( ScmProviderRepository repo, ScmFileSet fileSet, String branchName, String message ) throws ScmException { CvsScmProviderRepository repository = (CvsScmProviderRepository) repo; Commandline cl = CvsCommandUtils.getBaseCommand( "tag", repository, fileSet, false ); cl.createArg().setValue( "-b" ); cl.createArg().setValue( "-F" ); cl.createArg().setValue( "-c" ); cl.createArg().setValue( branchName ); if ( getLogger().isInfoEnabled() ) { getLogger().info( "Executing: " + cl ); getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); } return executeCvsCommand( cl ); }
/** {@inheritDoc} */ protected StatusScmResult executeCvsCommand( Commandline cl ) throws ScmException { CvsStatusConsumer consumer = new CvsStatusConsumer( getLogger(), cl.getWorkingDirectory() ); 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 StatusScmResult( cl.toString(), "The cvs command failed.", stderr.getOutput(), false ); } return new StatusScmResult( cl.toString(), consumer.getChangedFiles() ); } }
/** {@inheritDoc} */ protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, ScmBranch branch, String datePattern ) throws ScmException { VssScmProviderRepository repo = (VssScmProviderRepository) repository; Commandline cl = buildCmdLine( repo, fileSet, startDate, endDate ); if ( getLogger().isInfoEnabled() ) { getLogger().info( "Executing: " + cl ); getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); } VssChangeLogConsumer consumer = new VssChangeLogConsumer( repo, datePattern, getLogger() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode = VssCommandLineUtils.executeCommandline( cl, consumer, stderr, getLogger() ); if ( exitCode != 0 ) { return new ChangeLogScmResult( cl.toString(), "The vss command failed.", stderr.getOutput(), false ); } return new ChangeLogScmResult( cl.toString(), new ChangeLogSet( consumer.getModifications(), startDate, endDate ) ); }