protected void transformScm()

in maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RewritePomsForBranchPhase.java [66:107]


    protected void transformScm(
            MavenProject project,
            Model modelTarget,
            ReleaseDescriptor releaseDescriptor,
            String projectId,
            ScmRepository scmRepository,
            ReleaseResult result)
            throws ReleaseExecutionException {
        // If SCM is null in original model, it is inherited, no mods needed
        if (project.getScm() != null) {
            Scm scmRoot = modelTarget.getScm();

            if (scmRoot != null) {
                try {
                    translateScm(project, releaseDescriptor, scmRoot, scmRepository, result);
                } catch (IOException e) {
                    throw new ReleaseExecutionException(e.getMessage(), e);
                }
            } else {
                MavenProject parent = project.getParent();
                if (parent != null) {
                    // If the SCM element is not present, only add it if the parent was not mapped (ie, it's external to
                    // the release process and so has not been modified, so the values will not be correct on the tag),
                    String parentId = ArtifactUtils.versionlessKey(parent.getGroupId(), parent.getArtifactId());
                    if (!releaseDescriptor.hasOriginalScmInfo(parentId)) {
                        // we need to add it, since it has changed from the inherited value
                        scmRoot = new Scm();
                        // reset default value (HEAD)
                        scmRoot.setTag(null);

                        try {
                            if (translateScm(project, releaseDescriptor, scmRoot, scmRepository, result)) {
                                modelTarget.setScm(scmRoot);
                            }
                        } catch (IOException e) {
                            throw new ReleaseExecutionException(e.getMessage(), e);
                        }
                    }
                }
            }
        }
    }