Search in sources :

Example 16 with Commandline

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

the class AccuRevCommandLineTest method testAnnotate.

@Test
public void testAnnotate() throws Exception {
    File basedir = new File("/my/workspace");
    File file = new File("src/main/java/foo.java");
    AccuRevCommandLineTester accuRevCL = new AccuRevCommandLineTester();
    accuRevCL.annotate(basedir, file);
    Commandline lastCL = accuRevCL.getCommandline();
    assertThat(lastCL.getWorkingDirectory(), is(basedir.getCanonicalFile()));
    assertThat(lastCL.getArguments(), is(new String[] { "annotate", "-ftud", file.getPath() }));
}
Also used : Commandline(org.codehaus.plexus.util.cli.Commandline) File(java.io.File) Test(org.junit.Test)

Example 17 with Commandline

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

the class AccuRevCommandLineTest method testStatBackingStream.

@Test
public void testStatBackingStream() throws Exception {
    AccuRevCommandLineTester accuRevCL = new AccuRevCommandLineTester();
    File basedir = new File("/my/workspace");
    List<File> elements = new ArrayList<File>(1);
    File addedOrModifiedFile = new File("addedOrModified/file");
    elements.add(addedOrModifiedFile);
    accuRevCL.statBackingStream(basedir, elements);
    Commandline lastCL = accuRevCL.getCommandline();
    assertThat(lastCL.getWorkingDirectory(), is(basedir.getCanonicalFile()));
    assertThat(lastCL.getArguments(), is(new String[] { "stat", "-b", "-ffr", addedOrModifiedFile.getPath() }));
}
Also used : Commandline(org.codehaus.plexus.util.cli.Commandline) ArrayList(java.util.ArrayList) File(java.io.File) Test(org.junit.Test)

Example 18 with Commandline

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

the class SvnRemoveCommand method createCommandLine.

private static Commandline createCommandLine(File workingDirectory, List<File> files) throws ScmException {
    // Base command line doesn't make sense here - username/password not needed, and non-interactive/non-recusive is
    // not valid
    Commandline cl = new Commandline();
    cl.setExecutable("svn");
    cl.setWorkingDirectory(workingDirectory.getAbsolutePath());
    cl.createArg().setValue("remove");
    try {
        SvnCommandLineUtils.addTarget(cl, files);
    } catch (IOException e) {
        throw new ScmException("Can't create the targets file", e);
    }
    return cl;
}
Also used : ScmException(org.apache.maven.scm.ScmException) Commandline(org.codehaus.plexus.util.cli.Commandline) IOException(java.io.IOException)

Example 19 with Commandline

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

the class SvnStatusCommand method executeStatusCommand.

/**
 * {@inheritDoc}
 */
protected StatusScmResult executeStatusCommand(ScmProviderRepository repo, ScmFileSet fileSet) throws ScmException {
    Commandline cl = createCommandLine((SvnScmProviderRepository) repo, fileSet);
    SvnStatusConsumer consumer = new SvnStatusConsumer(getLogger(), fileSet.getBasedir());
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    if (getLogger().isInfoEnabled()) {
        getLogger().info("Executing: " + SvnCommandLineUtils.cryptPassword(cl));
        if (Os.isFamily(Os.FAMILY_WINDOWS)) {
            getLogger().info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath());
        }
    }
    int exitCode;
    try {
        exitCode = SvnCommandLineUtils.execute(cl, consumer, stderr, getLogger());
    } catch (CommandLineException ex) {
        throw new ScmException("Error while executing command.", ex);
    }
    if (exitCode != 0) {
        return new StatusScmResult(cl.toString(), "The svn 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) Commandline(org.codehaus.plexus.util.cli.Commandline) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) SvnCommandLineUtils(org.apache.maven.scm.provider.svn.svnexe.command.SvnCommandLineUtils) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException)

Example 20 with Commandline

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

the class SvnTagCommand method createCommandLine.

public static Commandline createCommandLine(SvnScmProviderRepository repository, File workingDirectory, String tag, File messageFile, ScmTagParameters scmTagParameters) {
    Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(workingDirectory, repository);
    cl.createArg().setValue("copy");
    cl.createArg().setValue("--file");
    cl.createArg().setValue(messageFile.getAbsolutePath());
    cl.createArg().setValue("--parents");
    if (scmTagParameters != null && scmTagParameters.getScmRevision() != null) {
        cl.createArg().setValue("--revision");
        cl.createArg().setValue(scmTagParameters.getScmRevision());
    }
    if (scmTagParameters != null && scmTagParameters.isRemoteTagging()) {
        cl.createArg().setValue(SvnCommandUtils.fixUrl(repository.getUrl(), repository.getUser()));
    } else {
        cl.createArg().setValue(".");
    }
    // Note: this currently assumes you have the tag base checked out too
    String tagUrl = SvnTagBranchUtils.resolveTagUrl(repository, new ScmTag(tag));
    cl.createArg().setValue(SvnCommandUtils.fixUrl(tagUrl, repository.getUser()));
    return cl;
}
Also used : Commandline(org.codehaus.plexus.util.cli.Commandline) ScmTag(org.apache.maven.scm.ScmTag)

Aggregations

Commandline (org.codehaus.plexus.util.cli.Commandline)443 File (java.io.File)131 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)116 ScmException (org.apache.maven.scm.ScmException)84 CommandLineException (org.codehaus.plexus.util.cli.CommandLineException)67 ScmRepository (org.apache.maven.scm.repository.ScmRepository)51 IOException (java.io.IOException)45 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 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 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)15 ScmFile (org.apache.maven.scm.ScmFile)13 CvsScmProviderRepository (org.apache.maven.scm.provider.cvslib.repository.CvsScmProviderRepository)13