Search in sources :

Example 66 with Commandline

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

the class ClearCaseBlameCommand method executeBlameCommand.

public BlameScmResult executeBlameCommand(ScmProviderRepository repo, ScmFileSet workingDirectory, String filename) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing blame command...");
    }
    Commandline cl = createCommandLine(workingDirectory.getBasedir(), filename);
    ClearCaseBlameConsumer consumer = new ClearCaseBlameConsumer(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 cvs command.", ex);
    }
    if (exitCode != 0) {
        return new BlameScmResult(cl.toString(), "The cleartool command failed.", stderr.getOutput(), false);
    }
    return new BlameScmResult(cl.toString(), consumer.getLines());
}
Also used : ScmException(org.apache.maven.scm.ScmException) Commandline(org.codehaus.plexus.util.cli.Commandline) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) BlameScmResult(org.apache.maven.scm.command.blame.BlameScmResult) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException)

Example 67 with Commandline

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

the class ClearCaseChangeLogCommand method executeChangeLogCommand.

// ----------------------------------------------------------------------
// AbstractChangeLogCommand Implementation
// ----------------------------------------------------------------------
/**
 * {@inheritDoc}
 */
protected ChangeLogScmResult executeChangeLogCommand(ScmProviderRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, ScmBranch branch, String datePattern) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing changelog command...");
    }
    Commandline cl = createCommandLine(fileSet.getBasedir(), branch, startDate);
    ClearCaseChangeLogConsumer consumer = new ClearCaseChangeLogConsumer(getLogger(), datePattern);
    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 cvs command.", ex);
    }
    if (exitCode != 0) {
        return new ChangeLogScmResult(cl.toString(), "The cleartool command failed.", stderr.getOutput(), false);
    }
    return new ChangeLogScmResult(cl.toString(), new ChangeLogSet(consumer.getModifications(), startDate, endDate));
}
Also used : ScmException(org.apache.maven.scm.ScmException) ChangeLogSet(org.apache.maven.scm.command.changelog.ChangeLogSet) Commandline(org.codehaus.plexus.util.cli.Commandline) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) ChangeLogScmResult(org.apache.maven.scm.command.changelog.ChangeLogScmResult) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException)

Example 68 with Commandline

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

the class ClearCaseCheckInCommand method executeCheckInCommand.

// ----------------------------------------------------------------------
// AbstractCheckOutCommand Implementation
// ----------------------------------------------------------------------
/**
 * {@inheritDoc}
 */
protected CheckInScmResult executeCheckInCommand(ScmProviderRepository scmProviderRepository, ScmFileSet fileSet, String message, ScmVersion version) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing checkin command...");
    }
    Commandline cl = createCommandLine(fileSet, message);
    ClearCaseCheckInConsumer consumer = new ClearCaseCheckInConsumer(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 CheckInScmResult(cl.toString(), "The cleartool command failed.", stderr.getOutput(), false);
    }
    return new CheckInScmResult(cl.toString(), consumer.getCheckedInFiles());
}
Also used : ScmException(org.apache.maven.scm.ScmException) Commandline(org.codehaus.plexus.util.cli.Commandline) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) CheckInScmResult(org.apache.maven.scm.command.checkin.CheckInScmResult) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException)

Example 69 with Commandline

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

the class ClearCaseCheckInCommand method createCommandLine.

// ----------------------------------------------------------------------
// 
// ----------------------------------------------------------------------
public static Commandline createCommandLine(ScmFileSet scmFileSet, String message) throws ScmException {
    Commandline command = new Commandline();
    File workingDirectory = scmFileSet.getBasedir();
    command.setWorkingDirectory(workingDirectory.getAbsolutePath());
    command.setExecutable("cleartool");
    command.createArg().setValue("ci");
    if (message != null) {
        command.createArg().setValue("-c");
        command.createArg().setLine("\"" + message + "\"");
    } else {
        command.createArg().setValue("-nc");
    }
    List<File> files = scmFileSet.getFileList();
    if (files.isEmpty()) {
        throw new ScmException("There are no files in the fileset to check in!");
    }
    for (File file : files) {
        command.createArg().setValue(file.getAbsolutePath());
    }
    return command;
}
Also used : ScmException(org.apache.maven.scm.ScmException) Commandline(org.codehaus.plexus.util.cli.Commandline) File(java.io.File)

Example 70 with Commandline

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

the class ClearCaseStatusCommandTest method testCommand.

public void testCommand() throws Exception {
    ScmFileSet scmFileSet = new ScmFileSet(getWorkingDirectory(), new File("test.java"));
    Commandline commandLine = ClearCaseStatusCommand.createCommandLine(scmFileSet);
    assertCommandLine("cleartool lscheckout -cview -r -fmt %n\\n", getWorkingDirectory(), commandLine);
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) Commandline(org.codehaus.plexus.util.cli.Commandline) File(java.io.File)

Aggregations

Commandline (org.codehaus.plexus.util.cli.Commandline)446 File (java.io.File)133 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)117 ScmException (org.apache.maven.scm.ScmException)84 CommandLineException (org.codehaus.plexus.util.cli.CommandLineException)70 ScmRepository (org.apache.maven.scm.repository.ScmRepository)51 IOException (java.io.IOException)48 ScmFileSet (org.apache.maven.scm.ScmFileSet)34 Test (org.junit.Test)28 StringStreamConsumer (org.codehaus.plexus.util.cli.CommandLineUtils.StringStreamConsumer)26 ArrayList (java.util.ArrayList)22 StarteamScmProviderRepository (org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository)22 PerforceScmProviderRepository (org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository)19 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)18 SvnCommandLineUtils (org.apache.maven.scm.provider.svn.svnexe.command.SvnCommandLineUtils)17 GitCommandLineUtils (org.apache.maven.scm.provider.git.gitexe.command.GitCommandLineUtils)16 GitScmProviderRepository (org.apache.maven.scm.provider.git.repository.GitScmProviderRepository)16 SvnScmProviderRepository (org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository)16 ScmFile (org.apache.maven.scm.ScmFile)13 CvsScmProviderRepository (org.apache.maven.scm.provider.cvslib.repository.CvsScmProviderRepository)13