/** * Locates the first occurrence of a property for a given name and returns * it. * * @param name the property name (required) * @return the property if found otherwise null */ public Property getProperty(final String name) { Validate.notBlank(name, "Property name to locate is required"); for (final Property p : pomProperties) { if (name.equals(p.getName())) { return p; } } return null; }
/** * Locates any properties which match the presented property, excluding the * value. This is useful for upgrade use cases, where it is necessary to * locate any properties with the name so that they can be removed. * * @param property to locate (required; note the value is ignored in * comparisons) * @return any matching properties (never returns null, but may return an * empty {@link Set}) */ public Set<Property> getPropertiesExcludingValue(final Property property) { Validate.notNull(property, "Property to locate is required"); final Set<Property> result = new HashSet<Property>(); for (final Property p : pomProperties) { if (property.getName().equals(p.getName())) { result.add(p); } } return result; }
final String descriptionOfChange; final Element existing = XmlUtils.findFirstElement("/project/properties/" + property.getName(), root); if (existing == null) { properties.appendChild(XmlUtils.createTextElement(document, property.getName(), property.getValue())); descriptionOfChange = highlight(ADDED + " property") + " '" + property.getName() + "' = '" + property.getValue() + "'"; } else { highlight(UPDATED + " property") + " '" + property.getName() + "' to '" + property.getValue() + "'";
public void removeProperty(final String moduleName, final Property property) { Validate .isTrue(isProjectAvailable(moduleName), "Property modification prohibited at this time"); Validate.notNull(property, "Property to remove required"); final Pom pom = getPomFromModuleName(moduleName); Validate.notNull(pom, "The pom is not available, so property removal cannot be performed"); if (!pom.isPropertyRegistered(property)) { return; } final Document document = XmlUtils.readXml(fileManager.getInputStream(pom.getPath())); final Element root = document.getDocumentElement(); final Element propertiesElement = XmlUtils.findFirstElement("/project/properties", root); String descriptionOfChange = ""; for (final Element candidate : XmlUtils.findElements("/project/properties/*", document.getDocumentElement())) { if (property.equals(new Property(candidate))) { propertiesElement.removeChild(candidate); descriptionOfChange = highlight(REMOVED + " property") + " " + property.getName(); // Stay in the loop just in case it was in the POM more than // once } } DomUtils.removeTextNodes(propertiesElement); fileManager.createOrUpdateTextFileIfRequired(pom.getPath(), XmlUtils.nodeToString(document), descriptionOfChange, false); }
if (rooVersion.compareTo(bundleVersionInfo) < 0) { final Property newProperty = new Property(existingProperty.getName(), bundleVersionInfo.toString()); projectOperations.addProperty(moduleName, newProperty); break; if (springVersion.compareTo(latestSpringVersion) < 0) { final Property newProperty = new Property(existingProperty.getName(), latestSpringVersion.toString()); projectOperations.addProperty(moduleName, newProperty); break;