/** * Returns the child node with the given tag name, creating it if it does * not exist. * * @param tagName the child tag to look for and possibly create (required) * @param parent the parent in which to look for the child (required) * @param document the document containing the parent (required) * @return the existing or created child (never <code>null</code>) * @since 1.2.0 */ public static Element createChildIfNotExists(final String tagName, final Node parent, final Document document) { final Element existingChild = XmlUtils.findFirstElement(tagName, parent); if (existingChild != null) { return existingChild; } // No such child; add it return createChildElement(tagName, parent, document); }
/** * Returns the Maven POM element for this resource * * @param document the POM document (required) * @return a non-<code>null</code> element */ public Element getElement(final Document document) { final Element resourceElement = document.createElement("resource"); resourceElement.appendChild(XmlUtils.createTextElement(document, "directory", directory)); if (filtering != null) { resourceElement.appendChild(XmlUtils.createTextElement(document, "filtering", filtering.toString())); } if (!includes.isEmpty()) { final Element includes = DomUtils.createChildElement("includes", resourceElement, document); for (final String include : this.includes) { includes.appendChild(XmlUtils.createTextElement(document, "include", include)); } } return resourceElement; }
/** * Returns the XML element for this execution within the given Maven POM * * @param document the Maven POM to which to add the element (required) * @return a non-<code>null</code> element */ public Element getElement(final Document document) { final Element executionElement = document.createElement("execution"); // ID if (StringUtils.isNotBlank(id)) { executionElement.appendChild(XmlUtils.createTextElement(document, "id", id)); } // Phase if (StringUtils.isNotBlank(phase)) { executionElement.appendChild(XmlUtils.createTextElement(document, "phase", phase)); } // Goals final Element goalsElement = DomUtils.createChildElement("goals", executionElement, document); for (final String goal : goals) { goalsElement.appendChild(XmlUtils.createTextElement(document, "goal", goal)); } // Configuration if (configuration != null) { final Node configurationNode = document.importNode(configuration.getConfiguration(), true); executionElement.appendChild(configurationNode); } return executionElement; }
DomUtils.createChildElement("executions", pluginElement, document); for (final Execution execution : executions) { executionsElement.appendChild(execution.getElement(document)); DomUtils.createChildElement("dependencies", pluginElement, document); for (final Dependency dependency : dependencies) { dependenciesElement.appendChild(dependency.getElement(document));
DomUtils.createChildElement("exclusions", dependencyElement, document); for (final Dependency exclusion : exclusions) { final Element exclusionElement = DomUtils.createChildElement("exclusion", exclusionsElement, document); exclusionElement.appendChild(XmlUtils.createTextElement(document, "groupId", exclusion.getGroupId()));
DomUtils.getChildElementByTagName(root, VERSION_ELEMENT); if (existingVersionElement == null) { DomUtils.createChildElement(VERSION_ELEMENT, root, pom).setTextContent(DEFAULT_VERSION);