Search in sources :

Example 16 with StarteamScmProviderRepository

use of org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository 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)

Example 17 with StarteamScmProviderRepository

use of org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository in project maven-scm by apache.

the class StarteamChangeLogCommandTest method testCommandLine.

// ----------------------------------------------------------------------
// 
// ----------------------------------------------------------------------
private void testCommandLine(String scmUrl, ScmFileSet workingCopy, String commandLine) throws Exception {
    ScmRepository repository = getScmManager().makeScmRepository(scmUrl);
    StarteamScmProviderRepository svnRepository = (StarteamScmProviderRepository) repository.getProviderRepository();
    Commandline cl = StarteamChangeLogCommand.createCommandLine(svnRepository, workingCopy, null);
    assertCommandLine(commandLine, null, cl);
}
Also used : ScmRepository(org.apache.maven.scm.repository.ScmRepository) Commandline(org.codehaus.plexus.util.cli.Commandline) StarteamScmProviderRepository(org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository)

Example 18 with StarteamScmProviderRepository

use of org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository in project maven-scm by apache.

the class StarteamCheckInCommand method executeCheckInCommand.

// ----------------------------------------------------------------------
// AbstractCheckInCommand Implementation
// ----------------------------------------------------------------------
/**
 * {@inheritDoc}
 */
protected CheckInScmResult executeCheckInCommand(ScmProviderRepository repo, ScmFileSet fileSet, String message, ScmVersion version) throws ScmException {
    // work around until maven-scm-api allow this
    String issueType = System.getProperty("maven.scm.issue.type");
    String issueValue = System.getProperty("maven.scm.issue.value");
    String deprecatedIssue = System.getProperty("maven.scm.issue");
    if (deprecatedIssue != null && deprecatedIssue.trim().length() > 0) {
        issueType = "cr";
        issueValue = deprecatedIssue;
    }
    if (getLogger().isInfoEnabled()) {
        getLogger().info("Working directory: " + fileSet.getBasedir().getAbsolutePath());
    }
    StarteamScmProviderRepository repository = (StarteamScmProviderRepository) repo;
    StarteamCheckInConsumer consumer = new StarteamCheckInConsumer(getLogger(), fileSet.getBasedir());
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    List<File> checkInFiles = fileSet.getFileList();
    if (checkInFiles.isEmpty()) {
        Commandline cl = createCommandLine(repository, fileSet, message, version, issueType, issueValue);
        int exitCode = StarteamCommandLineUtils.executeCommandline(cl, consumer, stderr, getLogger());
        if (exitCode != 0) {
            return new CheckInScmResult(cl.toString(), "The starteam command failed.", stderr.getOutput(), false);
        }
    } else {
        // update only interested files already on the local disk
        for (int i = 0; i < checkInFiles.size(); ++i) {
            ScmFileSet checkInFile = new ScmFileSet(fileSet.getBasedir(), (File) checkInFiles.get(i));
            Commandline cl = createCommandLine(repository, checkInFile, message, version, issueType, issueValue);
            int exitCode = StarteamCommandLineUtils.executeCommandline(cl, consumer, stderr, getLogger());
            if (exitCode != 0) {
                return new CheckInScmResult(cl.toString(), "The starteam command failed.", stderr.getOutput(), false);
            }
        }
    }
    return new CheckInScmResult(null, consumer.getCheckedInFiles());
}
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) File(java.io.File) CheckInScmResult(org.apache.maven.scm.command.checkin.CheckInScmResult)

Example 19 with StarteamScmProviderRepository

use of org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository in project maven-scm by apache.

the class StarteamRemoveCommand method executeRemoveCommand.

/**
 * {@inheritDoc}
 */
