in maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RewritePomsForReleasePhase.java [108:215]
private boolean translateScm(
MavenProject project,
ReleaseDescriptor releaseDescriptor,
Scm scmTarget,
ScmRepository scmRepository,
ReleaseResult relResult)
throws IOException {
ScmTranslator translator = getScmTranslators().get(scmRepository.getProvider());
boolean result = false;
if (translator != null) {
Scm scm = project.getOriginalModel().getScm();
if (scm == null) {
scm = project.getScm();
}
String tag = releaseDescriptor.getScmReleaseLabel();
String tagBase = releaseDescriptor.getScmTagBase();
// TODO: svn utils should take care of prepending this
if (tagBase != null) {
tagBase = "scm:svn:" + tagBase;
}
Path projectBasedir = project.getBasedir().toPath().toRealPath(LinkOption.NOFOLLOW_LINKS);
Path workingDirectory = Paths.get(releaseDescriptor.getWorkingDirectory());
int count = ReleaseUtil.getBaseWorkingDirectoryParentCount(workingDirectory, projectBasedir);
if (scm.getConnection() != null) {
String rootUrl = ReleaseUtil.realignScmUrl(count, scm.getConnection());
String subDirectoryTag = scm.getConnection().substring(rootUrl.length());
if (!subDirectoryTag.startsWith("/")) {
subDirectoryTag = "/" + subDirectoryTag;
}
String scmConnectionTag = tagBase;
if (scmConnectionTag != null) {
String trunkUrl = scm.getDeveloperConnection();
if (trunkUrl == null) {
trunkUrl = scm.getConnection();
}
scmConnectionTag = translateUrlPath(trunkUrl, tagBase, scm.getConnection());
}
String value = translator.translateTagUrl(scm.getConnection(), tag + subDirectoryTag, scmConnectionTag);
if (!value.equals(scm.getConnection())) {
scmTarget.setConnection(value);
result = true;
}
}
if (scm.getDeveloperConnection() != null) {
String rootUrl = ReleaseUtil.realignScmUrl(count, scm.getDeveloperConnection());
String subDirectoryTag = scm.getDeveloperConnection().substring(rootUrl.length());
if (!subDirectoryTag.startsWith("/")) {
subDirectoryTag = "/" + subDirectoryTag;
}
String value = translator.translateTagUrl(scm.getDeveloperConnection(), tag + subDirectoryTag, tagBase);
if (!value.equals(scm.getDeveloperConnection())) {
scmTarget.setDeveloperConnection(value);
result = true;
}
}
if (scm.getUrl() != null) {
String rootUrl = ReleaseUtil.realignScmUrl(count, scm.getUrl());
String subDirectoryTag = scm.getUrl().substring(rootUrl.length());
if (!subDirectoryTag.startsWith("/")) {
subDirectoryTag = "/" + subDirectoryTag;
}
String tagScmUrl = tagBase;
if (tagScmUrl != null) {
String trunkUrl = scm.getDeveloperConnection();
if (trunkUrl == null) {
trunkUrl = scm.getConnection();
}
tagScmUrl = translateUrlPath(trunkUrl, tagBase, scm.getUrl());
}
// use original tag base without protocol
String value = translator.translateTagUrl(scm.getUrl(), tag + subDirectoryTag, tagScmUrl);
if (!value.equals(scm.getUrl())) {
scmTarget.setUrl(value);
result = true;
}
}
if (tag != null) {
String value = translator.resolveTag(tag);
if (value != null && !value.equals(scm.getTag())) {
scmTarget.setTag(value);
result = true;
}
}
} else {
String message = "No SCM translator found - skipping rewrite";
relResult.appendDebug(message);
getLogger().debug(message);
}
return result;
}