Search in sources :

Example 11 with ExportScmResult

use of org.apache.maven.scm.command.export.ExportScmResult in project maven-scm by apache.

the class AccuRevExportCommandTest method testExportVersionOutSideWorkspace.

@Test
public void testExportVersionOutSideWorkspace() throws Exception {
    // info defaults to no workspace...
    info.setWorkSpace(null);
    when(accurev.info(basedir)).thenReturn(info);
    List<File> poppedFiles = Collections.singletonList(new File("exported/file"));
    when(accurev.popExternal(eq(basedir), eq("mySnapShot"), eq((String) null), (Collection<File>) argThat(hasItem(new File("/./project/dir"))))).thenReturn(poppedFiles);
    AccuRevExportCommand command = new AccuRevExportCommand(getLogger());
    CommandParameters params = new CommandParameters();
    params.setScmVersion(CommandParameter.SCM_VERSION, new ScmTag("mySnapShot"));
    ExportScmResult result = command.export(repo, new ScmFileSet(basedir), params);
    assertTrue(result.isSuccess());
    assertHasScmFile(result.getExportedFiles(), "exported/file", ScmFileStatus.CHECKED_OUT);
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) ScmTag(org.apache.maven.scm.ScmTag) ExportScmResult(org.apache.maven.scm.command.export.ExportScmResult) CommandParameters(org.apache.maven.scm.CommandParameters) ScmFileMatcher.assertHasScmFile(org.apache.maven.scm.ScmFileMatcher.assertHasScmFile) File(java.io.File) Test(org.junit.Test) AbstractAccuRevCommandTest(org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)

Example 12 with ExportScmResult

use of org.apache.maven.scm.command.export.ExportScmResult in project maven-scm by apache.

the class CvsExeExportCommand method executeCvsCommand.

/**
 * {@inheritDoc}
 */
protected ExportScmResult executeCvsCommand(Commandline cl) throws ScmException {
    CvsUpdateConsumer consumer = new CvsUpdateConsumer(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 ExportScmResult(cl.toString(), "The cvs command failed.", stderr.getOutput(), false);
    }
    return new ExportScmResult(cl.toString(), consumer.getUpdatedFiles());
}
Also used : CvsUpdateConsumer(org.apache.maven.scm.provider.cvslib.command.update.CvsUpdateConsumer) ScmException(org.apache.maven.scm.ScmException) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) ExportScmResult(org.apache.maven.scm.command.export.ExportScmResult) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException)

Aggregations

ExportScmResult (org.apache.maven.scm.command.export.ExportScmResult)12 File (java.io.File)6 ScmFileSet (org.apache.maven.scm.ScmFileSet)6 ScmTag (org.apache.maven.scm.ScmTag)6 CommandParameters (org.apache.maven.scm.CommandParameters)5 ScmFileMatcher.assertHasScmFile (org.apache.maven.scm.ScmFileMatcher.assertHasScmFile)5 AbstractAccuRevCommandTest (org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)5 Test (org.junit.Test)5 ScmException (org.apache.maven.scm.ScmException)4 CvsUpdateConsumer (org.apache.maven.scm.provider.cvslib.command.update.CvsUpdateConsumer)2 CommandLineException (org.codehaus.plexus.util.cli.CommandLineException)2 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)2 APIException (com.mks.api.response.APIException)1 BufferedReader (java.io.BufferedReader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 ArrayList (java.util.ArrayList)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 ScmBranch (org.apache.maven.scm.ScmBranch)1