Search in sources :

Example 26 with CommandLineException

use of org.codehaus.plexus.util.cli.CommandLineException in project maven-scm by apache.

the class CvsExeStatusCommand method executeCvsCommand.

/**
 * {@inheritDoc}
 */
protected StatusScmResult executeCvsCommand(Commandline cl) throws ScmException {
    CvsStatusConsumer consumer = new CvsStatusConsumer(getLogger(), cl.getWorkingDirectory());
    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 StatusScmResult(cl.toString(), "The cvs command failed.", stderr.getOutput(), false);
    }
    return new StatusScmResult(cl.toString(), consumer.getChangedFiles());
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) ScmException(org.apache.maven.scm.ScmException) CvsStatusConsumer(org.apache.maven.scm.provider.cvslib.command.status.CvsStatusConsumer) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException)

Example 27 with CommandLineException

use of org.codehaus.plexus.util.cli.CommandLineException 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 28 with CommandLineException

use of org.codehaus.plexus.util.cli.CommandLineException 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 29 with CommandLineException

use of org.codehaus.plexus.util.cli.CommandLineException 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 30 with CommandLineException

use of org.codehaus.plexus.util.cli.CommandLineException in project maven-scm by apache.

the class CvsExeDiffCommand method executeCvsCommand.

/**
 * {@inheritDoc}
 */
protected DiffScmResult executeCvsCommand(Commandline cl) throws ScmException {
    CvsDiffConsumer consumer = new CvsDiffConsumer(getLogger(), cl.getWorkingDirectory());
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    try {
        CommandLineUtils.executeCommandLine(cl, consumer, stderr);
    } catch (CommandLineException ex) {
        throw new ScmException("Error while executing command.", ex);
    }
    return new DiffScmResult(cl.toString(), consumer.getChangedFiles(), consumer.getDifferences(), consumer.getPatch());
}
Also used : CvsDiffConsumer(org.apache.maven.scm.provider.cvslib.command.diff.CvsDiffConsumer) ScmException(org.apache.maven.scm.ScmException) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException) DiffScmResult(org.apache.maven.scm.command.diff.DiffScmResult)

Aggregations

CommandLineException (org.codehaus.plexus.util.cli.CommandLineException)94 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)76 Commandline (org.codehaus.plexus.util.cli.Commandline)67 ScmException (org.apache.maven.scm.ScmException)56 IOException (java.io.IOException)20 SvnCommandLineUtils (org.apache.maven.scm.provider.svn.svnexe.command.SvnCommandLineUtils)18 File (java.io.File)14 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)13 BufferedReader (java.io.BufferedReader)6 BlameScmResult (org.apache.maven.scm.command.blame.BlameScmResult)6 StatusScmResult (org.apache.maven.scm.command.status.StatusScmResult)6 SvnScmProviderRepository (org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository)6 InputStreamReader (java.io.InputStreamReader)5 ChangeLogScmResult (org.apache.maven.scm.command.changelog.ChangeLogScmResult)5 ChangeLogSet (org.apache.maven.scm.command.changelog.ChangeLogSet)5 CheckOutScmResult (org.apache.maven.scm.command.checkout.CheckOutScmResult)5 StreamConsumer (org.codehaus.plexus.util.cli.StreamConsumer)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 StringTokenizer (java.util.StringTokenizer)4 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)4