Search in sources :

Example 31 with CommandParameters

use of org.apache.maven.scm.CommandParameters in project maven-plugins by apache.

the class AbstractScmPublishMojo method addFiles.

/**
 * Add files to scm.
 *
 * @param added files to be added
 * @throws MojoFailureException
 * @throws MojoExecutionException
 */
protected void addFiles(Collection<File> added) throws MojoFailureException, MojoExecutionException {
    List<File> addedList = new ArrayList<File>();
    Set<File> createdDirs = new HashSet<File>();
    Set<File> dirsToAdd = new TreeSet<File>();
    createdDirs.add(relativize(checkoutDirectory, checkoutDirectory));
    for (File f : added) {
        for (File dir = f.getParentFile(); !dir.equals(checkoutDirectory); dir = dir.getParentFile()) {
            File relativized = relativize(checkoutDirectory, dir);
            // we do the best we can with the directories
            if (createdDirs.add(relativized)) {
                dirsToAdd.add(relativized);
            } else {
                break;
            }
        }
        addedList.add(relativize(checkoutDirectory, f));
    }
    if (addUniqueDirectory) {
        // add one directory at a time
        for (File relativized : dirsToAdd) {
            try {
                ScmFileSet fileSet = new ScmFileSet(checkoutDirectory, relativized);
                getLog().info("scm add directory: " + relativized);
                AddScmResult addDirResult = scmProvider.add(scmRepository, fileSet, "Adding directory");
                if (!addDirResult.isSuccess()) {
                    getLog().warn(" Error adding directory " + relativized + ": " + addDirResult.getCommandOutput());
                }
            } catch (ScmException e) {
            // 
            }
        }
    } else {
        // add all directories in one command
        try {
            List<File> dirs = new ArrayList<File>(dirsToAdd);
            ScmFileSet fileSet = new ScmFileSet(checkoutDirectory, dirs);
            getLog().info("scm add directories: " + dirs);
            AddScmResult addDirResult = scmProvider.add(scmRepository, fileSet, "Adding directories");
            if (!addDirResult.isSuccess()) {
                getLog().warn(" Error adding directories " + dirs + ": " + addDirResult.getCommandOutput());
            }
        } catch (ScmException e) {
        // 
        }
    }
    // remove directories already added !
    addedList.removeAll(dirsToAdd);
    ScmFileSet addedFileSet = new ScmFileSet(checkoutDirectory, addedList);
    getLog().info("scm add files: " + addedList);
    try {
        CommandParameters commandParameters = new CommandParameters();
        commandParameters.setString(CommandParameter.MESSAGE, "Adding new site files.");
        commandParameters.setString(CommandParameter.FORCE_ADD, Boolean.TRUE.toString());
        checkScmResult(scmProvider.add(scmRepository, addedFileSet, commandParameters), "add new files to SCM");
    } catch (ScmException e) {
        throw new MojoExecutionException("Failed to add new files to SCM", e);
    }
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) ScmException(org.apache.maven.scm.ScmException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) TreeSet(java.util.TreeSet) AddScmResult(org.apache.maven.scm.command.add.AddScmResult) ArrayList(java.util.ArrayList) CommandParameters(org.apache.maven.scm.CommandParameters) File(java.io.File) HashSet(java.util.HashSet)

Example 32 with CommandParameters

use of org.apache.maven.scm.CommandParameters in project maven-scm by apache.

the class AbstractScmProvider method unedit.

/**
 * {@inheritDoc}
 */
public UnEditScmResult unedit(ScmRepository repository, ScmFileSet fileSet) throws ScmException {
    login(repository, fileSet);
    CommandParameters parameters = new CommandParameters();
    return unedit(repository.getProviderRepository(), fileSet, parameters);
}
Also used : CommandParameters(org.apache.maven.scm.CommandParameters)

Example 33 with CommandParameters

use of org.apache.maven.scm.CommandParameters in project maven-scm by apache.

the class AbstractScmProvider method list.

/**
 * {@inheritDoc}
 */
public ListScmResult list(ScmRepository repository, ScmFileSet fileSet, boolean recursive, ScmVersion scmVersion) throws ScmException {
    login(repository, fileSet);
    CommandParameters parameters = new CommandParameters();
    parameters.setString(CommandParameter.RECURSIVE, Boolean.toString(recursive));
    if (scmVersion != null) {
        parameters.setScmVersion(CommandParameter.SCM_VERSION, scmVersion);
    }
    return list(repository.getProviderRepository(), fileSet, parameters);
}
Also used : CommandParameters(org.apache.maven.scm.CommandParameters)

Example 34 with CommandParameters

use of org.apache.maven.scm.CommandParameters in project maven-scm by apache.

the class AbstractScmProvider method status.

/**
 * {@inheritDoc}
 */
public StatusScmResult status(ScmRepository repository, ScmFileSet fileSet) throws ScmException {
    login(repository, fileSet);
    CommandParameters parameters = new CommandParameters();
    return status(repository.getProviderRepository(), fileSet, parameters);
}
Also used : CommandParameters(org.apache.maven.scm.CommandParameters)

Example 35 with CommandParameters

use of org.apache.maven.scm.CommandParameters in project maven-scm by apache.

the class AbstractScmProvider method remove.

/**
 * {@inheritDoc}
 */
public RemoveScmResult remove(ScmRepository repository, ScmFileSet fileSet, String message) throws ScmException {
    login(repository, fileSet);
    CommandParameters parameters = new CommandParameters();
    parameters.setString(CommandParameter.MESSAGE, message == null ? "" : message);
    return remove(repository.getProviderRepository(), fileSet, parameters);
}
Also used : CommandParameters(org.apache.maven.scm.CommandParameters)

Aggregations

CommandParameters (org.apache.maven.scm.CommandParameters)68 ScmFileSet (org.apache.maven.scm.ScmFileSet)44 File (java.io.File)39 AbstractAccuRevCommandTest (org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)38 Test (org.junit.Test)38 ScmFileMatcher.assertHasScmFile (org.apache.maven.scm.ScmFileMatcher.assertHasScmFile)23 ScmFile (org.apache.maven.scm.ScmFile)8 ScmTag (org.apache.maven.scm.ScmTag)7 CheckOutScmResult (org.apache.maven.scm.command.checkout.CheckOutScmResult)7 Date (java.util.Date)6 ChangeFile (org.apache.maven.scm.ChangeFile)5 ChangeFileMatcher.changeFile (org.apache.maven.scm.ChangeFileMatcher.changeFile)5 ScmRevision (org.apache.maven.scm.ScmRevision)5 ExportScmResult (org.apache.maven.scm.command.export.ExportScmResult)5 InfoScmResult (org.apache.maven.scm.command.info.InfoScmResult)5 LoginScmResult (org.apache.maven.scm.command.login.LoginScmResult)5 AccuRevInfo (org.apache.maven.scm.provider.accurev.AccuRevInfo)5 Transaction (org.apache.maven.scm.provider.accurev.Transaction)5 ArrayList (java.util.ArrayList)4 ScmException (org.apache.maven.scm.ScmException)4