use of org.apache.maven.scm.ScmResult in project maven-plugins by apache.
the class AbstractScmPublishMojo method checkoutExisting.
protected void checkoutExisting() throws MojoExecutionException {
if (scmProvider instanceof AbstractSvnScmProvider) {
checkCreateRemoteSvnPath();
}
logInfo("%s the pub tree from %s into %s", (tryUpdate ? "Updating" : "Checking out"), pubScmUrl, checkoutDirectory);
if (checkoutDirectory.exists() && !tryUpdate) {
try {
FileUtils.deleteDirectory(checkoutDirectory);
} catch (IOException e) {
logError(e.getMessage());
throw new MojoExecutionException("Unable to remove old checkout directory: " + e.getMessage(), e);
}
}
boolean forceCheckout = false;
if (!checkoutDirectory.exists()) {
if (tryUpdate) {
logInfo("TryUpdate is configured but no local copy currently available: forcing checkout.");
}
checkoutDirectory.mkdirs();
forceCheckout = true;
}
try {
ScmFileSet fileSet = new ScmFileSet(checkoutDirectory, includes, excludes);
ScmBranch branch = (scmBranch == null) ? null : new ScmBranch(scmBranch);
ScmResult scmResult = null;
if (tryUpdate && !forceCheckout) {
scmResult = scmProvider.update(scmRepository, fileSet, branch);
} else {
int attempt = 0;
while (scmResult == null) {
try {
scmResult = scmProvider.checkOut(scmRepository, fileSet, branch);
} catch (ScmException e) {
// give it max 2 times to retry
if (attempt++ < 2) {
try {
// wait 3 seconds
Thread.sleep(3 * 1000);
} catch (InterruptedException ie) {
// noop
}
} else {
throw e;
}
}
}
}
checkScmResult(scmResult, "check out from SCM");
} catch (ScmException e) {
logError(e.getMessage());
throw new MojoExecutionException("An error occurred during the checkout process: " + e.getMessage(), e);
} catch (IOException e) {
logError(e.getMessage());
throw new MojoExecutionException("An error occurred during the checkout process: " + e.getMessage(), e);
}
}
Aggregations