/** * Adds an dependency to the give package if it is not already contained in the given list. version ranges are * current ignored. * * @param deps the original dependencies * @param dep the dependency to add * @return the new array of dependencies, or {@code deps} if nothing changed. */ public static Dependency[] add(@Nonnull Dependency[] deps, @Nonnull Dependency dep) { for (Dependency d: deps) { if (d.getName().equals(dep.getName()) && d.getGroup().equals(dep.getGroup())) { return deps; } } Dependency[] newDeps = new Dependency[deps.length + 1]; System.arraycopy(deps, 0, newDeps, 0, deps.length); newDeps[deps.length] = dep; return newDeps; }