use of org.apache.maven.scm.command.list.ListScmResult in project maven-scm by apache.
the class HgListCommand method executeListCommand.
/**
* {@inheritDoc}
*/
protected ListScmResult executeListCommand(ScmProviderRepository repository, ScmFileSet fileSet, boolean recursive, ScmVersion scmVersion) throws ScmException {
//
File workingDir = fileSet.getBasedir();
// build the command
String[] listCmd = new String[] { HgCommandConstants.INVENTORY_CMD };
// keep the command about in string form for reporting
StringBuilder cmd = new StringBuilder();
for (int i = 0; i < listCmd.length; i++) {
String s = listCmd[i];
cmd.append(s);
if (i < listCmd.length - 1) {
cmd.append(" ");
}
}
HgListConsumer consumer = new HgListConsumer(getLogger());
ScmResult result = HgUtils.execute(consumer, getLogger(), workingDir, listCmd);
if (result.isSuccess()) {
return new ListScmResult(consumer.getFiles(), result);
} else {
throw new ScmException("Error while executing command " + cmd.toString());
}
}
use of org.apache.maven.scm.command.list.ListScmResult in project maven-scm by apache.
the class CvsJavaListCommand method executeCvsCommand.
/**
* {@inheritDoc}
*/
protected ListScmResult executeCvsCommand(Commandline cl) throws ScmException {
CvsLogListener logListener = new CvsLogListener();
CvsListConsumer consumer = new CvsListConsumer(getLogger());
try {
boolean isSuccess = CvsConnection.processCommand(cl.getArguments(), cl.getWorkingDirectory().getAbsolutePath(), logListener, getLogger());
if (!isSuccess) {
return new ListScmResult(cl.toString(), "The cvs command failed.", logListener.getStderr().toString(), false);
}
BufferedReader stream = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(logListener.getStdout().toString().getBytes())));
String line;
while ((line = stream.readLine()) != null) {
consumer.consumeLine(line);
}
} catch (Exception e) {
e.printStackTrace();
return new ListScmResult(cl.toString(), "The cvs command failed.", logListener.getStderr().toString(), false);
}
return new ListScmResult(cl.toString(), consumer.getEntries());
}
use of org.apache.maven.scm.command.list.ListScmResult in project maven-scm by apache.
the class ListMojo method execute.
/**
* {@inheritDoc}
*/
public void execute() throws MojoExecutionException {
super.execute();
try {
ScmRepository repository = getScmRepository();
ListScmResult result = getScmManager().list(repository, getFileSet(), recursive, getScmVersion(scmVersionType, scmVersion));
checkResult(result);
if (result.getFiles() != null) {
for (ScmFile scmFile : result.getFiles()) {
getLog().info(scmFile.getPath());
}
}
} catch (ScmException e) {
throw new MojoExecutionException("Cannot run list command : ", e);
} catch (IOException e) {
throw new MojoExecutionException("Cannot run list command : ", e);
}
}
use of org.apache.maven.scm.command.list.ListScmResult in project maven-scm by apache.
the class IntegrityListCommand method executeListCommand.
/**
* {@inheritDoc}
*/
@Override
public ListScmResult executeListCommand(ScmProviderRepository repository, ScmFileSet fileSet, boolean recursive, ScmVersion scmVersion) throws ScmException {
ListScmResult result;
IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
getLogger().info("Listing all files in project " + iRepo.getConfigruationPath());
try {
// Get a listing for all the members in the project...
List<Member> projectMembers = iRepo.getProject().listFiles(fileSet.getBasedir().getAbsolutePath());
// Initialize the list of ScmFile objects for the ListScmResult
List<ScmFile> scmFileList = new ArrayList<ScmFile>();
for (Iterator<Member> it = projectMembers.iterator(); it.hasNext(); ) {
Member siMember = it.next();
scmFileList.add(new ScmFile(siMember.getTargetFilePath(), ScmFileStatus.UNKNOWN));
}
result = new ListScmResult(scmFileList, new ScmResult("si viewproject", "", "", true));
} catch (APIException aex) {
ExceptionHandler eh = new ExceptionHandler(aex);
getLogger().error("MKS API Exception: " + eh.getMessage());
getLogger().debug(eh.getCommand() + " exited with return code " + eh.getExitCode());
result = new ListScmResult(eh.getCommand(), eh.getMessage(), "Exit Code: " + eh.getExitCode(), false);
}
return result;
}
use of org.apache.maven.scm.command.list.ListScmResult in project maven-scm by apache.
the class ListCommandTckTest method testListCommandUnexistantFileTest.
public void testListCommandUnexistantFileTest() throws Exception {
ScmFileSet fileSet = new ScmFileSet(new File("."), new File("/void"));
ScmProvider provider = getScmManager().getProviderByUrl(getScmUrl());
ListScmResult result = provider.list(getScmRepository(), fileSet, false, (ScmVersion) null);
assertFalse("Found file when shouldn't", result.isSuccess());
}
Aggregations