Search in sources :

Example 91 with Commandline

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

the class VssCheckOutCommandTest method testCommandLine.

public void testCommandLine() throws Exception {
    ScmRepository repository = scmManager.makeScmRepository("scm:vss|username|password@C:/Program File/Visual Source Safe|D:/myProject");
    ScmFileSet fileSet = new ScmFileSet(getTestFile("target"));
    VssCheckOutCommand command = new VssCheckOutCommand();
    Commandline cl = command.buildCmdLine((VssScmProviderRepository) repository.getProviderRepository(), fileSet, null);
    String ssPath = VssCommandLineUtils.getSsDir().replace('/', File.separatorChar);
    assertCommandLine(ssPath + "ss Get $D:/myProject -Yusername,password -R -I- -GWR", fileSet.getBasedir(), cl);
}
Also used : ScmRepository(org.apache.maven.scm.repository.ScmRepository) ScmFileSet(org.apache.maven.scm.ScmFileSet) Commandline(org.codehaus.plexus.util.cli.Commandline)

Example 92 with Commandline

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

the class VssEditCommandTest method testCommandLineFileSet.

public void testCommandLineFileSet() throws Exception {
    File target = getTestFile(".");
    ScmRepository repository = scmManager.makeScmRepository("scm:vss|username|password@C:/Program File/Visual Source Safe|D:/myProject");
    ScmFileSet fileSet = new ScmFileSet(target, "**/target/**/VssEditCommandTest.class");
    VssEditCommand command = new VssEditCommand();
    List<Commandline> commands = command.buildCmdLine((VssScmProviderRepository) repository.getProviderRepository(), fileSet);
    Commandline cl = commands.get(0);
    String ssPath = VssCommandLineUtils.getSsDir().replace('/', File.separatorChar);
    assertCommandLine(ssPath + "ss Checkout $D:/myProject/target/test-classes/org/apache/maven/scm/provider/vss/commands/edit/VssEditCommandTest.class -Yusername,password -I-", ((File) fileSet.getFileList().get(0)).getParentFile().getCanonicalFile(), cl);
}
Also used : ScmRepository(org.apache.maven.scm.repository.ScmRepository) ScmFileSet(org.apache.maven.scm.ScmFileSet) Commandline(org.codehaus.plexus.util.cli.Commandline) File(java.io.File)

Example 93 with Commandline

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

the class VssEditCommandTest method testCommandLineRelativePath.

public void testCommandLineRelativePath() throws Exception {
    ScmRepository repository = scmManager.makeScmRepository("scm:vss|username|password@C:/Program File/Visual Source Safe|D:/myProject");
    File target = getTestFile("target");
    ScmFileSet fileSet = new ScmFileSet(target, new File(target, "test-classes/org/apache/maven/scm/provider/vss/commands/edit/VssEditCommandTest.class"));
    VssEditCommand command = new VssEditCommand();
    List<Commandline> commands = command.buildCmdLine((VssScmProviderRepository) repository.getProviderRepository(), fileSet);
    Commandline cl = commands.get(0);
    String ssPath = VssCommandLineUtils.getSsDir().replace('/', File.separatorChar);
    assertCommandLine(ssPath + "ss Checkout $D:/myProject/test-classes/org/apache/maven/scm/provider/vss/commands/edit/VssEditCommandTest.class -Yusername,password -I-", ((File) fileSet.getFileList().get(0)).getParentFile().getCanonicalFile(), cl);
}
Also used : ScmRepository(org.apache.maven.scm.repository.ScmRepository) ScmFileSet(org.apache.maven.scm.ScmFileSet) Commandline(org.codehaus.plexus.util.cli.Commandline) File(java.io.File)

Example 94 with Commandline

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

the class CvsCommandUtils method getBaseCommand.

public static Commandline getBaseCommand(String commandName, CvsScmProviderRepository repo, ScmFileSet fileSet, String options, boolean addCvsRoot) {
    Settings settings = CvsUtil.getSettings();
    Commandline cl = new Commandline();
    cl.setExecutable("cvs");
    cl.setWorkingDirectory(fileSet.getBasedir().getAbsolutePath());
    if (Boolean.getBoolean("maven.scm.cvs.use_compression")) {
        cl.createArg().setValue("-z" + System.getProperty("maven.scm.cvs.compression_level", "3"));
    } else if (settings.getCompressionLevel() > 0) {
        cl.createArg().setValue("-z" + settings.getCompressionLevel());
    }
    if (!settings.isUseCvsrc()) {
        // don't use ~/.cvsrc
        cl.createArg().setValue("-f");
    }
    if (settings.isTraceCvsCommand()) {
        cl.createArg().setValue("-t");
    }
    if (!StringUtils.isEmpty(settings.getTemporaryFilesDirectory())) {
        File tempDir = new File(settings.getTemporaryFilesDirectory());
        if (!tempDir.exists()) {
            tempDir.mkdirs();
        }
        cl.createArg().setValue("-T");
        cl.createArg().setValue(tempDir.getAbsolutePath());
    }
    if (settings.getCvsVariables().size() > 0) {
        for (Enumeration<?> e = settings.getCvsVariables().propertyNames(); e.hasMoreElements(); ) {
            String key = (String) e.nextElement();
            String value = settings.getCvsVariables().getProperty(key);
            cl.createArg().setValue("-s");
            cl.createArg().setValue(key + "=" + value);
        }
    }
    if (addCvsRoot) {
        cl.createArg().setValue("-d");
        cl.createArg().setValue(repo.getCvsRoot());
    }
    cl.createArg().setLine(options);
    cl.createArg().setValue("-q");
    cl.createArg().setValue(commandName);
    return cl;
}
Also used : Commandline(org.codehaus.plexus.util.cli.Commandline) File(java.io.File) Settings(org.apache.maven.scm.providers.cvslib.settings.Settings)

Example 95 with Commandline

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

the class AbstractCvsBlameCommand method executeBlameCommand.

/**
 * {@inheritDoc}
 */
public BlameScmResult executeBlameCommand(ScmProviderRepository repo, ScmFileSet fileSet, String filename) throws ScmException {
    CvsScmProviderRepository repository = (CvsScmProviderRepository) repo;
    Commandline cl = CvsCommandUtils.getBaseCommand("annotate", repository, fileSet);
    cl.createArg().setValue(filename);
    if (getLogger().isInfoEnabled()) {
        getLogger().info("Executing: " + cl);
        getLogger().info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath());
    }
    return executeCvsCommand(cl, repository);
}
Also used : CvsScmProviderRepository(org.apache.maven.scm.provider.cvslib.repository.CvsScmProviderRepository) Commandline(org.codehaus.plexus.util.cli.Commandline)

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