in maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScm.java [74:142]
public ReleaseResult execute(
ReleaseDescriptor releaseDescriptor,
ReleaseEnvironment releaseEnvironment,
List<MavenProject> reactorProjects)
throws ReleaseExecutionException, ReleaseFailureException {
ReleaseResult releaseResult;
if (releaseDescriptor.isLocalCheckout()) {
// in the release phase we have to change the checkout URL
// to do a local checkout instead of going over the network.
// the first step is a bit tricky, we need to know which provider! like e.g. "scm:jgit:http://"
// the offset of 4 is because 'scm:' has 4 characters...
String providerPart = releaseDescriptor
.getScmSourceUrl()
.substring(0, releaseDescriptor.getScmSourceUrl().indexOf(':', 4));
String scmPath = releaseDescriptor.getWorkingDirectory();
// now we iteratively try to checkout.
// if the local checkout fails, then we might be in a subdirectory
// and need to walk a few directories up.
do {
try {
if (scmPath.startsWith("/")) {
// cut off the first '/'
scmPath = scmPath.substring(1);
}
String scmUrl = providerPart + ":file:///" + scmPath;
releaseDescriptor.setScmSourceUrl(scmUrl);
getLogger().info("Performing a LOCAL checkout from " + releaseDescriptor.getScmSourceUrl());
releaseResult = performCheckout(releaseDescriptor, releaseEnvironment, reactorProjects);
} catch (ScmException scmEx) {
// the checkout from _this_ directory failed
releaseResult = null;
}
if (releaseResult == null || releaseResult.getResultCode() == ReleaseResult.ERROR) {
// this means that there is no SCM repo in this directory
// thus we try to step one directory up
releaseResult = null;
// remove last sub-directory path
int lastSlashPos = scmPath.lastIndexOf(File.separator);
if (lastSlashPos > 0) {
scmPath = scmPath.substring(0, lastSlashPos);
} else {
throw new ReleaseExecutionException("could not perform a local checkout");
}
}
} while (releaseResult == null);
} else {
// when there is no localCheckout, then we just do a standard SCM checkout.
try {
releaseResult = performCheckout(releaseDescriptor, releaseEnvironment, reactorProjects);
} catch (ScmException e) {
releaseResult = new ReleaseResult();
releaseResult.setResultCode(ReleaseResult.ERROR);
logError(releaseResult, e.getMessage());
throw new ReleaseExecutionException(
"An error is occurred in the checkout process: " + e.getMessage(), e);
}
}
return releaseResult;
}