Search in sources :

Example 1 with CvsCheckInConsumer

use of org.apache.maven.scm.provider.cvslib.command.checkin.CvsCheckInConsumer in project maven-scm by apache.

the class CvsExeCheckInCommand method executeCvsCommand.

/**
 * {@inheritDoc}
 */
protected CheckInScmResult executeCvsCommand(Commandline cl, CvsScmProviderRepository repository, File messageFile) throws ScmException {
    CvsCheckInConsumer consumer = new CvsCheckInConsumer(repository.getPath(), 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);
    }
    try {
        FileUtils.forceDelete(messageFile);
    } catch (IOException ex) {
    // ignore
    }
    if (exitCode != 0) {
        return new CheckInScmResult(cl.toString(), "The cvs command failed.", stderr.getOutput(), false);
    }
    return new CheckInScmResult(cl.toString(), consumer.getCheckedInFiles());
}
Also used : ScmException(org.apache.maven.scm.ScmException) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) IOException(java.io.IOException) CvsCheckInConsumer(org.apache.maven.scm.provider.cvslib.command.checkin.CvsCheckInConsumer) CheckInScmResult(org.apache.maven.scm.command.checkin.CheckInScmResult) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException)

Example 2 with CvsCheckInConsumer

use of org.apache.maven.scm.provider.cvslib.command.checkin.CvsCheckInConsumer in project maven-scm by apache.

the class CvsJavaCheckInCommand method executeCvsCommand.

/**
 * {@inheritDoc}
 */
protected CheckInScmResult executeCvsCommand(Commandline cl, CvsScmProviderRepository repository, File messageFile) throws ScmException {
    CvsLogListener logListener = new CvsLogListener();
    CvsCheckInConsumer consumer = new CvsCheckInConsumer(repository.getPath(), getLogger());
    try {
        boolean isSuccess = CvsConnection.processCommand(cl.getArguments(), cl.getWorkingDirectory().getAbsolutePath(), logListener, getLogger());
        if (!isSuccess) {
            return new CheckInScmResult(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 CheckInScmResult(cl.toString(), "The cvs command failed.", logListener.getStdout().toString(), false);
    } finally {
        try {
            FileUtils.forceDelete(messageFile);
        } catch (IOException ex) {
        // ignore
        }
    }
    return new CheckInScmResult(cl.toString(), consumer.getCheckedInFiles());
}
Also used : CvsLogListener(org.apache.maven.scm.provider.cvslib.cvsjava.util.CvsLogListener) InputStreamReader(java.io.InputStreamReader) ByteArrayInputStream(java.io.ByteArrayInputStream) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) CvsCheckInConsumer(org.apache.maven.scm.provider.cvslib.command.checkin.CvsCheckInConsumer) CheckInScmResult(org.apache.maven.scm.command.checkin.CheckInScmResult) IOException(java.io.IOException) ScmException(org.apache.maven.scm.ScmException)

Aggregations

IOException (java.io.IOException)2 ScmException (org.apache.maven.scm.ScmException)2 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)2 CvsCheckInConsumer (org.apache.maven.scm.provider.cvslib.command.checkin.CvsCheckInConsumer)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