Add support for repository mapping

This commit adds a way to map the repository of a dependency based on
a compatibility range.

Closes gh-1085
This commit is contained in:
Stephane Nicoll
2020-05-15 17:58:49 +02:00
parent 374459f800
commit a8926c2da7
6 changed files with 89 additions and 48 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -57,7 +57,7 @@ class DependencyRangesInfoContributorTests {
void dependencyWithRangeOnArtifact() {
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, "foo2", null, null));
.add(Dependency.Mapping.create("[1.1.0.RELEASE, 1.2.0.RELEASE)", null, "foo2", null, null, null));
InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults().addDependencyGroup("foo", dependency)
.build();
Info info = getInfo(metadata);
@@ -68,8 +68,8 @@ class DependencyRangesInfoContributorTests {
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));
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();
@@ -96,9 +96,10 @@ class DependencyRangesInfoContributorTests {
@Test
void dependencyWithMappingAndOpenRange() {
Dependency dependency = Dependency.withId("foo", null, null, "0.3.0.RELEASE");
dependency.getMappings().add(
Dependency.Mapping.create("[1.1.0.RELEASE, 1.2.0.RELEASE)", null, null, "0.1.0.RELEASE", null, null));
dependency.getMappings()
.add(Dependency.Mapping.create("[1.1.0.RELEASE, 1.2.0.RELEASE)", null, null, "0.1.0.RELEASE", null));
dependency.getMappings().add(Dependency.Mapping.create("1.2.0.RELEASE", null, null, "0.2.0.RELEASE", null));
.add(Dependency.Mapping.create("1.2.0.RELEASE", null, null, "0.2.0.RELEASE", null, null));
InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults()
.addDependencyGroup("test", dependency).build();
Info info = getInfo(metadata);
@@ -111,10 +112,10 @@ class DependencyRangesInfoContributorTests {
@Test
void dependencyWithMappingAndNoOpenRange() {
Dependency dependency = Dependency.withId("foo", null, null, "0.3.0.RELEASE");
dependency.getMappings()
.add(Dependency.Mapping.create("[1.1.0.RELEASE, 1.2.0.RELEASE)", null, null, "0.1.0.RELEASE", null));
dependency.getMappings()
.add(Dependency.Mapping.create("[1.2.0.RELEASE, 1.3.0.RELEASE)", null, null, "0.2.0.RELEASE", null));
dependency.getMappings().add(
Dependency.Mapping.create("[1.1.0.RELEASE, 1.2.0.RELEASE)", null, null, "0.1.0.RELEASE", null, null));
dependency.getMappings().add(
Dependency.Mapping.create("[1.2.0.RELEASE, 1.3.0.RELEASE)", null, null, "0.2.0.RELEASE", null, null));
InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults()
.addDependencyGroup("test", dependency).build();
Info info = getInfo(metadata);