Search in sources :

Example 1 with ExportScmResult

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

the class AccuRevExportCommandTest method testExportFailure.

@Test
public void testExportFailure() throws Exception {
    // info defaults to no workspace...
    info.setWorkSpace(null);
    when(accurev.info(basedir)).thenReturn(info);
    when(accurev.getClientVersion()).thenReturn("4.9.0");
    when(accurev.popExternal(eq(basedir), eq("mySnapShot"), eq("544"), (Collection<File>) argThat(hasItem(new File("/./project/dir"))))).thenReturn(null);
    AccuRevExportCommand command = new AccuRevExportCommand(getLogger());
    CommandParameters params = new CommandParameters();
    params.setScmVersion(CommandParameter.SCM_VERSION, new ScmTag("mySnapShot/544"));
    ExportScmResult result = command.export(repo, new ScmFileSet(basedir), params);
    assertThat(result.isSuccess(), is(false));
    assertThat(result.getProviderMessage(), notNullValue());
}
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 2 with ExportScmResult

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

the class AccuRevExportCommandTest method testNonPersistentWithinExistingWorkspace.

@Test
public void testNonPersistentWithinExistingWorkspace() throws Exception {
    // Setup info to return a stream rooted somewhere around here...
    info.setWorkSpace("myStream_me");
    info.setBasis("someStream");
    info.setTop(basedir.getParent());
    when(accurev.info(basedir)).thenReturn(info);
    when(accurev.stat(basedir)).thenReturn(null);
    when(accurev.rmws("myStream_me")).thenReturn(Boolean.TRUE);
    List<File> poppedFiles = Collections.singletonList(new File("exported/file"));
    when(accurev.popExternal(eq(basedir), eq("mySnapShot"), eq("now"), (Collection<File>) argThat(hasItem(new File("/./project/dir"))))).thenReturn(poppedFiles);
    when(accurev.reactivate("myStream_me")).thenReturn(Boolean.TRUE);
    repo.setPersistCheckout(true);
    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);
    verify(accurev).rmws("myStream_me");
    verify(accurev).reactivate("myStream_me");
    assertTrue(result.isSuccess());
// TODO - raise JIRA to move relative path dir to repository rather than checkout result
// dassertThat( result.getRelativePathProjectDirectory(), is( "/project/dir" ) );
}
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 3 with ExportScmResult

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

the class SvnExeExportCommand method executeExportCommand.

/**
 * {@inheritDoc}
 */
protected ExportScmResult executeExportCommand(ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion version, String outputDirectory) throws ScmException {
    if (outputDirectory == null) {
        outputDirectory = fileSet.getBasedir().getAbsolutePath();
    }
    SvnScmProviderRepository repository = (SvnScmProviderRepository) repo;
    String url = repository.getUrl();
    if (version != null && StringUtils.isNotEmpty(version.getName())) {
        if (version instanceof ScmTag) {
            url = SvnTagBranchUtils.resolveTagUrl(repository, (ScmTag) version);
        } else if (version instanceof ScmBranch) {
            url = SvnTagBranchUtils.resolveBranchUrl(repository, (ScmBranch) version);
        }
    }
    url = SvnCommandUtils.fixUrl(url, repository.getUser());
    Commandline cl = createCommandLine((SvnScmProviderRepository) repo, fileSet.getBasedir(), version, url, outputDirectory);
    SvnUpdateConsumer consumer = new SvnUpdateConsumer(getLogger(), fileSet.getBasedir());
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    if (getLogger().isInfoEnabled()) {
        getLogger().info("Executing: " + SvnCommandLineUtils.cryptPassword(cl));
        if (cl.getWorkingDirectory() != null && 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 ExportScmResult(cl.toString(), "The svn command failed.", stderr.getOutput(), false);
    }
    return new ExportScmResultWithRevision(cl.toString(), consumer.getUpdatedFiles(), String.valueOf(consumer.getRevision()));
}
Also used : ScmBranch(org.apache.maven.scm.ScmBranch) ScmException(org.apache.maven.scm.ScmException) Commandline(org.codehaus.plexus.util.cli.Commandline) SvnUpdateConsumer(org.apache.maven.scm.provider.svn.svnexe.command.update.SvnUpdateConsumer) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException) ScmTag(org.apache.maven.scm.ScmTag) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) SvnCommandLineUtils(org.apache.maven.scm.provider.svn.svnexe.command.SvnCommandLineUtils) ExportScmResult(org.apache.maven.scm.command.export.ExportScmResult) SvnScmProviderRepository(org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository) ExportScmResultWithRevision(org.apache.maven.scm.command.export.ExportScmResultWithRevision)

Example 4 with ExportScmResult

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

the class IntegrityScmProvider method export.

/**
 * Maps to si projectco (no sandbox is used)
 */
@Override
protected ExportScmResult export(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params) throws ScmException {
    IntegrityExportCommand command = new IntegrityExportCommand();
    command.setLogger(getLogger());
    return (ExportScmResult) command.execute(repository, fileSet, params);
}
Also used : ExportScmResult(org.apache.maven.scm.command.export.ExportScmResult) IntegrityExportCommand(org.apache.maven.scm.provider.integrity.command.export.IntegrityExportCommand)

Example 5 with ExportScmResult

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

the class CvsJavaExportCommand method executeCvsCommand.

/**
 * {@inheritDoc}
 */
protected ExportScmResult executeCvsCommand(Commandline cl) throws ScmException {
    CvsLogListener logListener = new CvsLogListener();
    CvsUpdateConsumer consumer = new CvsUpdateConsumer(getLogger());
    try {
        boolean isSuccess = CvsConnection.processCommand(cl.getArguments(), cl.getWorkingDirectory().getAbsolutePath(), logListener, getLogger());
        if (!isSuccess) {
            return new ExportScmResult(cl.toString(), "The cvs command failed.", logListener.getStderr().toString(), false);
        }
        BufferedReader stream = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(logListener.getStdout().toString().getBytes())));
        String line;
        while ((line = stream.readLine()) != null) {
            consumer.consumeLine(line);
        }
    } catch (Exception e) {
        e.printStackTrace();
        return new ExportScmResult(cl.toString(), "The cvs command failed.", logListener.getStderr().toString(), false);
    }
    return new ExportScmResult(cl.toString(), consumer.getUpdatedFiles());
}
Also used : CvsUpdateConsumer(org.apache.maven.scm.provider.cvslib.command.update.CvsUpdateConsumer) CvsLogListener(org.apache.maven.scm.provider.cvslib.cvsjava.util.CvsLogListener) InputStreamReader(java.io.InputStreamReader) ByteArrayInputStream(java.io.ByteArrayInputStream) ExportScmResult(org.apache.maven.scm.command.export.ExportScmResult) BufferedReader(java.io.BufferedReader) ScmException(org.apache.maven.scm.ScmException)

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