Search in sources :

Example 1 with CvsUpdateConsumer

use of org.apache.maven.scm.provider.cvslib.command.update.CvsUpdateConsumer in project maven-scm by apache.

the class CvsExeUpdateCommand method executeCvsCommand.

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

Example 2 with CvsUpdateConsumer

use of org.apache.maven.scm.provider.cvslib.command.update.CvsUpdateConsumer in project maven-scm by apache.

the class CvsJavaExportCommand method executeCvsCommand.

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

Example 3 with CvsUpdateConsumer

use of org.apache.maven.scm.provider.cvslib.command.update.CvsUpdateConsumer in project maven-scm by apache.

the class CvsExeExportCommand method executeCvsCommand.

/**
 * {@inheritDoc}
 */
protected ExportScmResult 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 ExportScmResult(cl.toString(), "The cvs command failed.", stderr.getOutput(), false);
    }
    return new ExportScmResult(cl.toString(), consumer.getUpdatedFiles());
}
Also used : CvsUpdateConsumer(org.apache.maven.scm.provider.cvslib.command.update.CvsUpdateConsumer) ScmException(org.apache.maven.scm.ScmException) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) ExportScmResult(org.apache.maven.scm.command.export.ExportScmResult) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException)

Example 4 with CvsUpdateConsumer

use of org.apache.maven.scm.provider.cvslib.command.update.CvsUpdateConsumer in project maven-scm by apache.

the class CvsJavaUpdateCommand method executeCvsCommand.

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

Aggregations

ScmException (org.apache.maven.scm.ScmException)4 CvsUpdateConsumer (org.apache.maven.scm.provider.cvslib.command.update.CvsUpdateConsumer)4 BufferedReader (java.io.BufferedReader)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStreamReader (java.io.InputStreamReader)2 ExportScmResult (org.apache.maven.scm.command.export.ExportScmResult)2 UpdateScmResult (org.apache.maven.scm.command.update.UpdateScmResult)2 CvsLogListener (org.apache.maven.scm.provider.cvslib.cvsjava.util.CvsLogListener)2 CommandLineException (org.codehaus.plexus.util.cli.CommandLineException)2 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)2