use of org.apache.maven.scm.command.export.ExportScmResult in project maven-scm by apache.
the class AccuRevScmProvider method checkout.
@Override
protected CheckOutScmResult checkout(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
// workaround deprecated behaviour
// TODO pull up to AbstractScmProvider
AccuRevScmProviderRepository accuRevRepo = (AccuRevScmProviderRepository) repository;
if (!repository.isPersistCheckout() && accuRevRepo.shouldUseExportForNonPersistentCheckout()) {
ExportScmResult result = export(repository, fileSet, parameters);
if (result.isSuccess()) {
return new CheckOutScmResult(result.getCommandLine(), result.getExportedFiles(), accuRevRepo.getExportRelativePath());
} else {
return new CheckOutScmResult(result.getCommandLine(), result.getProviderMessage(), result.getCommandOutput(), false);
}
}
AccuRevCheckOutCommand command = new AccuRevCheckOutCommand(getLogger());
return command.checkout(repository, fileSet, parameters);
}
use of org.apache.maven.scm.command.export.ExportScmResult in project maven-scm by apache.
the class ExportMojo method export.
protected void export() throws MojoExecutionException {
if (this.exportDirectory.getPath().contains("${project.basedir}")) {
// project.basedir is not set under maven 3.x when run without a project
this.exportDirectory = new File(this.getBasedir(), "target/export");
}
try {
ScmRepository repository = getScmRepository();
try {
if (this.exportDirectory.exists()) {
this.getLog().info("Removing " + this.exportDirectory);
FileUtils.deleteDirectory(this.exportDirectory);
}
} catch (IOException e) {
throw new MojoExecutionException("Cannot remove " + getExportDirectory());
}
if (!this.exportDirectory.mkdirs()) {
throw new MojoExecutionException("Cannot create " + this.exportDirectory);
}
ExportScmResult result = getScmManager().export(repository, new ScmFileSet(this.exportDirectory.getAbsoluteFile()), getScmVersion(scmVersionType, scmVersion));
checkResult(result);
handleExcludesIncludesAfterCheckoutAndExport(this.exportDirectory);
} catch (ScmException e) {
throw new MojoExecutionException("Cannot run export command : ", e);
}
}
use of org.apache.maven.scm.command.export.ExportScmResult in project maven-scm by apache.
the class IntegrityExportCommand method executeExportCommand.
/**
* {@inheritDoc}
*/
@Override
public ExportScmResult executeExportCommand(ScmProviderRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, String outputDirectory) throws ScmException {
// First lets figure out where we need to export files to...
String exportDir = outputDirectory;
exportDir = ((null != exportDir && exportDir.length() > 0) ? exportDir : fileSet.getBasedir().getAbsolutePath());
// Let the user know where we're going to be exporting the files...
getLogger().info("Attempting to export files to " + exportDir);
ExportScmResult result;
IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
try {
// Lets set our overall export success flag
boolean exportSuccess = true;
// Perform a fresh checkout of each file in the member list...
List<Member> projectMembers = iRepo.getProject().listFiles(exportDir);
// Initialize the list of files we actually exported...
List<ScmFile> scmFileList = new ArrayList<ScmFile>();
for (Iterator<Member> it = projectMembers.iterator(); it.hasNext(); ) {
Member siMember = it.next();
try {
getLogger().info("Attempting to export file: " + siMember.getTargetFilePath() + " at revision " + siMember.getRevision());
siMember.checkout(iRepo.getAPISession());
scmFileList.add(new ScmFile(siMember.getTargetFilePath(), ScmFileStatus.UNKNOWN));
} catch (APIException ae) {
exportSuccess = false;
ExceptionHandler eh = new ExceptionHandler(ae);
getLogger().error("MKS API Exception: " + eh.getMessage());
getLogger().debug(eh.getCommand() + " exited with return code " + eh.getExitCode());
}
}
// Lets advice the user that we've checked out all the members
getLogger().info("Exported " + scmFileList.size() + " files out of a total of " + projectMembers.size() + " files!");
if (exportSuccess) {
result = new ExportScmResult("si co", scmFileList);
} else {
result = new ExportScmResult("si co", "Failed to export all files!", "", exportSuccess);
}
} 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 ExportScmResult(eh.getCommand(), eh.getMessage(), "Exit Code: " + eh.getExitCode(), false);
}
return result;
}
use of org.apache.maven.scm.command.export.ExportScmResult in project maven-scm by apache.
the class AccuRevExportCommandTest method testExportToVersionPre490.
@Test
public void testExportToVersionPre490() throws Exception {
// info defaults to no workspace...
info.setWorkSpace(null);
when(accurev.info(basedir)).thenReturn(info);
// A version that does not support pop -t
when(accurev.getClientVersion()).thenReturn("4.7.4b");
List<File> poppedFiles = Collections.singletonList(new File("exported/file"));
when(accurev.popExternal(eq(basedir), eq("mySnapShot"), eq("now"), (Collection<File>) argThat(hasItem(new File("/./project/dir"))))).thenReturn(poppedFiles);
AccuRevExportCommand command = new AccuRevExportCommand(getLogger());
CommandParameters params = new CommandParameters();
params.setScmVersion(CommandParameter.SCM_VERSION, new ScmTag("mySnapShot/676"));
ExportScmResult result = command.export(repo, new ScmFileSet(basedir), params);
assertTrue(result.isSuccess());
assertHasScmFile(result.getExportedFiles(), "exported/file", ScmFileStatus.CHECKED_OUT);
}
use of org.apache.maven.scm.command.export.ExportScmResult in project maven-scm by apache.
the class AccuRevExportCommandTest method testExportToVersion490.
@Test
public void testExportToVersion490() throws Exception {
// info defaults to no workspace...
info.setWorkSpace(null);
when(accurev.info(basedir)).thenReturn(info);
// A version that does not support pop -t
when(accurev.getClientVersion()).thenReturn("4.9.0");
List<File> poppedFiles = Collections.singletonList(new File("exported/file"));
when(accurev.popExternal(eq(basedir), eq("mySnapShot"), eq("676"), (Collection<File>) argThat(hasItem(new File("/./project/dir"))))).thenReturn(poppedFiles);
AccuRevExportCommand command = new AccuRevExportCommand(getLogger());
CommandParameters params = new CommandParameters();
params.setScmVersion(CommandParameter.SCM_VERSION, new ScmTag("mySnapShot/676"));
ExportScmResult result = command.export(repo, new ScmFileSet(basedir), params);
assertTrue(result.isSuccess());
assertHasScmFile(result.getExportedFiles(), "exported/file", ScmFileStatus.CHECKED_OUT);
verify(accurev).syncReplica();
}
Aggregations