Search in sources :

Example 56 with CommandLineException

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

Example 57 with CommandLineException

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

the class ClearCaseEditCommand method executeEditCommand.

/**
 * {@inheritDoc}
 */
protected ScmResult executeEditCommand(ScmProviderRepository repository, ScmFileSet fileSet) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing edit command...");
    }
    Commandline cl = createCommandLine(getLogger(), fileSet);
    ClearCaseEditConsumer consumer = new ClearCaseEditConsumer(getLogger());
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    int exitCode;
    try {
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Executing: " + cl.getWorkingDirectory().getAbsolutePath() + ">>" + cl.toString());
        }
        exitCode = CommandLineUtils.executeCommandLine(cl, consumer, stderr);
    } catch (CommandLineException ex) {
        throw new ScmException("Error while executing clearcase command.", ex);
    }
    if (exitCode != 0) {
        return new EditScmResult(cl.toString(), "The cleartool command failed.", stderr.getOutput(), false);
    }
    return new EditScmResult(cl.toString(), consumer.getEditFiles());
}
Also used : ScmException(org.apache.maven.scm.ScmException) Commandline(org.codehaus.plexus.util.cli.Commandline) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) EditScmResult(org.apache.maven.scm.command.edit.EditScmResult) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException)

Example 58 with CommandLineException

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

the class ClearCaseRemoveCommand method executeRemoveCommand.

/**
 * {@inheritDoc}
 */
protected ScmResult executeRemoveCommand(ScmProviderRepository scmProviderRepository, ScmFileSet scmFileSet, String string) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing remove command...");
    }
    Commandline cl = createCommandLine(getLogger(), scmFileSet);
    ClearCaseRemoveConsumer consumer = new ClearCaseRemoveConsumer(getLogger());
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    int exitCode;
    try {
        // First we need to 'check out' the current directory
        Commandline checkoutCurrentDirCommandLine = ClearCaseEditCommand.createCheckoutCurrentDirCommandLine(scmFileSet);
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Executing: " + checkoutCurrentDirCommandLine.getWorkingDirectory().getAbsolutePath() + ">>" + checkoutCurrentDirCommandLine.toString());
        }
        exitCode = CommandLineUtils.executeCommandLine(checkoutCurrentDirCommandLine, new CommandLineUtils.StringStreamConsumer(), stderr);
        if (exitCode == 0) {
            // Then we add the file
            if (getLogger().isDebugEnabled()) {
                getLogger().debug("Executing: " + cl.getWorkingDirectory().getAbsolutePath() + ">>" + cl.toString());
            }
            exitCode = CommandLineUtils.executeCommandLine(cl, consumer, stderr);
            if (exitCode == 0) {
                // Then we check in the current directory again.
                Commandline checkinCurrentDirCommandLine = ClearCaseEditCommand.createCheckinCurrentDirCommandLine(scmFileSet);
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("Executing: " + checkinCurrentDirCommandLine.getWorkingDirectory().getAbsolutePath() + ">>" + checkinCurrentDirCommandLine.toString());
                }
                exitCode = CommandLineUtils.executeCommandLine(checkinCurrentDirCommandLine, new CommandLineUtils.StringStreamConsumer(), stderr);
            }
        }
    } catch (CommandLineException ex) {
        throw new ScmException("Error while executing clearcase command.", ex);
    }
    if (exitCode != 0) {
        return new StatusScmResult(cl.toString(), "The cleartool command failed.", stderr.getOutput(), false);
    }
    return new StatusScmResult(cl.toString(), consumer.getRemovedFiles());
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) ScmException(org.apache.maven.scm.ScmException) Commandline(org.codehaus.plexus.util.cli.Commandline) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException)

Example 59 with CommandLineException

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

the class ClearCaseTagCommand method executeTagCommand.

/**
 * {@inheritDoc}
 */
protected ScmResult executeTagCommand(ScmProviderRepository scmProviderRepository, ScmFileSet fileSet, String tag, ScmTagParameters scmTagParameters) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing tag command...");
    }
    Commandline cl = createCommandLine(fileSet, tag);
    ClearCaseCheckInConsumer consumer = new ClearCaseCheckInConsumer(getLogger());
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    int exitCode;
    try {
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Creating label: " + tag);
        }
        Commandline newLabelCommandLine = createNewLabelCommandLine(fileSet, tag);
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Executing: " + newLabelCommandLine.getWorkingDirectory().getAbsolutePath() + ">>" + newLabelCommandLine.toString());
        }
        exitCode = CommandLineUtils.executeCommandLine(newLabelCommandLine, new CommandLineUtils.StringStreamConsumer(), stderr);
        if (exitCode == 0) {
            getLogger().debug("Executing: " + cl.getWorkingDirectory().getAbsolutePath() + ">>" + cl.toString());
            exitCode = CommandLineUtils.executeCommandLine(cl, consumer, stderr);
        }
    } catch (CommandLineException ex) {
        throw new ScmException("Error while executing clearcase command.", ex);
    }
    if (exitCode != 0) {
        return new TagScmResult(cl.toString(), "The cleartool command failed.", stderr.getOutput(), false);
    }
    return new TagScmResult(cl.toString(), consumer.getCheckedInFiles());
}
Also used : ScmException(org.apache.maven.scm.ScmException) ClearCaseCheckInConsumer(org.apache.maven.scm.provider.clearcase.command.checkin.ClearCaseCheckInConsumer) Commandline(org.codehaus.plexus.util.cli.Commandline) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) TagScmResult(org.apache.maven.scm.command.tag.TagScmResult) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException)

Example 60 with CommandLineException

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

the class ClearCaseUnEditCommand method executeUnEditCommand.

/**
 * {@inheritDoc}
 */
protected ScmResult executeUnEditCommand(ScmProviderRepository repository, ScmFileSet fileSet) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing unedit command...");
    }
    Commandline cl = createCommandLine(getLogger(), fileSet);
    ClearCaseUnEditConsumer consumer = new ClearCaseUnEditConsumer(getLogger());
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    int exitCode;
    try {
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Executing: " + cl.getWorkingDirectory().getAbsolutePath() + ">>" + cl.toString());
        }
        exitCode = CommandLineUtils.executeCommandLine(cl, consumer, stderr);
    } catch (CommandLineException ex) {
        throw new ScmException("Error while executing clearcase command.", ex);
    }
    if (exitCode != 0) {
        return new StatusScmResult(cl.toString(), "The cleartool command failed.", stderr.getOutput(), false);
    }
    return new StatusScmResult(cl.toString(), consumer.getUnEditFiles());
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) ScmException(org.apache.maven.scm.ScmException) Commandline(org.codehaus.plexus.util.cli.Commandline) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException)

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