/** * Returns list of dependencies or empty list if project doesn't have dependencies. * * <p><b>Note: update methods should not be used on returned list</b> * * @see #dependencies() */ public List<Dependency> getDependencies() { return dependencies().get(); }
/** * Sets default dependency information for projects that inherit from this one. If new dependency * management is {@code null} removes old dependency management from profile and from xml as well * * @param dependencyManagement new project dependency management * @return this profile instance */ public Profile setDependencyManagement(DependencyManagement dependencyManagement) { this.dependencyManagement = dependencyManagement; if (dependencyManagement == null) { element.removeChild("dependencyManagement"); } else { final Element dependencyManagementElement = element.getSingleChild("dependencyManagement"); if (element.hasSingleChild("dependencyManagement") && dependencyManagementElement != null) { dependencyManagement.dmElement = dependencyManagementElement.replaceWith(dependencyManagement.asXMLElement()); } else { element.insertChild( this.dependencyManagement.asXMLElement(), beforeAnyOf("dependencies").or(inTheEnd())); dependencyManagement.dmElement = dependencyManagementElement; } } return this; }
final List<Dependency> dependencies = dependencyManagementDependencies.getChildren(TO_DEPENDENCY_MAPPER); this.dependencyManagement = new DependencyManagement(dm, dependencies);
/** Returns profile element as XML element. */ public NewElement asXMLElement() { final NewElement profile = createElement("profile"); if (!isNullOrEmpty(id)) { profile.appendChild(createElement("id", id)); } if (modules != null && !modules.isEmpty()) { profile.appendChild(newModulesXMLElement(modules)); } if (activation != null) { profile.appendChild(activation.asXMLElement()); } if (build != null) { profile.appendChild(build.asXMLElement()); } if (repositories != null && !repositories.isEmpty()) { profile.appendChild(newRepositoryElement(repositories)); } if (dependencies != null && !dependencies.get().isEmpty()) { profile.appendChild(newDependencyElement(dependencies.get())); } if (properties != null && !properties.isEmpty()) { profile.appendChild(newPropertiesElement(properties)); } if (dependencyManagement != null && !dependencyManagement.getDependencies().isEmpty()) { profile.appendChild(newDependencyManagementElement(dependencies.get())); } return profile; }
/** * Sets default dependency information for projects that inherit from this one. If new dependency * management is {@code null} removes old dependency management from model and from xml as well * * <p>The dependencies in this section are not immediately resolved. Instead, when a POM derived * from this one declares a dependency described by a matching groupId and artifactId, the version * and other values from this section are used for that dependency if they were not already * specified. If {@code parent} is {@code null} then it will be removed from model and xml as * well. * * @param dependencyManagement new project dependency management * @return this model instance */ public Model setDependencyManagement(DependencyManagement dependencyManagement) { this.dependencyManagement = dependencyManagement; if (dependencyManagement == null) { root.removeChild("dependencyManagement"); } else if (root.hasSingleChild("dependencyManagement")) { dependencyManagement.dmElement = root.getSingleChild("dependencyManagement") .replaceWith(dependencyManagement.asXMLElement()); } else { root.insertChild( this.dependencyManagement.asXMLElement(), beforeAnyOf("dependencies", "build").or(inTheEnd())); dependencyManagement.dmElement = root.getSingleChild("dependencyManagement"); } return this; }
tree.getElements( "/project/dependencyManagement/dependencies/dependency", TO_DEPENDENCY_MAPPER); model.dependencyManagement = new DependencyManagement(dm, dependencies);