protected void updatePropertyToNewestVersion( ModifiedPomXMLEventReader pom, Property property, PropertyVersions version, String currentVersion) throws MojoExecutionException, XMLStreamException { ArtifactVersion winner = version.getNewestVersion( currentVersion, property, this.allowSnapshots, this.reactorProjects, this.getHelper()); if (winner == null || currentVersion.equals(winner.toString())) { getLog() .info("Property ${" + property.getName() + "}: Leaving unchanged as " + currentVersion); } else if (PomHelper.setPropertyVersion( pom, version.getProfileId(), property.getName(), winner.toString())) { getLog() .info("Updated ${" + property.getName() + "} from " + currentVersion + " to " + winner); } }
public void execute() throws MojoExecutionException, MojoFailureException { List<String> current = new ArrayList<String>(); List<String> updates = new ArrayList<String>(); Map<Property, PropertyVersions> propertyVersions = this.getHelper() .getVersionPropertiesMap( getProject(), properties, includeProperties, excludeProperties, !Boolean.FALSE.equals(autoLinkItems)); for (Map.Entry<Property, PropertyVersions> entry : propertyVersions.entrySet()) { Property property = entry.getKey(); PropertyVersions version = entry.getValue(); final String currentVersion = getProject().getProperties().getProperty(property.getName()); if (currentVersion == null) { continue; } ArtifactVersion winner = version.getNewestVersion( currentVersion, property, this.allowSnapshots, this.reactorProjects, this.getHelper()); if (winner != null && !currentVersion.equals(winner.toString())) { StringBuilder buf = new StringBuilder(); buf.append("${"); buf.append(property.getName()); buf.append("} "); final String newVersion = winner.toString(); int padding = INFO_PAD_SIZE - currentVersion.length() - newVersion.length() - 4; while (buf.length() < padding) { buf.append('.'); } buf.append(' '); buf.append(currentVersion); buf.append(" -> "); buf.append(newVersion); updates.add(buf.toString()); } else { StringBuilder buf = new StringBuilder(); buf.append("${"); buf.append(property.getName()); buf.append("} "); int padding = INFO_PAD_SIZE - currentVersion.length(); while (buf.length() < padding) { buf.append('.'); } buf.append(' '); buf.append(currentVersion); current.add(buf.toString()); } } getLog().info(""); if (!current.isEmpty()) { getLog() .info("The following version properties are referencing the newest available version:"); for (String s : current) { getLog().info(" " + s); } } if (updates.isEmpty() && current.isEmpty()) { getLog().info("This project does not have any properties associated with versions."); } else if (updates.isEmpty()) { getLog().info("All version properties are referencing the newest version available."); } if (!updates.isEmpty()) { getLog().info("The following version property updates are available:"); for (String update : updates) { getLog().info(" " + update); } } getLog().info(""); }