Search in sources :

Example 1 with CvsBranchConsumer

use of org.apache.maven.scm.provider.cvslib.command.branch.CvsBranchConsumer in project maven-scm by apache.

the class CvsExeBranchCommand method executeCvsCommand.

/**
 * {@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());
}
Also used : ScmException(org.apache.maven.scm.ScmException) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) CvsBranchConsumer(org.apache.maven.scm.provider.cvslib.command.branch.CvsBranchConsumer) BranchScmResult(org.apache.maven.scm.command.branch.BranchScmResult) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException)

Example 2 with CvsBranchConsumer

use of org.apache.maven.scm.provider.cvslib.command.branch.CvsBranchConsumer in project maven-scm by apache.

the class CvsJavaBranchCommand method executeCvsCommand.

/**
 * {@inheritDoc}
 */
protected BranchScmResult executeCvsCommand(Commandline cl) throws ScmException {
    CvsLogListener logListener = new CvsLogListener();
    CvsBranchConsumer consumer = new CvsBranchConsumer(getLogger());
    try {
        boolean isSuccess = CvsConnection.processCommand(cl.getArguments(), cl.getWorkingDirectory().getAbsolutePath(), logListener, getLogger());
        if (!isSuccess) {
            return new BranchScmResult(cl.toString(), "The cvs branch command failed.", logListener.getStderr().toString(), false);
        }
        BufferedReader stream = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(logListener.getStdout().toString().getBytes())));
        String line;
        while ((line = stream.readLine()) != null) {
            consumer.consumeLine(line);
        }
    } catch (Exception e) {
        getLogger().error(e.getMessage(), e);
        return new BranchScmResult(cl.toString(), "The cvs branch command failed.", logListener.getStderr().toString(), false);
    }
    return new BranchScmResult(cl.toString(), consumer.getTaggedFiles());
}
Also used : CvsLogListener(org.apache.maven.scm.provider.cvslib.cvsjava.util.CvsLogListener) InputStreamReader(java.io.InputStreamReader) ByteArrayInputStream(java.io.ByteArrayInputStream) BufferedReader(java.io.BufferedReader) CvsBranchConsumer(org.apache.maven.scm.provider.cvslib.command.branch.CvsBranchConsumer) BranchScmResult(org.apache.maven.scm.command.branch.BranchScmResult) ScmException(org.apache.maven.scm.ScmException)

Aggregations

ScmException (org.apache.maven.scm.ScmException)2 BranchScmResult (org.apache.maven.scm.command.branch.BranchScmResult)2 CvsBranchConsumer (org.apache.maven.scm.provider.cvslib.command.branch.CvsBranchConsumer)2 BufferedReader (java.io.BufferedReader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStreamReader (java.io.InputStreamReader)1 CvsLogListener (org.apache.maven.scm.provider.cvslib.cvsjava.util.CvsLogListener)1 CommandLineException (org.codehaus.plexus.util.cli.CommandLineException)1 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)1