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);
}
}
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);
}
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);
}
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);
}
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);
}
Aggregations