io.spring.initializr.metadata.BillOfMaterials Java Examples
The following examples show how to use
io.spring.initializr.metadata.BillOfMaterials.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DependencyManagementBuildCustomizer.java From initializr with Apache License 2.0 | 6 votes |
protected void contributeDependencyManagement(Build build) { Map<String, BillOfMaterials> resolvedBoms = new LinkedHashMap<>(); Map<String, Repository> repositories = new LinkedHashMap<>(); mapDependencies(build).forEach((dependency) -> { if (dependency.getBom() != null) { resolveBom(resolvedBoms, dependency.getBom(), this.description.getPlatformVersion()); } if (dependency.getRepository() != null) { String repositoryId = dependency.getRepository(); repositories.computeIfAbsent(repositoryId, (key) -> this.metadata.getConfiguration().getEnv().getRepositories().get(key)); } }); resolvedBoms.values().forEach( (bom) -> bom.getRepositories().forEach((repositoryId) -> repositories.computeIfAbsent(repositoryId, (key) -> this.metadata.getConfiguration().getEnv().getRepositories().get(key)))); resolvedBoms.forEach((key, bom) -> { build.boms().add(key, MetadataBuildItemMapper.toBom(bom)); if (bom.getVersionProperty() != null) { build.properties().version(bom.getVersionProperty(), bom.getVersion()); } }); repositories.keySet().forEach((id) -> build.repositories().add(id)); }
Example #2
Source File: MetadataBuildItemResolverTests.java From initializr with Apache License 2.0 | 6 votes |
@Test void resoleBomWithMatchingEntryAndCompatibilityRange() throws MalformedURLException { InitializrMetadata metadata = new InitializrMetadata(); BillOfMaterials bom = BillOfMaterials.create("com.example", "bom", "0.0.1"); bom.getMappings().add(BillOfMaterials.Mapping.create("[1.0.0.RELEASE, 2.0.0.RELEASE)", "1.0.0")); bom.getMappings().add(BillOfMaterials.Mapping.create("2.0.0.RELEASE", "1.1.0")); metadata.getConfiguration().getEnv().getBoms().put("test-bom", bom); metadata.getConfiguration().getEnv().getRepositories().put("test-repo", new Repository("test", new URL("https://example.com/repo"), false)); metadata.validate(); MetadataBuildItemResolver resolver = new MetadataBuildItemResolver(metadata, VERSION_2_0_0); io.spring.initializr.generator.buildsystem.BillOfMaterials resolvedBom = resolver.resolveBom("test-bom"); assertThat(resolvedBom.getGroupId()).isEqualTo("com.example"); assertThat(resolvedBom.getArtifactId()).isEqualTo("bom"); assertThat(resolvedBom.getVersion()).hasToString("1.1.0"); }
Example #3
Source File: DependencyResolver.java From start.spring.io with Apache License 2.0 | 6 votes |
static List<String> resolveDependencies(String groupId, String artifactId, String version, List<BillOfMaterials> boms, List<RemoteRepository> repositories) { DependencyResolver instance = instanceForThread.get(); List<Dependency> managedDependencies = instance.getManagedDependencies(boms, repositories); Dependency aetherDependency = new Dependency(new DefaultArtifact(groupId, artifactId, "pom", instance.getVersion(groupId, artifactId, version, managedDependencies)), "compile"); CollectRequest collectRequest = new CollectRequest((org.eclipse.aether.graph.Dependency) null, Collections.singletonList(aetherDependency), repositories); collectRequest.setManagedDependencies(managedDependencies); DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE, JavaScopes.RUNTIME)); try { return instance.resolveDependencies(dependencyRequest).getArtifactResults().stream() .map(ArtifactResult::getArtifact) .map((artifact) -> artifact.getGroupId() + ":" + artifact.getArtifactId()) .collect(Collectors.toList()); } catch (DependencyResolutionException ex) { throw new RuntimeException(ex); } }
Example #4
Source File: VersionsFetcher.java From spring-cloud-release-tools with Apache License 2.0 | 6 votes |
private ProjectVersion latestBomVersion() { String latestVersionsUrl = this.properties.getVersions().getAllVersionsFileUrl(); InitializrProperties initializrProperties = this.toPropertiesConverter .toProperties(latestVersionsUrl); if (initializrProperties == null) { return null; } ProjectVersion springCloudVersion = initializrProperties.getEnv().getBoms() .getOrDefault( this.properties.getVersions().getBomName(), new BillOfMaterials()) .getMappings().stream() .map(mapping -> new ProjectVersion( this.properties.getVersions().getBomName(), mapping.getVersion())) .filter(ProjectVersion::isReleaseOrServiceRelease) .max(ProjectVersion::compareTo).orElse(new ProjectVersion( this.properties.getVersions().getBomName(), "")); log.info("Latest BOM version is [{}]", springCloudVersion.version); return springCloudVersion; }
Example #5
Source File: MavenBuildAssert.java From initializr with Apache License 2.0 | 6 votes |
private static BillOfMaterials toBom(Node item) { if (item instanceof Element) { Element element = (Element) item; NodeList type = element.getElementsByTagName("type"); NodeList scope = element.getElementsByTagName("scope"); if (isBom(type, scope)) { BillOfMaterials bom = new BillOfMaterials(); NodeList groupId = element.getElementsByTagName("groupId"); if (groupId.getLength() > 0) { bom.setGroupId(groupId.item(0).getTextContent()); } NodeList artifactId = element.getElementsByTagName("artifactId"); if (artifactId.getLength() > 0) { bom.setArtifactId(artifactId.item(0).getTextContent()); } NodeList version = element.getElementsByTagName("version"); if (version.getLength() > 0) { bom.setVersion(version.item(0).getTextContent()); } return bom; } } return null; }
Example #6
Source File: BomRangesInfoContributorTests.java From initializr with Apache License 2.0 | 6 votes |
@Test void withMappings() { BillOfMaterials bom = BillOfMaterials.create("com.example", "bom", "1.0.0"); bom.getMappings().add(BillOfMaterials.Mapping.create("[1.3.0.RELEASE,1.3.8.RELEASE]", "1.1.0")); bom.getMappings().add(BillOfMaterials.Mapping.create("1.3.8.BUILD-SNAPSHOT", "1.1.1-SNAPSHOT")); InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults().addBom("foo", bom).build(); Info info = getInfo(metadata); assertThat(info.getDetails()).containsKeys("bom-ranges"); @SuppressWarnings("unchecked") Map<String, Object> ranges = (Map<String, Object>) info.getDetails().get("bom-ranges"); assertThat(ranges).containsOnlyKeys("foo"); @SuppressWarnings("unchecked") Map<String, Object> foo = (Map<String, Object>) ranges.get("foo"); assertThat(foo).containsExactly(entry("1.1.0", "Spring Boot >=1.3.0.RELEASE and <=1.3.8.RELEASE"), entry("1.1.1-SNAPSHOT", "Spring Boot >=1.3.8.BUILD-SNAPSHOT")); }
Example #7
Source File: SpringCloudFunctionBuildCustomizer.java From start.spring.io with Apache License 2.0 | 6 votes |
private void removeCloudFunction(Build build) { Dependency cloudFunction = this.metadata.getDependencies().get("cloud-function"); // We should make sure whatever metadata this entry convey isn't lost // This is a workaround until we provide a feature to deal with this automatically if (cloudFunction.getBom() != null) { BillOfMaterials bom = resolveBom(cloudFunction.getBom()); if (bom != null) { build.boms().add(cloudFunction.getBom()); if (bom.getVersionProperty() != null) { build.properties().version(bom.getVersionProperty(), bom.getVersion()); } if (!ObjectUtils.isEmpty(bom.getRepositories())) { bom.getRepositories().forEach((repository) -> build.repositories().add(repository)); } } } if (cloudFunction.getRepository() != null) { build.repositories().add(cloudFunction.getRepository()); } build.dependencies().remove("cloud-function"); }
Example #8
Source File: SpringCloudCircuitBreakerBuildCustomizer.java From start.spring.io with Apache License 2.0 | 6 votes |
private void removeBlockingCloudResilience4j(Build build) { Dependency cloudResilience4j = this.metadata.getDependencies().get("cloud-resilience4j"); if (cloudResilience4j.getBom() != null) { BillOfMaterials bom = resolveBom(cloudResilience4j.getBom()); if (bom != null) { build.boms().add(cloudResilience4j.getBom()); if (bom.getVersionProperty() != null) { build.properties().version(bom.getVersionProperty(), bom.getVersion()); } if (!ObjectUtils.isEmpty(bom.getRepositories())) { bom.getRepositories().forEach((repository) -> build.repositories().add(repository)); } } } if (cloudResilience4j.getRepository() != null) { build.repositories().add(cloudResilience4j.getRepository()); } build.dependencies().remove("cloud-resilience4j"); }
Example #9
Source File: BuildComplianceTests.java From initializr with Apache License 2.0 | 6 votes |
@ParameterizedTest @MethodSource("parameters") void bomWithOrdering(BuildSystem build, String fileName) { Dependency foo = Dependency.withId("foo", "org.acme", "foo"); foo.setBom("foo-bom"); BillOfMaterials barBom = BillOfMaterials.create("org.acme", "bar-bom", "1.0"); barBom.setOrder(50); BillOfMaterials bizBom = BillOfMaterials.create("org.acme", "biz-bom"); bizBom.setOrder(40); bizBom.getAdditionalBoms().add("bar-bom"); bizBom.getMappings().add(BillOfMaterials.Mapping.create("1.0.0.RELEASE", "1.0")); BillOfMaterials fooBom = BillOfMaterials.create("org.acme", "foo-bom", "1.0"); fooBom.setOrder(20); fooBom.getAdditionalBoms().add("biz-bom"); InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults().addDependencyGroup("foo", foo) .addBom("foo-bom", fooBom).addBom("bar-bom", barBom).addBom("biz-bom", bizBom).build(); ProjectStructure project = generateProject(java, build, "2.1.1.RELEASE", (description) -> description.addDependency("foo", MetadataBuildItemMapper.toDependency(foo)), metadata); assertThat(project).textFile(fileName).hasSameContentAs( new ClassPathResource("project/" + build + "/bom-ordering-" + getAssertFileName(fileName))); }
Example #10
Source File: MetadataVerificationTests.java From start.spring.io with Apache License 2.0 | 6 votes |
private List<RemoteRepository> getRepositories(Dependency dependency, Version bootVersion, List<BillOfMaterials> boms) { Map<String, RemoteRepository> repositories = new HashMap<>(); repositories.put("central", DependencyResolver.mavenCentral); String dependencyRepository = dependency.getRepository(); if (dependencyRepository != null) { repositories.computeIfAbsent(dependencyRepository, this::repositoryForId); } for (BillOfMaterials bom : boms) { for (String repository : bom.getRepositories()) { repositories.computeIfAbsent(repository, this::repositoryForId); } } if (!bootVersion.getQualifier().getId().equals("RELEASE")) { repositories.computeIfAbsent("spring-milestones", this::repositoryForId); if (bootVersion.getQualifier().getId().contains("SNAPSHOT")) { repositories.computeIfAbsent("spring-snapshots", this::repositoryForId); } } return new ArrayList<>(repositories.values()); }
Example #11
Source File: DefaultDependencyMetadataProviderTests.java From initializr with Apache License 2.0 | 6 votes |
@Test void addBomAndRemoveDuplicates() { Dependency first = Dependency.withId("first", "org.foo", "first"); first.setBom("bom-foo"); Dependency second = Dependency.withId("second", "org.foo", "second"); Dependency third = Dependency.withId("third", "org.foo", "third"); third.setBom("bom-foo"); BillOfMaterials bom = BillOfMaterials.create("org.foo", "bom"); bom.getMappings().add(BillOfMaterials.Mapping.create("[1.0.0.RELEASE, 1.1.8.RELEASE)", "1.0.0.RELEASE")); bom.getMappings().add(BillOfMaterials.Mapping.create("1.1.8.RELEASE", "2.0.0.RELEASE")); InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults().addBom("bom-foo", bom) .addDependencyGroup("test", first, second, third).build(); DependencyMetadata dependencyMetadata = this.provider.get(metadata, Version.parse("1.1.5.RELEASE")); assertThat(dependencyMetadata.getDependencies()).hasSize(3); assertThat(dependencyMetadata.getRepositories()).isEmpty(); assertThat(dependencyMetadata.getBoms()).hasSize(1); assertThat(dependencyMetadata.getBoms().get("bom-foo").getGroupId()).isEqualTo("org.foo"); assertThat(dependencyMetadata.getBoms().get("bom-foo").getArtifactId()).isEqualTo("bom"); assertThat(dependencyMetadata.getBoms().get("bom-foo").getVersion()).isEqualTo("1.0.0.RELEASE"); }
Example #12
Source File: DefaultDependencyMetadataProviderTests.java From initializr with Apache License 2.0 | 6 votes |
private DependencyMetadata testRepoFromBomAccordingToVersion(String bootVersion) { Dependency first = Dependency.withId("first", "org.foo", "first"); first.setRepository("repo-foo"); Dependency second = Dependency.withId("second", "org.foo", "second"); Dependency third = Dependency.withId("third", "org.foo", "third"); third.setBom("bom-foo"); BillOfMaterials bom = BillOfMaterials.create("org.foo", "bom"); bom.getMappings().add(BillOfMaterials.Mapping.create("[1.0.0.RELEASE, 1.1.0.RELEASE)", "2.0.0.RELEASE", "repo-foo", "repo-bar")); bom.getMappings().add(BillOfMaterials.Mapping.create("1.1.0.RELEASE", "3.0.0.RELEASE", "repo-biz")); InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults().addBom("bom-foo", bom) .addRepository("repo-foo", "foo", "http://localhost", false) .addRepository("repo-bar", "bar", "http://localhost", false) .addRepository("repo-biz", "biz", "http://localhost", false) .addDependencyGroup("test", first, second, third).build(); return this.provider.get(metadata, Version.parse(bootVersion)); }
Example #13
Source File: DependencyMetadataJsonMapperTests.java From initializr with Apache License 2.0 | 6 votes |
@Test void mapDependency() throws Exception { Dependency d = Dependency.withId("foo", "org.foo", "foo"); d.setRepository("my-repo"); d.setBom("my-bom"); Repository repository = new Repository(); repository.setName("foo-repo"); repository.setUrl(new URL("https://example.com/foo")); BillOfMaterials bom = BillOfMaterials.create("org.foo", "foo-bom", "1.0.0.RELEASE"); DependencyMetadata metadata = new DependencyMetadata(Version.parse("1.2.0.RELEASE"), Collections.singletonMap(d.getId(), d), Collections.singletonMap("repo-id", repository), Collections.singletonMap("bom-id", bom)); JSONObject content = new JSONObject(this.mapper.write(metadata)); assertThat(content.getJSONObject("dependencies").getJSONObject("foo").getString("bom")).isEqualTo("my-bom"); assertThat(content.getJSONObject("dependencies").getJSONObject("foo").getString("repository")) .isEqualTo("my-repo"); assertThat(content.getJSONObject("repositories").getJSONObject("repo-id").getString("name")) .isEqualTo("foo-repo"); assertThat(content.getJSONObject("boms").getJSONObject("bom-id").getString("artifactId")).isEqualTo("foo-bom"); assertThat(content.getJSONObject("boms").getJSONObject("bom-id").getString("version")) .isEqualTo("1.0.0.RELEASE"); }
Example #14
Source File: BuildComplianceTests.java From initializr with Apache License 2.0 | 5 votes |
@ParameterizedTest @MethodSource("parameters") void bomWithVersionProperty(BuildSystem build, String fileName) { Dependency foo = Dependency.withId("foo", "org.acme", "foo"); foo.setBom("the-bom"); BillOfMaterials bom = BillOfMaterials.create("org.acme", "foo-bom", "1.3.3"); bom.setVersionProperty("foo.version"); InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults().addDependencyGroup("foo", foo) .addBom("the-bom", bom).build(); ProjectStructure project = generateProject(java, build, "2.1.1.RELEASE", (description) -> description.addDependency("foo", MetadataBuildItemMapper.toDependency(foo)), metadata); assertThat(project).textFile(fileName).hasSameContentAs( new ClassPathResource("project/" + build + "/bom-property-" + getAssertFileName(fileName))); }
Example #15
Source File: DependencyManagementBuildCustomizer.java From initializr with Apache License 2.0 | 5 votes |
private void resolveBom(Map<String, BillOfMaterials> boms, String bomId, Version requestedVersion) { if (!boms.containsKey(bomId)) { BillOfMaterials bom = this.metadata.getConfiguration().getEnv().getBoms().get(bomId) .resolve(requestedVersion); bom.getAdditionalBoms().forEach((id) -> resolveBom(boms, id, requestedVersion)); boms.put(bomId, bom); } }
Example #16
Source File: MetadataBuildItemMapper.java From initializr with Apache License 2.0 | 5 votes |
/** * Return a {@link Build} bom from a {@link BillOfMaterials bom metadata}. * @param bom a metadata bom * @return an equivalent build bom */ public static io.spring.initializr.generator.buildsystem.BillOfMaterials toBom(BillOfMaterials bom) { if (bom == null) { return null; } VersionReference version = (bom.getVersionProperty() != null) ? VersionReference.ofProperty(bom.getVersionProperty()) : VersionReference.ofValue(bom.getVersion()); return io.spring.initializr.generator.buildsystem.BillOfMaterials .withCoordinates(bom.getGroupId(), bom.getArtifactId()).version(version).order(bom.getOrder()).build(); }
Example #17
Source File: BomRangesInfoContributorTests.java From initializr with Apache License 2.0 | 5 votes |
@Test void noMapping() { BillOfMaterials bom = BillOfMaterials.create("com.example", "bom", "1.0.0"); InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults().addBom("foo", bom).build(); Info info = getInfo(metadata); assertThat(info.getDetails()).doesNotContainKeys("bom-ranges"); }
Example #18
Source File: DependencyRangesInfoContributorTests.java From initializr with Apache License 2.0 | 5 votes |
@Test void dependencyWithRangeAndBom() { BillOfMaterials bom = BillOfMaterials.create("com.example", "bom", "1.0.0"); Dependency dependency = Dependency.withId("foo", "com.example", "foo", "1.2.3.RELEASE"); dependency.getMappings().add( Dependency.Mapping.create("[1.1.0.RELEASE, 1.2.0.RELEASE)", null, null, "0.1.0.RELEASE", null, null)); dependency.setBom("bom"); InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults().addBom("bom", bom) .addDependencyGroup("foo", dependency).build(); Info info = getInfo(metadata); assertThat(info.getDetails()).doesNotContainKeys("dependency-ranges"); }
Example #19
Source File: DependencyMetadataV21JsonMapper.java From initializr with Apache License 2.0 | 5 votes |
private static JsonNode mapBom(BillOfMaterials bom) { ObjectNode node = nodeFactory.objectNode(); node.put("groupId", bom.getGroupId()); node.put("artifactId", bom.getArtifactId()); if (bom.getVersion() != null) { node.put("version", bom.getVersion()); } if (bom.getRepositories() != null) { ArrayNode array = nodeFactory.arrayNode(); bom.getRepositories().forEach(array::add); node.set("repositories", array); } return node; }
Example #20
Source File: MavenBuildAssert.java From initializr with Apache License 2.0 | 5 votes |
/** * Assert that {@code pom.xml} does not define the specified bom. * @param groupId the groupId of the bom * @param artifactId the artifactId of the bom * @return {@code this} assertion object */ public MavenBuildAssert doesNotHaveBom(String groupId, String artifactId) { this.pom.nodesAtPath("/project/dependencyManagement/dependencies/dependency").noneMatch((candidate) -> { BillOfMaterials actual = toBom(candidate); return groupId.equals(actual.getGroupId()) && artifactId.equals(actual.getArtifactId()); }); return this; }
Example #21
Source File: MavenBuildAssert.java From initializr with Apache License 2.0 | 5 votes |
/** * Assert {@code pom.xml} defines the specified bom. * @param groupId the groupId of the bom * @param artifactId the artifactId of the bom * @param version the version of the bom * @return {@code this} assertion object */ public MavenBuildAssert hasBom(String groupId, String artifactId, String version) { this.pom.nodesAtPath("/project/dependencyManagement/dependencies/dependency").areExactly(1, new Condition<>((candidate) -> { BillOfMaterials actual = toBom(candidate); return (actual != null && actual.getGroupId().equals(groupId) && actual.getArtifactId().equals(artifactId) && actual.getVersion().equals(version)); }, "matching bom")); return this; }
Example #22
Source File: MetadataBuildItemResolverTests.java From initializr with Apache License 2.0 | 5 votes |
@Test void resoleBomWithNotMatchingEntry() { InitializrMetadata metadata = new InitializrMetadata(); BillOfMaterials bom = BillOfMaterials.create("com.example", "bom", "2.0.0"); metadata.getConfiguration().getEnv().getBoms().put("test-bom", bom); metadata.validate(); MetadataBuildItemResolver resolver = new MetadataBuildItemResolver(metadata, VERSION_2_0_0); assertThat(resolver.resolveBom("does-not-exost")).isNull(); }
Example #23
Source File: SpringCloudFunctionBuildCustomizerTests.java From start.spring.io with Apache License 2.0 | 5 votes |
@Test void webflux() { ProjectRequest request = createProjectRequest("webflux", "cloud-function"); request.setBootVersion("2.1.0.BUILD-SNAPSHOT"); BillOfMaterials bom = getBom("spring-cloud", "2.1.0.BUILD-SNAPSHOT"); assertThat(mavenPom(request)).hasDependency(getDependency("webflux")).hasDependency(WEB_ADAPTER) .hasDependenciesSize(4) .hasBom("org.springframework.cloud", "spring-cloud-dependencies", "${spring-cloud.version}") .hasBomsSize(1).hasProperty("spring-cloud.version", bom.getVersion()); }
Example #24
Source File: SpringCloudFunctionBuildCustomizerTests.java From start.spring.io with Apache License 2.0 | 5 votes |
@Test void web() { ProjectRequest request = createProjectRequest("web", "cloud-function"); BillOfMaterials bom = getBom("spring-cloud", request.getBootVersion()); assertThat(mavenPom(request)).hasDependency(getDependency("web")).hasDependency(WEB_ADAPTER) .hasDependenciesSize(3) .hasBom("org.springframework.cloud", "spring-cloud-dependencies", "${spring-cloud.version}") .hasBomsSize(1).hasProperty("spring-cloud.version", bom.getVersion()); }
Example #25
Source File: SpringCloudProjectVersionResolverTests.java From start.spring.io with Apache License 2.0 | 5 votes |
@Test void resolveManagedArtifact() { BillOfMaterials bom = BillOfMaterials.create("org.springframework.cloud", "spring-cloud-dependencies", "1.0.0"); InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults().addBom("spring-cloud", bom).build(); given(this.versionResolver.resolve("org.springframework.cloud", "spring-cloud-dependencies", "1.0.0")) .willReturn(Collections.singletonMap("org.springframework.cloud:spring-cloud", "1.1.0")); String version = new SpringCloudProjectVersionResolver(metadata, this.versionResolver) .resolveVersion(VersionParser.DEFAULT.parse("2.1.0.RELEASE"), "org.springframework.cloud:spring-cloud"); assertThat(version).isEqualTo("1.1.0"); }
Example #26
Source File: MetadataBuildItemResolverTests.java From initializr with Apache License 2.0 | 5 votes |
@Test void resoleBomWithMatchingEntry() { InitializrMetadata metadata = new InitializrMetadata(); BillOfMaterials bom = BillOfMaterials.create("com.example", "bom", "2.0.0"); metadata.getConfiguration().getEnv().getBoms().put("test-bom", bom); metadata.validate(); MetadataBuildItemResolver resolver = new MetadataBuildItemResolver(metadata, VERSION_2_0_0); io.spring.initializr.generator.buildsystem.BillOfMaterials resolvedBom = resolver.resolveBom("test-bom"); assertThat(resolvedBom.getGroupId()).isEqualTo("com.example"); assertThat(resolvedBom.getArtifactId()).isEqualTo("bom"); assertThat(resolvedBom.getVersion()).hasToString("2.0.0"); }
Example #27
Source File: MetadataVerificationTests.java From start.spring.io with Apache License 2.0 | 5 votes |
@ParameterizedTest(name = "{3}") @MethodSource("parameters") void dependencyStarterConfigurationIsCorrect(Dependency dependency, List<BillOfMaterials> boms, List<RemoteRepository> repositories, String description) { List<String> dependencies = DependencyResolver.resolveDependencies(dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), boms, repositories); if (dependency.isStarter()) { assertThat(dependencies).anyMatch("org.springframework.boot:spring-boot-starter"::equals); } else { assertThat(dependencies).noneMatch("org.springframework.boot:spring-boot-starter"::equals); } }
Example #28
Source File: SpringCloudProjectVersionResolverTests.java From start.spring.io with Apache License 2.0 | 5 votes |
@Test void resolveWithUnknownArtifactId() { BillOfMaterials bom = BillOfMaterials.create("org.springframework.cloud", "spring-cloud-dependencies", "1.0.0"); InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults().addBom("spring-cloud", bom).build(); given(this.versionResolver.resolve("org.springframework.cloud", "spring-cloud-dependencies", "1.0.0")) .willReturn(Collections.singletonMap("org.springframework.cloud:spring-cloud", "1.1.0")); String version = new SpringCloudProjectVersionResolver(metadata, this.versionResolver) .resolveVersion(VersionParser.DEFAULT.parse("2.1.0.RELEASE"), "org.springframework.cloud:test"); assertThat(version).isNull(); }
Example #29
Source File: SpringCloudProjectVersionResolverTests.java From start.spring.io with Apache License 2.0 | 5 votes |
@Test void resolveWithNoSpringCloudBom() { BillOfMaterials bom = BillOfMaterials.create("com.example", "custom-bom", "1.0.0"); InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults().addBom("custom-bom", bom).build(); String version = new SpringCloudProjectVersionResolver(metadata, this.versionResolver) .resolveVersion(VersionParser.DEFAULT.parse("2.1.0.RELEASE"), "com.example:test"); assertThat(version).isNull(); }
Example #30
Source File: MetadataVerificationTests.java From start.spring.io with Apache License 2.0 | 5 votes |
private List<BillOfMaterials> getBoms(Dependency dependency, Version bootVersion) { List<BillOfMaterials> boms = new ArrayList<>(); bomsForId(dependency.getBom(), bootVersion, boms::add); boms.add( BillOfMaterials.create("org.springframework.boot", "spring-boot-dependencies", bootVersion.toString())); return boms; }