protected ScmResult executeRemoveCommand(ScmProviderRepository repo, ScmFileSet fileSet, String message) throws ScmException {
    if (getLogger().isInfoEnabled()) {
        getLogger().info("Working directory: " + fileSet.getBasedir().getAbsolutePath());
    }
    StarteamScmProviderRepository repository = (StarteamScmProviderRepository) repo;
    StarteamCheckInConsumer consumer = new StarteamCheckInConsumer(getLogger(), fileSet.getBasedir());
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    List<File> remvoveFiles = fileSet.getFileList();
    if (remvoveFiles.size() == 0) {
        Commandline cl = createCommandLine(repository, fileSet);
        int exitCode = StarteamCommandLineUtils.executeCommandline(cl, consumer, stderr, getLogger());
        if (exitCode != 0) {
            return new RemoveScmResult(cl.toString(), "The starteam command failed.", stderr.getOutput(), false);
        }
    } else {
        // update only interested files already on the local disk
        for (int i = 0; i < remvoveFiles.size(); ++i) {
            File fileToBeRemoved = (File) remvoveFiles.get(i);
            ScmFileSet scmFileSet = new ScmFileSet(fileSet.getBasedir(), fileToBeRemoved);
            Commandline cl = createCommandLine(repository, scmFileSet);
            int exitCode = StarteamCommandLineUtils.executeCommandline(cl, consumer, stderr, getLogger());
            if (exitCode != 0) {
                return new RemoveScmResult(cl.toString(), "The starteam command failed.", stderr.getOutput(), false);
            }
        }
    }
    return new RemoveScmResult(null, consumer.getCheckedInFiles());
}
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) StarteamCheckInConsumer(org.apache.maven.scm.provider.starteam.command.checkin.StarteamCheckInConsumer) File(java.io.File) RemoveScmResult(org.apache.maven.scm.command.remove.RemoveScmResult)

Example 20 with StarteamScmProviderRepository

use of org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository in project maven-scm by apache.

the class StarteamCheckOutCommandTest method testCommandLine.

// ----------------------------------------------------------------------
// 
// ----------------------------------------------------------------------
private void testCommandLine(String scmUrl, ScmFileSet workingCopy, ScmVersion version, String commandLine) throws Exception {
    ScmRepository repo = getScmManager().makeScmRepository(scmUrl);
    StarteamScmProviderRepository repository = (StarteamScmProviderRepository) repo.getProviderRepository();
    Commandline cl = StarteamCheckOutCommand.createCommandLine(repository, workingCopy, version);
    assertCommandLine(commandLine, null, cl);
}
Also used : ScmRepository(org.apache.maven.scm.repository.ScmRepository) Commandline(org.codehaus.plexus.util.cli.Commandline) StarteamScmProviderRepository(org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository)

Aggregations

StarteamScmProviderRepository (org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository)24 Commandline (org.codehaus.plexus.util.cli.Commandline)22 StarteamCommandLineUtils (org.apache.maven.scm.provider.starteam.command.StarteamCommandLineUtils)11 ScmRepository (org.apache.maven.scm.repository.ScmRepository)11 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)11 File (java.io.File)6 ScmException (org.apache.maven.scm.ScmException)6 ScmFileSet (org.apache.maven.scm.ScmFileSet)6 IOException (java.io.IOException)1 AddScmResult (org.apache.maven.scm.command.add.AddScmResult)1 ChangeLogScmResult (org.apache.maven.scm.command.changelog.ChangeLogScmResult)1 ChangeLogSet (org.apache.maven.scm.command.changelog.ChangeLogSet)1 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)1 CheckOutScmResult (org.apache.maven.scm.command.checkout.CheckOutScmResult)1 DiffScmResult (org.apache.maven.scm.command.diff.DiffScmResult)1 EditScmResult (org.apache.maven.scm.command.edit.EditScmResult)1 RemoveScmResult (org.apache.maven.scm.command.remove.RemoveScmResult)1 StatusScmResult (org.apache.maven.scm.command.status.StatusScmResult)1 TagScmResult (org.apache.maven.scm.command.tag.TagScmResult)1 UnEditScmResult (org.apache.maven.scm.command.unedit.UnEditScmResult)1