Search in sources :

Example 1 with StarteamCheckOutConsumer

use of org.apache.maven.scm.provider.starteam.command.checkout.StarteamCheckOutConsumer in project maven-scm by apache.

the class StarteamUpdateCommand method executeUpdateCommand.

// ----------------------------------------------------------------------
// AbstractUpdateCommand Implementation
// ----------------------------------------------------------------------
/**
 * {@inheritDoc}
 */
protected UpdateScmResult executeUpdateCommand(ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion version) throws ScmException {
    if (getLogger().isInfoEnabled()) {
        getLogger().info("Working directory: " + fileSet.getBasedir().getAbsolutePath());
    }
    StarteamScmProviderRepository repository = (StarteamScmProviderRepository) repo;
    StarteamCheckOutConsumer consumer = new StarteamCheckOutConsumer(getLogger(), fileSet.getBasedir());
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    List<File> updateFiles = fileSet.getFileList();
    if (updateFiles.size() == 0) {
        // update everything
        Commandline cl = createCommandLine(repository, fileSet, version);
        int exitCode = StarteamCommandLineUtils.executeCommandline(cl, consumer, stderr, getLogger());
        if (exitCode != 0) {
            return new UpdateScmResult(cl.toString(), "The starteam command failed.", stderr.getOutput(), false);
        } else {
            // hiden feature to allow Continuous Integration machine to
            // delete local files. It affectively remove all build ouput as well
            String doDeleteLocal = System.getProperty("maven.scm.starteam.deleteLocal");
            if ("true".equalsIgnoreCase(doDeleteLocal)) {
                this.deleteLocal(repository, fileSet, version);
            }
        }
    } else {
        // update only interested files already on the local disk
        for (int i = 0; i < updateFiles.size(); ++i) {
            File updateFile = (File) updateFiles.get(i);
            ScmFileSet scmFileSet = new ScmFileSet(fileSet.getBasedir(), updateFile);
            Commandline cl = createCommandLine(repository, scmFileSet, version);
            int exitCode = StarteamCommandLineUtils.executeCommandline(cl, consumer, stderr, getLogger());
            if (exitCode != 0) {
                return new UpdateScmResult(cl.toString(), "The starteam command failed.", stderr.getOutput(), false);
            }
        }
    }
    return new UpdateScmResult(null, consumer.getCheckedOutFiles());
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) Commandline(org.codehaus.plexus.util.cli.Commandline) StarteamScmProviderRepository(org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository) StarteamCommandLineUtils(org.apache.maven.scm.provider.starteam.command.StarteamCommandLineUtils) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) UpdateScmResult(org.apache.maven.scm.command.update.UpdateScmResult) StarteamCheckOutConsumer(org.apache.maven.scm.provider.starteam.command.checkout.StarteamCheckOutConsumer) File(java.io.File)

Aggregations

File (java.io.File)1 ScmFileSet (org.apache.maven.scm.ScmFileSet)1 UpdateScmResult (org.apache.maven.scm.command.update.UpdateScmResult)1 StarteamCommandLineUtils (org.apache.maven.scm.provider.starteam.command.StarteamCommandLineUtils)1 StarteamCheckOutConsumer (org.apache.maven.scm.provider.starteam.command.checkout.StarteamCheckOutConsumer)1 StarteamScmProviderRepository (org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository)1 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)1 Commandline (org.codehaus.plexus.util.cli.Commandline)1