Search in sources :

Example 1 with SvnUpdateConsumer

use of org.apache.maven.scm.provider.svn.svnexe.command.update.SvnUpdateConsumer 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)

Aggregations

ScmBranch (org.apache.maven.scm.ScmBranch)1 ScmException (org.apache.maven.scm.ScmException)1 ScmTag (org.apache.maven.scm.ScmTag)1 ExportScmResult (org.apache.maven.scm.command.export.ExportScmResult)1 ExportScmResultWithRevision (org.apache.maven.scm.command.export.ExportScmResultWithRevision)1 SvnScmProviderRepository (org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository)1 SvnCommandLineUtils (org.apache.maven.scm.provider.svn.svnexe.command.SvnCommandLineUtils)1 SvnUpdateConsumer (org.apache.maven.scm.provider.svn.svnexe.command.update.SvnUpdateConsumer)1 CommandLineException (org.codehaus.plexus.util.cli.CommandLineException)1 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)1 Commandline (org.codehaus.plexus.util.cli.Commandline)1