Ejemplo n.º 1
0
 /**
  * Locates any dependencies which match the presented dependency, excluding the version number.
  * This is useful for upgrade use cases, where it is necessary to remove any dependencies with the
  * same group id, artifact id, and type as the dependency being upgraded to.
  *
  * @param dependency to locate (can be <code>null</code>)
  * @return any matching dependencies (never returns null, but may return an empty {@link Set})
  */
 public Set<Dependency> getDependenciesExcludingVersion(final Dependency dependency) {
   final Set<Dependency> result = new HashSet<Dependency>();
   for (final Dependency d : dependencies) {
     if (dependency != null
         && dependency.getArtifactId().equals(d.getArtifactId())
         && dependency.getGroupId().equals(d.getGroupId())
         && dependency.getType().equals(d.getType())) {
       result.add(d);
     }
   }
   return result;
 }
Ejemplo n.º 2
0
 /**
  * Indicates whether it's valid to add the given {@link Dependency} to this POM.
  *
  * @param newDependency the {@link Dependency} to check (can be <code>null</code>)
  * @return see above
  * @since 1.2.1
  */
 public boolean canAddDependency(final Dependency newDependency) {
   return newDependency != null
       && !isDependencyRegistered(newDependency, false)
       && !Dependency.isHigherLevel(newDependency.getType().toString(), packaging);
 }