Search in sources :

Example 1 with CvsTagConsumer

use of org.apache.maven.scm.provider.cvslib.command.tag.CvsTagConsumer in project maven-scm by apache.

the class CvsExeTagCommand method executeCvsCommand.

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

Example 2 with CvsTagConsumer

use of org.apache.maven.scm.provider.cvslib.command.tag.CvsTagConsumer in project maven-scm by apache.

the class CvsJavaTagCommand method executeCvsCommand.

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

Aggregations

ScmException (org.apache.maven.scm.ScmException)2 TagScmResult (org.apache.maven.scm.command.tag.TagScmResult)2 CvsTagConsumer (org.apache.maven.scm.provider.cvslib.command.tag.CvsTagConsumer)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