protected ExportScmResult executeExportCommand()

in maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/export/SvnExeExportCommand.java [51:102]


    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(fileSet.getBasedir());

        CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();

        if (logger.isInfoEnabled()) {
            logger.info("Executing: " + SvnCommandLineUtils.cryptPassword(cl));

            if (cl.getWorkingDirectory() != null && Os.isFamily(Os.FAMILY_WINDOWS)) {
                logger.info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath());
            }
        }

        int exitCode;

        try {
            exitCode = SvnCommandLineUtils.execute(cl, consumer, stderr);
        } 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()));
    }