boolean rewritePropertyUsedInVersionExpression()

in maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRewritePomsPhase.java [642:704]


    boolean rewritePropertyUsedInVersionExpression(
            String projectKey,
            String artifactKey,
            String rawVersion,
            String mappedVersion,
            String originalVersion,
            String property,
            Properties properties,
            ReleaseResult result,
            ReleaseDescriptor releaseDescriptor)
            throws ReleaseFailureException {
        if (properties == null) {
            logInfo(
                    result,
                    "  Ignoring artifact version update for " + artifactKey + " as expression " + rawVersion
                            + " cannot be locally resolved");
            return false;
        }
        // check for value of property
        boolean isUpdated = false;
        String propertyValue = properties.getProperty(property);
        if (propertyValue != null) {
            if (propertyValue.equals(originalVersion)) {
                logInfo(result, "  Updating " + rawVersion + " to " + mappedVersion);
                // change the property only if the property is the same as what's in the reactor
                properties.setProperty(property, mappedVersion);
                isUpdated = true;
            } else if (mappedVersion.equals(propertyValue)) {
                // this property may have been updated during processing a sibling.
                logInfo(
                        result,
                        "  Ignoring artifact version update for expression " + rawVersion
                                + " because it is already updated");
            } else if (!mappedVersion.equals(rawVersion)) {
                // WARNING: ${pom.*} prefix support and ${version} is about to be dropped in mvn4!
                // https://issues.apache.org/jira/browse/MNG-7404
                // https://issues.apache.org/jira/browse/MNG-7244
                if (mappedVersion.matches("\\$\\{project.+\\}")
                        || mappedVersion.matches("\\$\\{pom.+\\}")
                        || "${version}".equals(mappedVersion)) {
                    logInfo(result, "  Ignoring artifact version update for expression " + mappedVersion);
                    // ignore... we cannot update this expression
                } else {
                    // the value of the expression conflicts with what the user wanted to release
                    throw new ReleaseFailureException("The artifact (" + artifactKey + ") requires a "
                            + "different version (" + mappedVersion + ") than what is found ("
                            + propertyValue + ") for the expression (" + rawVersion + ") in the "
                            + "project (" + projectKey + ").");
                }
            }
        } else {
            if (CI_FRIENDLY_PROPERTIES.contains(property)) {
                logInfo(result, "  Ignoring artifact version update for CI friendly expression " + rawVersion);
            } else {
                // the expression used to define the version of this artifact may be inherited
                logInfo(
                        result,
                        "  Ignoring artifact version update for " + artifactKey + " as expression " + rawVersion
                                + " cannot be locally resolved");
            }
        }
        return isUpdated;
    }