private void transitiveDependenciesOf( Jenkins jenkins, PluginMetadata p, String v, List<PluginMetadata> result) { for (Dependency d : p.getDependencies()) { if (d.optional || !shouldBeIncluded(jenkins, d)) continue; PluginMetadata depMetaData = plugins.get(d.name); if (depMetaData == null) { throw new UnableToResolveDependencies( String.format("Unable to install dependency '%s' for '%s': plugin not found", d, p)); } transitiveDependenciesOf(jenkins, depMetaData, d.version, result); } if (!result.contains(p)) { if (p.requiredCore().isNewerThan(jenkins.getVersion())) { // If latest version is too new for current Jenkins, use the declared one result.add(p.withVersion(v)); } else { result.add(p); } } }