artifactId = ReleaseUtil.interpolate(artifactIdElement.getTextTrim(),projectModel);
}
catch (ReleaseExecutionException e)
{
throw new ProjectRewriteException("error interpolating pom variable: " + e.getMessage(),e);
}
String artifactKey = ArtifactUtils.versionlessKey(groupId,artifactId);
String mappedVersion = releaseVersions.get(artifactKey);
String originalVersion = originalVersions.get(artifactKey);
if(null != mappedVersion
&& mappedVersion.endsWith(Artifact.SNAPSHOT_VERSION)
&& !rawVersion.endsWith(Artifact.SNAPSHOT_VERSION)
&& !updateDependencies)
{
continue;
}
if(null != mappedVersion)
{
if(rawVersion.equals(originalVersion))
{
workLog.append(LF).append("updating ").append(artifactId).append(" to ").append(mappedVersion);
versionElement.setText(mappedVersion);
modified = true;
}
else if(rawVersion.matches("\\$\\{.+\\}"))
{
String propName = rawVersion.substring(2,rawVersion.length() - 1);
if(propName.startsWith("project.")
|| propName.startsWith("pom.")
|| "version".equals(propName)
)
{
if(!mappedVersion.equals(releaseVersions.get(projectId)))
{
workLog.append(LF).append("updating ").append(artifactId).append(" to ").append(mappedVersion);
versionElement.setText(mappedVersion);
modified = true;
}
}
else if(null != properties)
{
Element prop = properties.getChild(propName, ns);
if(null != prop)
{
String propValue = prop.getTextTrim();
if(propValue.equals(originalVersion))
{
workLog.append(LF).append("updating ").append(rawVersion).append(" to ").append(mappedVersion);
prop.setText(mappedVersion);
modified = true;
}
else if(!mappedVersion.equals(rawVersion))
{
if(!mappedVersion.matches("\\$\\{project.+\\}")
&& !mappedVersion.matches("\\$\\{pom.+\\}")
&& !"${version}".equals(mappedVersion))
{
throw new ProjectRewriteException("The artifact (" + artifactKey + ") requires a "
+ "different version (" + mappedVersion + ") than what is found ("
+ propValue + ") for the expression (" + propName + ") in the "
+ "project (" + projectId + ").");
}
}
}
else
{
throw new ProjectRewriteException("Error updating version '" + rawVersion + "' for artifact " + artifactKey);
}
}
}
}
}