/** Returns returns {@link Dependencies} instance which helps to manage project dependencies */ public Dependencies dependencies() { if (dependencies == null) { dependencies = new Dependencies(root); } return dependencies; }
/** * Adds new dependency to the end of dependencies list. * * <p>Creates dependencies tag if element doesn't have dependencies yet * * @param dependency new dependency which will be added to the end of dependencies list */ public Dependencies add(Dependency dependency) { dependencies.add(requireNonNull(dependency, "Required not null dependency")); if (!isNew()) { addDependencyToXML(dependency); } return this; }
/** * Removes dependency from the list of existing dependencies. * * @param dependency dependency which should be removed */ public Dependencies remove(Dependency dependency) { if (dependencies().remove(requireNonNull(dependency, "Required not null dependency")) && !isNew()) { removeDependencyFromXML(dependency); } return this; }
/** * Sets dependencies associated with a project. * * <p>These dependencies are used to construct a classpath for your project during the build * process. They are automatically downloaded from the repositories defined in this project. See * <a * href="http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html">the * dependency mechanism</a> for more information. */ public Dependencies set(Collection<? extends Dependency> newDependencies) { if (newDependencies == null || newDependencies.isEmpty()) { removeDependencies(); } else if (isNew()) { dependencies = new ArrayList<>(newDependencies); } else { setDependencies(newDependencies); } return this; }
private void setDependencies(Collection<? extends Dependency> newDependencies) { // removing all dependencies from xml tree for (Dependency dependency : dependencies) { dependency.remove(); } // add and associate each new dependency with element in tree dependencies = new ArrayList<>(newDependencies.size()); for (Dependency newDependency : newDependencies) { add(newDependency); } }
public List<Dependency> getDependencies() { return dependencies == null ? emptyList() : dependencies.get(); }
/** Returns list of dependencies */ public List<Dependency> get() { return new ArrayList<>(dependencies()); }
private void removeDependencies() { if (!isNew()) { dependenciesParent.removeChild("dependencies"); } this.dependencies = null; }
NewElement asXMLElement() { return createElement("dependencyManagement", dependencies.asXMLElement()); } }
model .dependencies() .add(new Dependency(extension.groupId, extension.artifactId, extension.artifactVersion)); model.writeTo(pom);
/** * 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(); }
/** Returns selected dependencies or {@code null} if nothing was selected */ public Dependency first() { return dependencies().isEmpty() ? null : dependencies.get(0); }
/** Returns returns {@link Dependencies} instance which helps to manage project dependencies */ public Dependencies dependencies() { if (dependencies == null) { dependencies = new Dependencies(dmElement); } return dependencies; }
/** * 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(); }
/** Returns last selected dependency or {@code null} if nothing was selected */ public Dependency last() { return dependencies().isEmpty() ? null : dependencies.get(dependencies.size() - 1); }
public Profile setDependencies(List<Dependency> dependencies) { this.dependencies = new Dependencies(element, dependencies); return this; }
/** 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; }
DependencyManagement(Element element, List<Dependency> dependencies) { this.dmElement = element; this.dependencies = new Dependencies(element, dependencies); }
if (element.hasSingleChild("dependencies") && elementDependencies != null) { final List<Dependency> dependencies = elementDependencies.getChildren(TO_DEPENDENCY_MAPPER); this.dependencies = new Dependencies(element, dependencies);
final List<Dependency> dependencies = tree.getElements("/project/dependencies/dependency", TO_DEPENDENCY_MAPPER); model.dependencies = new Dependencies(root, dependencies);