private static JsonNode mapDependency(Dependency dep) { ObjectNode node = nodeFactory.objectNode(); node.put("groupId", dep.getGroupId()); node.put("artifactId", dep.getArtifactId()); if (dep.getVersion() != null) { node.put("version", dep.getVersion()); } node.put("scope", dep.getScope()); if (dep.getBom() != null) { node.put("bom", dep.getBom()); } if (dep.getRepository() != null) { node.put("repository", dep.getRepository()); } return node; }
@Override public void contribute(Info.Builder builder) { Map<String, Object> details = new LinkedHashMap<>(); this.metadataProvider.get().getDependencies().getAll().forEach((dependency) -> { if (dependency.getBom() == null) { contribute(details, dependency); } }); if (!details.isEmpty()) { builder.withDetail("dependency-ranges", details); } }
@Test void addDefaultBom() { Dependency first = Dependency.withId("first"); Dependency second = Dependency.withId("second"); second.setBom("da-bom"); DependencyGroup group = createDependencyGroup("test", first, second); group.setBom("test-bom"); DependenciesCapability capability = new DependenciesCapability(); capability.getContent().add(group); capability.validate(); assertThat(capability.get("first").getBom()).isEqualTo("test-bom"); assertThat(capability.get("second").getBom()).isEqualTo("da-bom"); }
Map<String, BillOfMaterials> boms = this.configuration.getEnv().getBoms(); for (Dependency dependency : this.dependencies.getAll()) { if (dependency.getBom() != null && !boms.containsKey(dependency.getBom())) { throw new InvalidInitializrMetadataException( "Dependency " + dependency + "defines an invalid BOM id " + dependency.getBom() + ", available boms " + boms);
private void index() { this.indexedDependencies.clear(); this.content.forEach((group) -> group.content.forEach((dependency) -> { // Apply defaults if (dependency.getVersionRange() == null && group.getVersionRange() != null) { dependency.setVersionRange(group.getVersionRange()); } if (dependency.getBom() == null && group.getBom() != null) { dependency.setBom(group.getBom()); } if (dependency.getRepository() == null && group.getRepository() != null) { dependency.setRepository(group.getRepository()); } dependency.resolve(); indexDependency(dependency.getId(), dependency); for (String alias : dependency.getAliases()) { indexDependency(alias, dependency); } })); }
@Override public void contribute(Info.Builder builder) { Map<String, Object> details = new LinkedHashMap<>(); this.metadataProvider.get().getDependencies().getAll().forEach((d) -> { if (d.getBom() == null) { contribute(details, d); } }); if (!details.isEmpty()) { builder.withDetail("dependency-ranges", details); } }