Search in sources :

Example 71 with Commandline

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

the class HgUtils method buildCmd.

static Commandline buildCmd(File workingDir, String[] cmdAndArgs) throws ScmException {
    Commandline cmd = new Commandline();
    cmd.setExecutable(HgCommandConstants.EXEC);
    cmd.addArguments(cmdAndArgs);
    if (workingDir != null) {
        cmd.setWorkingDirectory(workingDir.getAbsolutePath());
        if (!workingDir.exists()) {
            boolean success = workingDir.mkdirs();
            if (!success) {
                String msg = "Working directory did not exist" + " and it couldn't be created: " + workingDir;
                throw new ScmException(msg);
            }
        }
    }
    return cmd;
}
Also used : ScmException(org.apache.maven.scm.ScmException) Commandline(org.codehaus.plexus.util.cli.Commandline)

Example 72 with Commandline

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

the class ClearCaseEditCommand method createCheckinCurrentDirCommandLine.

public static Commandline createCheckinCurrentDirCommandLine(ScmFileSet scmFileSet) {
    Commandline command = new Commandline();
    File workingDirectory = scmFileSet.getBasedir();
    command.setWorkingDirectory(workingDirectory.getAbsolutePath());
    command.setExecutable("cleartool");
    command.createArg().setValue("ci");
    command.createArg().setValue("-nc");
    command.createArg().setValue(".");
    return command;
}
Also used : Commandline(org.codehaus.plexus.util.cli.Commandline) File(java.io.File)

Example 73 with Commandline

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

the class ClearCaseStatusCommand method createCommandLine.

// ----------------------------------------------------------------------
// 
// ----------------------------------------------------------------------
public static Commandline createCommandLine(ScmFileSet scmFileSet) {
    Commandline command = new Commandline();
    File workingDirectory = scmFileSet.getBasedir();
    command.setWorkingDirectory(workingDirectory.getAbsolutePath());
    command.setExecutable("cleartool");
    command.createArg().setValue("lscheckout");
    command.createArg().setValue("-cview");
    command.createArg().setValue("-r");
    command.createArg().setValue("-fmt");
    command.createArg().setValue("%n\\n");
    return command;
}
Also used : Commandline(org.codehaus.plexus.util.cli.Commandline) File(java.io.File)

Example 74 with Commandline

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

the class ClearCaseStatusCommand method executeStatusCommand.

/**
 * {@inheritDoc}
 */
protected StatusScmResult executeStatusCommand(ScmProviderRepository scmProviderRepository, ScmFileSet scmFileSet) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing status command...");
    }
    Commandline cl = createCommandLine(scmFileSet);
    ClearCaseStatusConsumer consumer = new ClearCaseStatusConsumer(getLogger(), scmFileSet.getBasedir());
    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.getCheckedOutFiles());
}
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 75 with Commandline

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

the class ClearCaseCheckInCommandTest method testCommand.

public void testCommand() throws Exception {
    File file = new File("test.java");
    ScmFileSet scmFileSet = new ScmFileSet(getWorkingDirectory(), file);
    Commandline commandLine = ClearCaseCheckInCommand.createCommandLine(scmFileSet, "done some changes");
    assertCommandLine("cleartool ci -c \"done some changes\" " + file.getAbsolutePath(), 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