Search in sources :

Example 1 with CvsListConsumer

use of org.apache.maven.scm.provider.cvslib.command.list.CvsListConsumer in project maven-scm by apache.

the class CvsJavaListCommand method executeCvsCommand.

/**
 * {@inheritDoc}
 */
protected ListScmResult executeCvsCommand(Commandline cl) throws ScmException {
    CvsLogListener logListener = new CvsLogListener();
    CvsListConsumer consumer = new CvsListConsumer(getLogger());
    try {
        boolean isSuccess = CvsConnection.processCommand(cl.getArguments(), cl.getWorkingDirectory().getAbsolutePath(), logListener, getLogger());
        if (!isSuccess) {
            return new ListScmResult(cl.toString(), "The cvs 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) {
        e.printStackTrace();
        return new ListScmResult(cl.toString(), "The cvs command failed.", logListener.getStderr().toString(), false);
    }
    return new ListScmResult(cl.toString(), consumer.getEntries());
}
Also used : CvsLogListener(org.apache.maven.scm.provider.cvslib.cvsjava.util.CvsLogListener) InputStreamReader(java.io.InputStreamReader) CvsListConsumer(org.apache.maven.scm.provider.cvslib.command.list.CvsListConsumer) ByteArrayInputStream(java.io.ByteArrayInputStream) ListScmResult(org.apache.maven.scm.command.list.ListScmResult) BufferedReader(java.io.BufferedReader) ScmException(org.apache.maven.scm.ScmException)

Example 2 with CvsListConsumer

use of org.apache.maven.scm.provider.cvslib.command.list.CvsListConsumer in project maven-scm by apache.

the class CvsExeListCommand method executeCvsCommand.

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

Aggregations

ScmException (org.apache.maven.scm.ScmException)2 ListScmResult (org.apache.maven.scm.command.list.ListScmResult)2 CvsListConsumer (org.apache.maven.scm.provider.cvslib.command.list.CvsListConsumer)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