/** * Factory method * * @param configurationElement the XML node from which to parse the instance * (can be <code>null</code>) * @return <code>null</code> if a <code>null</code> element is given * @since 1.2.0 */ public static Configuration getInstance(final Element configurationElement) { if (configurationElement == null) { return null; } return new Configuration(configurationElement); }
@Override public boolean equals(final Object obj) { return obj instanceof Configuration && compareTo((Configuration) obj) == 0; }
/** * Parses the configuration of the given plugin (global, not * execution-scoped) * * @param plugin the XML element to parse (required) * @return <code>null</code> if there isn't one */ private static Configuration getConfiguration(final Element plugin) { return Configuration.getInstance(XmlUtils.findFirstElement("configuration", plugin)); }
/** * 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; }
@Override public int hashCode() { final int prime = 31; final int result = prime * 1 + gav.hashCode(); return prime * result + (configuration == null ? 0 : configuration.hashCode()); }
final Node configuration = document.importNode(this.configuration.getConfiguration(), true); pluginElement.appendChild(configuration);
.getConfiguration(), document); newParentElement = DomUtils.createChildIfNotExists(elementName, execution.getConfiguration() .getConfiguration(), parentDocument); elementsElement.appendChild(newParentElement); newParentElement = DomUtils.createChildIfNotExists(elementName, execution.getConfiguration() .getConfiguration(), document); elementsElement.appendChild(newParentElement);
public int compareTo(final Plugin o) { if (o == null) { throw new NullPointerException(); } int result = gav.compareTo(o.getGAV()); if (result == 0 && configuration != null && o.configuration != null) { result = configuration.compareTo(o.configuration); } return result; }
/** * Parses the given XML plugin element for the plugin's executions * * @param plugin the XML element to parse (required) * @return a non-<code>null</code> list */ private static List<Execution> getExecutions(final Element plugin) { final List<Execution> executions = new ArrayList<Execution>(); // Loop through the "execution" elements in the plugin element for (final Element execution : XmlUtils.findElements("executions/execution", plugin)) { final Element idElement = XmlUtils.findFirstElement("id", execution); final String id = DomUtils.getTextContent(idElement, ""); final Element phaseElement = XmlUtils.findFirstElement("phase", execution); final String phase = DomUtils.getTextContent(phaseElement, ""); final List<String> goals = new ArrayList<String>(); for (final Element goalElement : XmlUtils.findElements("goals/goal", execution)) { goals.add(goalElement.getTextContent()); } final Configuration configuration = Configuration.getInstance(XmlUtils.findFirstElement("configuration", execution)); executions.add(new Execution(id, phase, configuration, goals.toArray(new String[goals.size()]))); } return executions; }