Rename versionRange attribute to compatibilityRange

See gh-968
This commit is contained in:
HaiTao Zhang
2019-08-08 14:23:22 -07:00
committed by Stephane Nicoll
parent aaf44d1ec8
commit 71364408fa
21 changed files with 117 additions and 116 deletions

View File

@@ -45,7 +45,7 @@ public class BomRangesInfoContributor implements InfoContributor {
if (v.getMappings() != null && !v.getMappings().isEmpty()) { if (v.getMappings() != null && !v.getMappings().isEmpty()) {
Map<String, Object> bom = new LinkedHashMap<>(); Map<String, Object> bom = new LinkedHashMap<>();
v.getMappings().forEach((it) -> { v.getMappings().forEach((it) -> {
String requirement = "Spring Boot " + it.determineVersionRangeRequirement(); String requirement = "Spring Boot " + it.determineCompatibilityRangeRequirement();
bom.put(it.getVersion(), requirement); bom.put(it.getVersion(), requirement);
}); });
details.put(k, bom); details.put(k, bom);

View File

@@ -80,7 +80,7 @@ class DependencyRangesInfoContributorTests {
@Test @Test
void dependencyNoMappingSimpleRange() { void dependencyNoMappingSimpleRange() {
Dependency dependency = Dependency.withId("foo", "com.example", "foo", "1.2.3.RELEASE"); Dependency dependency = Dependency.withId("foo", "com.example", "foo", "1.2.3.RELEASE");
dependency.setVersionRange("[1.1.0.RELEASE, 1.5.0.RELEASE)"); dependency.setCompatibilityRange("[1.1.0.RELEASE, 1.5.0.RELEASE)");
InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults().addDependencyGroup("foo", dependency) InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults().addDependencyGroup("foo", dependency)
.build(); .build();
Info info = getInfo(metadata); Info info = getInfo(metadata);

View File

@@ -11,10 +11,10 @@ initializr:
versionProperty: my-api.version versionProperty: my-api.version
additionalBoms: ['my-api-dependencies-bom'] additionalBoms: ['my-api-dependencies-bom']
mappings: mappings:
- versionRange: "[2.0.0.RELEASE,2.1.6.RELEASE)" - compatibilityRange: "[2.0.0.RELEASE,2.1.6.RELEASE)"
version: 1.0.0.RELEASE version: 1.0.0.RELEASE
repositories: my-api-repo-1 repositories: my-api-repo-1
- versionRange: "2.2.1.RELEASE" - compatibilityRange: "2.2.1.RELEASE"
version: 2.0.0.RELEASE version: 2.0.0.RELEASE
repositories: my-api-repo-2 repositories: my-api-repo-2
my-api-dependencies-bom: my-api-dependencies-bom:
@@ -25,9 +25,9 @@ initializr:
kotlin: kotlin:
defaultVersion: 1.2 defaultVersion: 1.2
mappings: mappings:
- versionRange: "[1.5.0.RELEASE,2.0.0.M1)" - compatibilityRange: "[1.5.0.RELEASE,2.0.0.M1)"
version: 1.0 version: 1.0
- versionRange: "[2.0.0.M1,2.1.0.M1)" - compatibilityRange: "[2.0.0.M1,2.1.0.M1)"
version: 1.1 version: 1.1
repositories: repositories:
my-api-repo-1: my-api-repo-1:
@@ -85,12 +85,12 @@ initializr:
artifactId: biz artifactId: biz
scope: runtime scope: runtime
version: 1.3.5 version: 1.3.5
versionRange: 2.2.0.BUILD-SNAPSHOT compatibilityRange: 2.2.0.BUILD-SNAPSHOT
- name: Bur - name: Bur
id: org.acme:bur id: org.acme:bur
version: 2.1.0 version: 2.1.0
scope: test scope: test
versionRange: "[2.1.4.RELEASE,2.2.0.BUILD-SNAPSHOT)" compatibilityRange: "[2.1.4.RELEASE,2.2.0.BUILD-SNAPSHOT)"
- name: My API - name: My API
id : my-api id : my-api
groupId: org.acme groupId: org.acme

View File

@@ -160,17 +160,17 @@ public class BillOfMaterials {
if (this.version == null && this.mappings.isEmpty()) { if (this.version == null && this.mappings.isEmpty()) {
throw new InvalidInitializrMetadataException("No version available for " + this); throw new InvalidInitializrMetadataException("No version available for " + this);
} }
updateVersionRange(VersionParser.DEFAULT); updateCompatibilityRange(VersionParser.DEFAULT);
} }
public void updateVersionRange(VersionParser versionParser) { public void updateCompatibilityRange(VersionParser versionParser) {
this.mappings.forEach((it) -> { this.mappings.forEach((it) -> {
try { try {
it.range = versionParser.parseRange(it.versionRange); it.range = versionParser.parseRange(it.compatibilityRange);
} }
catch (InvalidVersionException ex) { catch (InvalidVersionException ex) {
throw new InvalidInitializrMetadataException( throw new InvalidInitializrMetadataException(
"Invalid version range " + it.versionRange + " for " + this, ex); "Invalid compatibility range " + it.compatibilityRange + " for " + this, ex);
} }
}); });
} }
@@ -229,7 +229,7 @@ public class BillOfMaterials {
@JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonInclude(JsonInclude.Include.NON_EMPTY)
public static class Mapping { public static class Mapping {
private String versionRange; private String compatibilityRange;
/** /**
* The groupId to use for this mapping or {@code null} to use the default. * The groupId to use for this mapping or {@code null} to use the default.
@@ -254,12 +254,12 @@ public class BillOfMaterials {
} }
private Mapping(String range, String version, String... repositories) { private Mapping(String range, String version, String... repositories) {
this.versionRange = range; this.compatibilityRange = range;
this.version = version; this.version = version;
this.repositories.addAll(Arrays.asList(repositories)); this.repositories.addAll(Arrays.asList(repositories));
} }
public String determineVersionRangeRequirement() { public String determineCompatibilityRangeRequirement() {
return this.range.toString(); return this.range.toString();
} }
@@ -271,12 +271,12 @@ public class BillOfMaterials {
return new Mapping(range, version, repositories); return new Mapping(range, version, repositories);
} }
public String getVersionRange() { public String getCompatibilityRange() {
return this.versionRange; return this.compatibilityRange;
} }
public void setVersionRange(String versionRange) { public void setCompatibilityRange(String compatibilityRange) {
this.versionRange = versionRange; this.compatibilityRange = compatibilityRange;
} }
public String getGroupId() { public String getGroupId() {
@@ -329,7 +329,8 @@ public class BillOfMaterials {
@Override @Override
public String toString() { public String toString() {
return "Mapping [" + ((this.versionRange != null) ? "versionRange=" + this.versionRange + ", " : "") return "Mapping ["
+ ((this.compatibilityRange != null) ? "compatibilityRange=" + this.compatibilityRange + ", " : "")
+ ((this.groupId != null) ? "groupId=" + this.groupId + ", " : "") + ((this.groupId != null) ? "groupId=" + this.groupId + ", " : "")
+ ((this.artifactId != null) ? "artifactId=" + this.artifactId + ", " : "") + ((this.artifactId != null) ? "artifactId=" + this.artifactId + ", " : "")
+ ((this.version != null) ? "version=" + this.version + ", " : "") + ((this.version != null) ? "version=" + this.version + ", " : "")

View File

@@ -73,8 +73,8 @@ public class DependenciesCapability extends ServiceCapability<List<DependencyGro
index(); index();
} }
public void updateVersionRange(VersionParser versionParser) { public void updateCompatibilityRange(VersionParser versionParser) {
this.indexedDependencies.values().forEach((it) -> it.updateVersionRanges(versionParser)); this.indexedDependencies.values().forEach((it) -> it.updateCompatibilityRange(versionParser));
} }
@Override @Override
@@ -92,8 +92,8 @@ public class DependenciesCapability extends ServiceCapability<List<DependencyGro
this.indexedDependencies.clear(); this.indexedDependencies.clear();
this.content.forEach((group) -> group.content.forEach((dependency) -> { this.content.forEach((group) -> group.content.forEach((dependency) -> {
// Apply defaults // Apply defaults
if (dependency.getVersionRange() == null && group.getVersionRange() != null) { if (dependency.getCompatibilityRange() == null && group.getCompatibilityRange() != null) {
dependency.setVersionRange(group.getVersionRange()); dependency.setCompatibilityRange(group.getCompatibilityRange());
} }
if (dependency.getBom() == null && group.getBom() != null) { if (dependency.getBom() == null && group.getBom() != null) {
dependency.setBom(group.getBom()); dependency.setBom(group.getBom());

View File

@@ -94,7 +94,7 @@ public class Dependency extends MetadataElement implements Describable {
private String description; private String description;
private String versionRange; private String compatibilityRange;
@JsonIgnore @JsonIgnore
private String versionRequirement; private String versionRequirement;
@@ -133,7 +133,7 @@ public class Dependency extends MetadataElement implements Describable {
this.mappings.addAll(dependency.mappings); this.mappings.addAll(dependency.mappings);
this.scope = dependency.scope; this.scope = dependency.scope;
this.description = dependency.description; this.description = dependency.description;
this.versionRange = dependency.versionRange; this.compatibilityRange = dependency.compatibilityRange;
this.versionRequirement = dependency.versionRequirement; this.versionRequirement = dependency.versionRequirement;
this.range = dependency.range; this.range = dependency.range;
this.bom = dependency.bom; this.bom = dependency.bom;
@@ -151,8 +151,8 @@ public class Dependency extends MetadataElement implements Describable {
this.scope = scope; this.scope = scope;
} }
public void setVersionRange(String versionRange) { public void setCompatibilityRange(String compatibilityRange) {
this.versionRange = (StringUtils.hasText(versionRange) ? versionRange.trim() : null); this.compatibilityRange = (StringUtils.hasText(compatibilityRange) ? compatibilityRange.trim() : null);
} }
/** /**
@@ -209,28 +209,28 @@ public class Dependency extends MetadataElement implements Describable {
} }
} }
this.links.forEach(Link::resolve); this.links.forEach(Link::resolve);
updateVersionRanges(VersionParser.DEFAULT); updateCompatibilityRange(VersionParser.DEFAULT);
} }
public void updateVersionRanges(VersionParser versionParser) { public void updateCompatibilityRange(VersionParser versionParser) {
if (this.versionRange != null) { if (this.compatibilityRange != null) {
try { try {
this.range = versionParser.parseRange(this.versionRange); this.range = versionParser.parseRange(this.compatibilityRange);
this.versionRange = this.range.toRangeString(); this.compatibilityRange = this.range.toRangeString();
this.versionRequirement = this.range.toString(); this.versionRequirement = this.range.toString();
} }
catch (InvalidVersionException ex) { catch (InvalidVersionException ex) {
throw new InvalidInitializrMetadataException("Invalid version range '" + this.versionRange + " for " throw new InvalidInitializrMetadataException("Invalid compatibility range '" + this.compatibilityRange
+ "dependency with id '" + getId() + "'", ex); + " for " + "dependency with id '" + getId() + "'", ex);
} }
} }
this.mappings.forEach((it) -> { this.mappings.forEach((it) -> {
try { try {
it.range = versionParser.parseRange(it.versionRange); it.range = versionParser.parseRange(it.compatibilityRange);
} }
catch (InvalidVersionException ex) { catch (InvalidVersionException ex) {
throw new InvalidInitializrMetadataException( throw new InvalidInitializrMetadataException(
"Invalid version range " + it.versionRange + " for " + this, ex); "Invalid compatibility range " + it.compatibilityRange + " for " + this, ex);
} }
}); });
} }
@@ -431,8 +431,8 @@ public class Dependency extends MetadataElement implements Describable {
return this.scope; return this.scope;
} }
public String getVersionRange() { public String getCompatibilityRange() {
return this.versionRange; return this.compatibilityRange;
} }
@Override @Override
@@ -476,14 +476,14 @@ public class Dependency extends MetadataElement implements Describable {
} }
/** /**
* Map several attribute of the dependency for a given version range. * Map several attribute of the dependency for a given compatibility range.
*/ */
public static class Mapping { public static class Mapping {
/** /**
* The version range of this mapping. * The compatibility range of this mapping.
*/ */
private String versionRange; private String compatibilityRange;
/** /**
* The version to use for this mapping or {@code null} to use the default. * The version to use for this mapping or {@code null} to use the default.
@@ -544,17 +544,17 @@ public class Dependency extends MetadataElement implements Describable {
return this.range; return this.range;
} }
public String getVersionRange() { public String getCompatibilityRange() {
return this.versionRange; return this.compatibilityRange;
} }
public void setVersionRange(String versionRange) { public void setCompatibilityRange(String compatibilityRange) {
this.versionRange = versionRange; this.compatibilityRange = compatibilityRange;
} }
public static Mapping create(String range, String groupId, String artifactId, String version, Boolean starter) { public static Mapping create(String range, String groupId, String artifactId, String version, Boolean starter) {
Mapping mapping = new Mapping(); Mapping mapping = new Mapping();
mapping.versionRange = range; mapping.compatibilityRange = range;
mapping.groupId = groupId; mapping.groupId = groupId;
mapping.artifactId = artifactId; mapping.artifactId = artifactId;
mapping.version = version; mapping.version = version;

View File

@@ -31,7 +31,7 @@ public class DependencyGroup {
private String name; private String name;
@JsonIgnore @JsonIgnore
private String versionRange; private String compatibilityRange;
@JsonIgnore @JsonIgnore
private String bom; private String bom;
@@ -54,16 +54,16 @@ public class DependencyGroup {
} }
/** /**
* Return the default version range to apply to all dependencies of this group unless * Return the default compatibility range to apply to all dependencies of this group
* specified otherwise. * unless specified otherwise.
* @return the version range * @return the compatibility range
*/ */
public String getVersionRange() { public String getCompatibilityRange() {
return this.versionRange; return this.compatibilityRange;
} }
public void setVersionRange(String versionRange) { public void setCompatibilityRange(String compatibilityRange) {
this.versionRange = versionRange; this.compatibilityRange = compatibilityRange;
} }
/** /**

View File

@@ -413,11 +413,11 @@ public class InitializrConfiguration {
public void validate() { public void validate() {
VersionParser simpleParser = new VersionParser(Collections.emptyList()); VersionParser simpleParser = new VersionParser(Collections.emptyList());
this.mappings.forEach((m) -> { this.mappings.forEach((m) -> {
if (m.versionRange == null) { if (m.compatibilityRange == null) {
throw new InvalidInitializrMetadataException( throw new InvalidInitializrMetadataException(
"VersionRange is mandatory, invalid version mapping for " + this); "CompatibilityRange is mandatory, invalid version mapping for " + this);
} }
m.range = simpleParser.parseRange(m.versionRange); m.range = simpleParser.parseRange(m.compatibilityRange);
if (m.version == null) { if (m.version == null) {
throw new InvalidInitializrMetadataException( throw new InvalidInitializrMetadataException(
"Version is mandatory, invalid version mapping for " + this); "Version is mandatory, invalid version mapping for " + this);
@@ -425,14 +425,14 @@ public class InitializrConfiguration {
}); });
} }
public void updateVersionRange(VersionParser versionParser) { public void updateCompatibilityRange(VersionParser versionParser) {
this.mappings.forEach((it) -> { this.mappings.forEach((it) -> {
try { try {
it.range = versionParser.parseRange(it.versionRange); it.range = versionParser.parseRange(it.compatibilityRange);
} }
catch (InvalidVersionException ex) { catch (InvalidVersionException ex) {
throw new InvalidInitializrMetadataException( throw new InvalidInitializrMetadataException(
"Invalid version range " + it.versionRange + " for " + this, ex); "Invalid compatibility range " + it.compatibilityRange + " for " + this, ex);
} }
}); });
} }
@@ -444,14 +444,14 @@ public class InitializrConfiguration {
} }
/** /**
* Map several attribute of the dependency for a given version range. * Map several attribute of the dependency for a given compatibility range.
*/ */
public static class Mapping { public static class Mapping {
/** /**
* The version range of this mapping. * The compatibility range of this mapping.
*/ */
private String versionRange; private String compatibilityRange;
/** /**
* The kotlin version for this mapping. * The kotlin version for this mapping.
@@ -461,12 +461,12 @@ public class InitializrConfiguration {
@JsonIgnore @JsonIgnore
private VersionRange range; private VersionRange range;
public String getVersionRange() { public String getCompatibilityRange() {
return this.versionRange; return this.compatibilityRange;
} }
public void setVersionRange(String versionRange) { public void setCompatibilityRange(String compatibilityRange) {
this.versionRange = versionRange; this.compatibilityRange = compatibilityRange;
} }
public String getVersion() { public String getVersion() {

View File

@@ -205,9 +205,9 @@ public class InitializrMetadata {
List<Version> bootVersions = this.bootVersions.getContent().stream().map((it) -> Version.parse(it.getId())) List<Version> bootVersions = this.bootVersions.getContent().stream().map((it) -> Version.parse(it.getId()))
.collect(Collectors.toList()); .collect(Collectors.toList());
VersionParser parser = new VersionParser(bootVersions); VersionParser parser = new VersionParser(bootVersions);
this.dependencies.updateVersionRange(parser); this.dependencies.updateCompatibilityRange(parser);
this.configuration.getEnv().getBoms().values().forEach((it) -> it.updateVersionRange(parser)); this.configuration.getEnv().getBoms().values().forEach((it) -> it.updateCompatibilityRange(parser));
this.configuration.getEnv().getKotlin().updateVersionRange(parser); this.configuration.getEnv().getKotlin().updateCompatibilityRange(parser);
} }
/** /**

View File

@@ -130,12 +130,12 @@ class BillOfMaterialsTests {
bom.getMappings().add(BillOfMaterials.Mapping.create("[1.3.x.BUILD-SNAPSHOT,1.4.0.RELEASE)", "1.1.1-SNAPSHOT")); bom.getMappings().add(BillOfMaterials.Mapping.create("[1.3.x.BUILD-SNAPSHOT,1.4.0.RELEASE)", "1.1.1-SNAPSHOT"));
bom.validate(); bom.validate();
bom.updateVersionRange(new VersionParser( bom.updateCompatibilityRange(new VersionParser(
Arrays.asList(Version.parse("1.3.8.RELEASE"), Version.parse("1.3.9.BUILD-SNAPSHOT")))); Arrays.asList(Version.parse("1.3.8.RELEASE"), Version.parse("1.3.9.BUILD-SNAPSHOT"))));
assertThat(bom.resolve(Version.parse("1.3.8.RELEASE")).getVersion()).isEqualTo("1.1.0"); assertThat(bom.resolve(Version.parse("1.3.8.RELEASE")).getVersion()).isEqualTo("1.1.0");
assertThat(bom.resolve(Version.parse("1.3.9.RELEASE")).getVersion()).isEqualTo("1.1.1-SNAPSHOT"); assertThat(bom.resolve(Version.parse("1.3.9.RELEASE")).getVersion()).isEqualTo("1.1.1-SNAPSHOT");
bom.updateVersionRange(new VersionParser( bom.updateCompatibilityRange(new VersionParser(
Arrays.asList(Version.parse("1.3.9.RELEASE"), Version.parse("1.3.10.BUILD-SNAPSHOT")))); Arrays.asList(Version.parse("1.3.9.RELEASE"), Version.parse("1.3.10.BUILD-SNAPSHOT"))));
assertThat(bom.resolve(Version.parse("1.3.8.RELEASE")).getVersion()).isEqualTo("1.1.0"); assertThat(bom.resolve(Version.parse("1.3.8.RELEASE")).getVersion()).isEqualTo("1.1.0");
assertThat(bom.resolve(Version.parse("1.3.9.RELEASE")).getVersion()).isEqualTo("1.1.0"); assertThat(bom.resolve(Version.parse("1.3.9.RELEASE")).getVersion()).isEqualTo("1.1.0");

View File

@@ -90,19 +90,19 @@ class DependenciesCapabilityTests {
} }
@Test @Test
void addDefaultVersionRange() { void addDefaultCompatibilityRange() {
Dependency first = Dependency.withId("first"); Dependency first = Dependency.withId("first");
Dependency second = Dependency.withId("second"); Dependency second = Dependency.withId("second");
second.setVersionRange("1.2.3.RELEASE"); second.setCompatibilityRange("1.2.3.RELEASE");
DependencyGroup group = createDependencyGroup("test", first, second); DependencyGroup group = createDependencyGroup("test", first, second);
group.setVersionRange("1.2.0.RELEASE"); group.setCompatibilityRange("1.2.0.RELEASE");
DependenciesCapability capability = new DependenciesCapability(); DependenciesCapability capability = new DependenciesCapability();
capability.getContent().add(group); capability.getContent().add(group);
capability.validate(); capability.validate();
assertThat(capability.get("first").getVersionRange()).isEqualTo("1.2.0.RELEASE"); assertThat(capability.get("first").getCompatibilityRange()).isEqualTo("1.2.0.RELEASE");
assertThat(capability.get("second").getVersionRange()).isEqualTo("1.2.3.RELEASE"); assertThat(capability.get("second").getCompatibilityRange()).isEqualTo("1.2.3.RELEASE");
} }
@Test @Test

View File

@@ -107,7 +107,7 @@ class DependencyTests {
@Test @Test
void invalidSpringBootRange() { void invalidSpringBootRange() {
Dependency dependency = Dependency.withId("web"); Dependency dependency = Dependency.withId("web");
dependency.setVersionRange("A.B.C"); dependency.setCompatibilityRange("A.B.C");
assertThatExceptionOfType(InvalidInitializrMetadataException.class).isThrownBy(dependency::resolve) assertThatExceptionOfType(InvalidInitializrMetadataException.class).isThrownBy(dependency::resolve)
.withMessageContaining("A.B.C"); .withMessageContaining("A.B.C");
} }
@@ -219,7 +219,7 @@ class DependencyTests {
Dependency.Mapping.create("[1.1.x.BUILD-SNAPSHOT, 1.2.0.RELEASE)", null, null, "0.2.0.RELEASE", null)); Dependency.Mapping.create("[1.1.x.BUILD-SNAPSHOT, 1.2.0.RELEASE)", null, null, "0.2.0.RELEASE", null));
dependency.resolve(); dependency.resolve();
dependency.updateVersionRanges(new VersionParser( dependency.updateCompatibilityRange(new VersionParser(
Arrays.asList(Version.parse("1.1.5.RELEASE"), Version.parse("1.1.6.BUILD-SNAPSHOT")))); Arrays.asList(Version.parse("1.1.5.RELEASE"), Version.parse("1.1.6.BUILD-SNAPSHOT"))));
validateResolvedWebDependency(dependency.resolve(Version.parse("1.1.5.RELEASE")), "org.springframework.boot", validateResolvedWebDependency(dependency.resolve(Version.parse("1.1.5.RELEASE")), "org.springframework.boot",
"spring-boot-starter-web", "0.1.0.RELEASE", true); "spring-boot-starter-web", "0.1.0.RELEASE", true);
@@ -228,7 +228,7 @@ class DependencyTests {
validateResolvedWebDependency(dependency.resolve(Version.parse("2.1.3.M1")), "org.springframework.boot", validateResolvedWebDependency(dependency.resolve(Version.parse("2.1.3.M1")), "org.springframework.boot",
"spring-boot-starter-web", "0.3.0.RELEASE", true); // default "spring-boot-starter-web", "0.3.0.RELEASE", true); // default
dependency.updateVersionRanges(new VersionParser( dependency.updateCompatibilityRange(new VersionParser(
Arrays.asList(Version.parse("1.1.6.RELEASE"), Version.parse("1.1.7.BUILD-SNAPSHOT")))); Arrays.asList(Version.parse("1.1.6.RELEASE"), Version.parse("1.1.7.BUILD-SNAPSHOT"))));
validateResolvedWebDependency(dependency.resolve(Version.parse("1.1.5.RELEASE")), "org.springframework.boot", validateResolvedWebDependency(dependency.resolve(Version.parse("1.1.5.RELEASE")), "org.springframework.boot",
"spring-boot-starter-web", "0.1.0.RELEASE", true); "spring-boot-starter-web", "0.1.0.RELEASE", true);
@@ -278,17 +278,17 @@ class DependencyTests {
@Test @Test
void resolveVersionWithX() { void resolveVersionWithX() {
Dependency dependency1 = Dependency.withId("foo1", "com.acme", "foo1", "0.3.0.RELEASE"); Dependency dependency1 = Dependency.withId("foo1", "com.acme", "foo1", "0.3.0.RELEASE");
dependency1.setVersionRange("1.2.x.RELEASE"); dependency1.setCompatibilityRange("1.2.x.RELEASE");
dependency1.resolve(); dependency1.resolve();
assertThat(dependency1.getVersionRange()).isEqualTo("1.2.999.RELEASE"); assertThat(dependency1.getCompatibilityRange()).isEqualTo("1.2.999.RELEASE");
} }
@Test @Test
void resolveVersionRangeWithX() { void resolveCompatibilityRangeWithX() {
Dependency dependency = Dependency.withId("foo1", "com.acme", "foo1", "0.3.0.RELEASE"); Dependency dependency = Dependency.withId("foo1", "com.acme", "foo1", "0.3.0.RELEASE");
dependency.setVersionRange("[1.1.0.RELEASE, 1.2.x.RELEASE)"); dependency.setCompatibilityRange("[1.1.0.RELEASE, 1.2.x.RELEASE)");
dependency.resolve(); dependency.resolve();
assertThat(dependency.getVersionRange()).isEqualTo("[1.1.0.RELEASE,1.2.999.RELEASE)"); assertThat(dependency.getCompatibilityRange()).isEqualTo("[1.1.0.RELEASE,1.2.999.RELEASE)");
} }
private static void validateResolvedWebDependency(Dependency dependency, String expectedGroupId, private static void validateResolvedWebDependency(Dependency dependency, String expectedGroupId,

View File

@@ -196,9 +196,9 @@ class InitializrConfigurationTests {
assertThat(kotlin.resolveKotlinVersion(Version.parse("1.3.2.RELEASE"))).isEqualTo("1.2.3"); assertThat(kotlin.resolveKotlinVersion(Version.parse("1.3.2.RELEASE"))).isEqualTo("1.2.3");
} }
private Kotlin.Mapping createKotlinVersionMapping(String versionRange, String kotlinVersion) { private Kotlin.Mapping createKotlinVersionMapping(String compatibilityRange, String kotlinVersion) {
Kotlin.Mapping mapping = new Kotlin.Mapping(); Kotlin.Mapping mapping = new Kotlin.Mapping();
mapping.setVersionRange(versionRange); mapping.setCompatibilityRange(compatibilityRange);
mapping.setVersion(kotlinVersion); mapping.setVersion(kotlinVersion);
return mapping; return mapping;
} }

View File

@@ -92,7 +92,7 @@ class InitializrMetadataTests {
} }
@Test @Test
void invalidBomVersionRangeMapping() { void invalidBomCompatibilityRangeMapping() {
InitializrMetadata metadata = initializeMetadata(); InitializrMetadata metadata = initializeMetadata();
BillOfMaterials bom = BillOfMaterials.create("org.acme", "foo-bom"); BillOfMaterials bom = BillOfMaterials.create("org.acme", "foo-bom");
bom.getMappings().add(Mapping.create("[1.2.0.RELEASE,1.3.0.M1)", "1.0.0")); bom.getMappings().add(Mapping.create("[1.2.0.RELEASE,1.3.0.M1)", "1.0.0"));
@@ -103,7 +103,7 @@ class InitializrMetadataTests {
} }
@Test @Test
void invalidBomVersionRangeMappingUnknownRepo() { void invalidBomCompatibilityRangeMappingUnknownRepo() {
InitializrMetadata metadata = initializeMetadata(); InitializrMetadata metadata = initializeMetadata();
BillOfMaterials bom = BillOfMaterials.create("org.acme", "foo-bom"); BillOfMaterials bom = BillOfMaterials.create("org.acme", "foo-bom");
bom.getMappings().add(Mapping.create("[1.0.0.RELEASE,1.3.0.M1)", "1.0.0")); bom.getMappings().add(Mapping.create("[1.0.0.RELEASE,1.3.0.M1)", "1.0.0"));
@@ -117,7 +117,7 @@ class InitializrMetadataTests {
} }
@Test @Test
void invalidBomVersionRangeMappingUnknownAdditionalBom() { void invalidBomCompatibilityRangeMappingUnknownAdditionalBom() {
InitializrMetadata metadata = initializeMetadata(); InitializrMetadata metadata = initializeMetadata();
BillOfMaterials bom = BillOfMaterials.create("org.acme", "foo-bom"); BillOfMaterials bom = BillOfMaterials.create("org.acme", "foo-bom");
bom.getMappings().add(Mapping.create("[1.0.0.RELEASE,1.3.0.M1)", "1.0.0")); bom.getMappings().add(Mapping.create("[1.0.0.RELEASE,1.3.0.M1)", "1.0.0"));
@@ -201,9 +201,9 @@ class InitializrMetadataTests {
metadata.getDependencies().getContent().add(group); metadata.getDependencies().getContent().add(group);
} }
private Kotlin.Mapping createKotlinVersionMapping(String versionRange, String kotlinVersion) { private Kotlin.Mapping createKotlinVersionMapping(String compatibilityRange, String kotlinVersion) {
Kotlin.Mapping mapping = new Kotlin.Mapping(); Kotlin.Mapping mapping = new Kotlin.Mapping();
mapping.setVersionRange(versionRange); mapping.setCompatibilityRange(compatibilityRange);
mapping.setVersion(kotlinVersion); mapping.setVersion(kotlinVersion);
return mapping; return mapping;
} }

View File

@@ -57,7 +57,7 @@ class MetadataBuildItemResolverTests {
} }
@Test @Test
void resoleDependencyWithMatchingEntryAndVersionRange() { void resoleDependencyWithMatchingEntryAndCompatibilityRange() {
InitializrMetadata metadata = new InitializrMetadata(); InitializrMetadata metadata = new InitializrMetadata();
DependencyGroup group = DependencyGroup.create("test"); DependencyGroup group = DependencyGroup.create("test");
Dependency dependency = Dependency.withId("test-dep", "com.example", "test"); Dependency dependency = Dependency.withId("test-dep", "com.example", "test");
@@ -102,7 +102,7 @@ class MetadataBuildItemResolverTests {
} }
@Test @Test
void resoleBomWithMatchingEntryAndVersionRange() throws MalformedURLException { void resoleBomWithMatchingEntryAndCompatibilityRange() throws MalformedURLException {
InitializrMetadata metadata = new InitializrMetadata(); InitializrMetadata metadata = new InitializrMetadata();
BillOfMaterials bom = BillOfMaterials.create("com.example", "bom", "0.0.1"); 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("[1.0.0.RELEASE, 2.0.0.RELEASE)", "1.0.0"));

View File

@@ -11,10 +11,10 @@ initializr:
versionProperty: my-api.version versionProperty: my-api.version
additionalBoms: ['my-api-dependencies-bom'] additionalBoms: ['my-api-dependencies-bom']
mappings: mappings:
- versionRange: "[2.0.0.RELEASE,2.1.6.RELEASE)" - compatibilityRange: "[2.0.0.RELEASE,2.1.6.RELEASE)"
version: 1.0.0.RELEASE version: 1.0.0.RELEASE
repositories: my-api-repo-1 repositories: my-api-repo-1
- versionRange: "2.2.1.RELEASE" - compatibilityRange: "2.2.1.RELEASE"
version: 2.0.0.RELEASE version: 2.0.0.RELEASE
repositories: my-api-repo-2 repositories: my-api-repo-2
my-api-dependencies-bom: my-api-dependencies-bom:
@@ -25,9 +25,9 @@ initializr:
kotlin: kotlin:
defaultVersion: 1.2 defaultVersion: 1.2
mappings: mappings:
- versionRange: "[1.5.0.RELEASE,2.0.0.M1)" - compatibilityRange: "[1.5.0.RELEASE,2.0.0.M1)"
version: 1.0 version: 1.0
- versionRange: "[2.0.0.M1,2.1.0.M1)" - compatibilityRange: "[2.0.0.M1,2.1.0.M1)"
version: 1.1 version: 1.1
repositories: repositories:
my-api-repo-1: my-api-repo-1:
@@ -85,12 +85,12 @@ initializr:
artifactId: biz artifactId: biz
scope: runtime scope: runtime
version: 1.3.5 version: 1.3.5
versionRange: 2.2.0.BUILD-SNAPSHOT compatibilityRange: 2.2.0.BUILD-SNAPSHOT
- name: Bur - name: Bur
id: org.acme:bur id: org.acme:bur
version: 2.1.0 version: 2.1.0
scope: test scope: test
versionRange: "[2.1.4.RELEASE,2.2.0.BUILD-SNAPSHOT)" compatibilityRange: "[2.1.4.RELEASE,2.2.0.BUILD-SNAPSHOT)"
- name: My API - name: My API
id : my-api id : my-api
groupId: org.acme groupId: org.acme

View File

@@ -55,8 +55,8 @@ public class InitializrMetadataV21JsonMapper extends InitializrMetadataV2JsonMap
@Override @Override
protected ObjectNode mapDependency(Dependency dependency) { protected ObjectNode mapDependency(Dependency dependency) {
ObjectNode content = mapValue(dependency); ObjectNode content = mapValue(dependency);
if (dependency.getVersionRange() != null) { if (dependency.getCompatibilityRange() != null) {
content.put("versionRange", dependency.getVersionRange()); content.put("versionRange", dependency.getCompatibilityRange());
} }
if (dependency.getLinks() != null && !dependency.getLinks().isEmpty()) { if (dependency.getLinks() != null && !dependency.getLinks().isEmpty()) {
content.set("_links", LinkMapper.mapLinks(dependency.getLinks())); content.set("_links", LinkMapper.mapLinks(dependency.getLinks()));

View File

@@ -173,8 +173,8 @@ public class InitializrMetadataV2JsonMapper implements InitializrMetadataJsonMap
} }
protected ObjectNode mapDependency(Dependency dependency) { protected ObjectNode mapDependency(Dependency dependency) {
if (dependency.getVersionRange() == null) { if (dependency.getCompatibilityRange() == null) {
// only map the dependency if no versionRange is set // only map the dependency if no compatibilityRange is set
return mapValue(dependency); return mapValue(dependency);
} }
return null; return null;

View File

@@ -159,13 +159,13 @@ class CommandLineHelpGeneratorTests {
} }
@Test @Test
void generateCapabilitiesWithVersionRange() throws IOException { void generateCapabilitiesWithCompatibilityRange() throws IOException {
Dependency first = Dependency.withId("first"); Dependency first = Dependency.withId("first");
first.setDescription("first desc"); first.setDescription("first desc");
first.setVersionRange("1.2.0.RELEASE"); first.setCompatibilityRange("1.2.0.RELEASE");
Dependency second = Dependency.withId("second"); Dependency second = Dependency.withId("second");
second.setDescription("second desc"); second.setDescription("second desc");
second.setVersionRange(" [1.2.0.RELEASE,1.3.0.M1) "); second.setCompatibilityRange(" [1.2.0.RELEASE,1.3.0.M1) ");
InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults() InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults()
.addDependencyGroup("test", first, second).build(); .addDependencyGroup("test", first, second).build();
String content = this.generator.generateSpringBootCliCapabilities(metadata, "https://fake-service"); String content = this.generator.generateSpringBootCliCapabilities(metadata, "https://fake-service");

View File

@@ -37,10 +37,10 @@ class DefaultDependencyMetadataProviderTests {
@Test @Test
void filterDependencies() { void filterDependencies() {
Dependency first = Dependency.withId("first", "org.foo", "first"); Dependency first = Dependency.withId("first", "org.foo", "first");
first.setVersionRange("2.1.4.RELEASE"); first.setCompatibilityRange("2.1.4.RELEASE");
Dependency second = Dependency.withId("second", "org.foo", "second"); Dependency second = Dependency.withId("second", "org.foo", "second");
Dependency third = Dependency.withId("third", "org.foo", "third"); Dependency third = Dependency.withId("third", "org.foo", "third");
third.setVersionRange("2.1.8.RELEASE"); third.setCompatibilityRange("2.1.8.RELEASE");
InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults() InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults()
.addDependencyGroup("test", first, second, third).build(); .addDependencyGroup("test", first, second, third).build();
DependencyMetadata dependencyMetadata = this.provider.get(metadata, Version.parse("2.1.5.RELEASE")); DependencyMetadata dependencyMetadata = this.provider.get(metadata, Version.parse("2.1.5.RELEASE"));

View File

@@ -40,11 +40,11 @@
"defaultVersion": "1.2", "defaultVersion": "1.2",
"mappings": [ "mappings": [
{ {
"versionRange": "[1.5.0.RELEASE,2.0.0.M1)", "compatibilityRange": "[1.5.0.RELEASE,2.0.0.M1)",
"version": "1.0" "version": "1.0"
}, },
{ {
"versionRange": "[2.0.0.M1,2.1.0.M1)", "compatibilityRange": "[2.0.0.M1,2.1.0.M1)",
"version": "1.1" "version": "1.1"
} }
] ]
@@ -102,14 +102,14 @@
], ],
"mappings": [ "mappings": [
{ {
"versionRange": "[2.0.0.RELEASE,2.1.6.RELEASE)", "compatibilityRange": "[2.0.0.RELEASE,2.1.6.RELEASE)",
"repositories": [ "repositories": [
"my-api-repo-1" "my-api-repo-1"
], ],
"version": "1.0.0.RELEASE" "version": "1.0.0.RELEASE"
}, },
{ {
"versionRange": "2.2.1.RELEASE", "compatibilityRange": "2.2.1.RELEASE",
"repositories": [ "repositories": [
"my-api-repo-2" "my-api-repo-2"
], ],
@@ -219,7 +219,7 @@
"name": "Biz", "name": "Biz",
"scope": "runtime", "scope": "runtime",
"version": "1.3.5", "version": "1.3.5",
"versionRange": "2.2.0.BUILD-SNAPSHOT" "compatibilityRange": "2.2.0.BUILD-SNAPSHOT"
}, },
{ {
"starter": true, "starter": true,
@@ -229,7 +229,7 @@
"name": "Bur", "name": "Bur",
"scope": "test", "scope": "test",
"version": "2.1.0", "version": "2.1.0",
"versionRange": "[2.1.4.RELEASE,2.2.0.BUILD-SNAPSHOT)" "compatibilityRange": "[2.1.4.RELEASE,2.2.0.BUILD-SNAPSHOT)"
}, },
{ {
"starter": true, "starter": true,