mirror of
https://gitee.com/dcren/initializr.git
synced 2025-07-16 16:50:42 +08:00
Merge pull request #968 from htztomic
* pr/968: Polish "Rename versionRange attribute to compatibilityRange" Rename versionRange attribute to compatibilityRange Closes gh-968
This commit is contained in:
commit
7ffcd17a8c
@ -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);
|
||||||
|
@ -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);
|
||||||
|
@ -92,7 +92,7 @@ that dependency.
|
|||||||
* A `scope` (can be `compile`, `runtime`, `provided` or `test`).
|
* A `scope` (can be `compile`, `runtime`, `provided` or `test`).
|
||||||
* The reference to a `bom` or a `repository` that must be added to the project once
|
* The reference to a `bom` or a `repository` that must be added to the project once
|
||||||
that dependency is added.
|
that dependency is added.
|
||||||
* A `versionRange` used to determine the Spring Boot versions that are compatible
|
* A `compatibilityRange` used to determine the platform versions that are compatible
|
||||||
with the dependency.
|
with the dependency.
|
||||||
* Links to resources such as a guide or a reference doc section.
|
* Links to resources such as a guide or a reference doc section.
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ lines and further for some reason.
|
|||||||
artifactId: foo-core
|
artifactId: foo-core
|
||||||
bom: foo-bom
|
bom: foo-bom
|
||||||
repository: foo-repo
|
repository: foo-repo
|
||||||
versionRange: "[1.2.0.RELEASE,1.3.0.M1)"
|
compatibilityRange: "[1.2.0.RELEASE,1.3.0.M1)"
|
||||||
----
|
----
|
||||||
|
|
||||||
If one selects this entry, the `com.example.foo:foo-core}` dependency will be added
|
If one selects this entry, the `com.example.foo:foo-core}` dependency will be added
|
||||||
@ -145,7 +145,7 @@ the project as well (see the "Env section" above for a reference to those
|
|||||||
identifiers). Because the bom provides a dependency management for `foo-core` there
|
identifiers). Because the bom provides a dependency management for `foo-core` there
|
||||||
is no need to hard code the version in the configuration.
|
is no need to hard code the version in the configuration.
|
||||||
|
|
||||||
The `versionRange` syntax follows some simple rules: a square bracket "[" or "]"
|
The `compatibilityRange` syntax follows some simple rules: a square bracket "[" or "]"
|
||||||
denotes an inclusive end of the range and a round bracket "(" or ")" denotes an
|
denotes an inclusive end of the range and a round bracket "(" or ")" denotes an
|
||||||
exclusive end of the range. A range can also be unbounded by defining a a single
|
exclusive end of the range. A range can also be unbounded by defining a a single
|
||||||
version. In the example above, the dependency will be available as from
|
version. In the example above, the dependency will be available as from
|
||||||
@ -155,7 +155,7 @@ version. In the example above, the dependency will be available as from
|
|||||||
### Dependency group
|
### Dependency group
|
||||||
|
|
||||||
A dependency group gather a set of dependencies as well as some common settings:
|
A dependency group gather a set of dependencies as well as some common settings:
|
||||||
`bom`, `repository` and `versionRange`. If one of them is set, it is applied for all
|
`bom`, `repository` and `compatibilityRange`. If one of them is set, it is applied for all
|
||||||
dependencies within that group. It is still possible to override a particular value
|
dependencies within that group. It is still possible to override a particular value
|
||||||
at the dependency level.
|
at the dependency level.
|
||||||
|
|
||||||
|
@ -506,14 +506,15 @@ The rest of this section will detail the other configuration options.
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[dependencies-version-range]]
|
[[dependencies-compatibility-range]]
|
||||||
==== Availability (version range)
|
==== Compatibility Range
|
||||||
By default, a dependency is available regardless of the Spring Boot version you have
|
By default, a dependency is available regardless of the Spring Boot version you have
|
||||||
selected. If you need to restrict a dependency to a certain Spring Boot generation you
|
selected. If you need to restrict a dependency to a certain Spring Boot generation you
|
||||||
can add a `versionRange` attribute to its definition. A version range is a range of
|
can add a `compatibilityRange` attribute to its definition that defines a version range. A
|
||||||
versions of Spring Boot which are valid in combination with it. The versions are *not*
|
version range is a range of versions of Spring Boot which are valid in combination with
|
||||||
applied to the dependency itself, but rather used to filter out the dependency, or modify
|
it. The versions are *not* applied to the dependency itself, but rather used to filter out
|
||||||
it, when different versions of Spring Boot are selected for the generated project.
|
the dependency, or modify it, when different versions of Spring Boot are selected for the
|
||||||
|
generated project.
|
||||||
|
|
||||||
A typical version is composed of four parts: a major revision, a minor revision, a patch
|
A typical version is composed of four parts: a major revision, a minor revision, a patch
|
||||||
revision and a qualifier. Qualifiers are ordered as follows:
|
revision and a qualifier. Qualifiers are ordered as follows:
|
||||||
@ -662,18 +663,18 @@ Here's an example of a BOM with mappings:
|
|||||||
groupId: com.example.foo
|
groupId: com.example.foo
|
||||||
artifactId: acme-foo-dependencies
|
artifactId: acme-foo-dependencies
|
||||||
mappings:
|
mappings:
|
||||||
- versionRange: "[1.2.3.RELEASE,1.3.0.RELEASE)"
|
- compatibilityRange: "[1.2.3.RELEASE,1.3.0.RELEASE)"
|
||||||
groupId: com.example.bar
|
groupId: com.example.bar
|
||||||
artifactId: acme-foo-bom
|
artifactId: acme-foo-bom
|
||||||
version: Arcturus.SR6
|
version: Arcturus.SR6
|
||||||
- versionRange: "[1.3.0.RELEASE,1.4.0.RELEASE)"
|
- compatibilityRange: "[1.3.0.RELEASE,1.4.0.RELEASE)"
|
||||||
version: Botein.SR7
|
version: Botein.SR7
|
||||||
- versionRange: "[1.4.0.RELEASE,1.5.x.RELEASE)"
|
- compatibilityRange: "[1.4.0.RELEASE,1.5.x.RELEASE)"
|
||||||
version: Castor.SR6
|
version: Castor.SR6
|
||||||
- versionRange: "[1.5.0.RELEASE,1.5.x.BUILD-SNAPSHOT)"
|
- compatibilityRange: "[1.5.0.RELEASE,1.5.x.BUILD-SNAPSHOT)"
|
||||||
version: Diadem.RC1
|
version: Diadem.RC1
|
||||||
repositories: spring-milestones
|
repositories: spring-milestones
|
||||||
- versionRange: "1.5.x.BUILD-SNAPSHOT"
|
- compatibilityRange: "1.5.x.BUILD-SNAPSHOT"
|
||||||
version: Diadem.BUILD-SNAPSHOT
|
version: Diadem.BUILD-SNAPSHOT
|
||||||
repositories: spring-snapshots,spring-milestones
|
repositories: spring-snapshots,spring-milestones
|
||||||
----
|
----
|
||||||
@ -838,8 +839,8 @@ If your dependency requires a specific version of Spring Boot, ot different vers
|
|||||||
Spring Boot require different versions of your dependency there are a couple of mechanisms
|
Spring Boot require different versions of your dependency there are a couple of mechanisms
|
||||||
to configure that.
|
to configure that.
|
||||||
|
|
||||||
The simplest is to put a `versionRange` in the dependency declaration. This is a range of
|
The simplest is to put a `compatibilityRange` in the dependency declaration. This is a
|
||||||
versions of Spring Boot, not of your dependency. For example:
|
range of versions of Spring Boot, not of your dependency. For example:
|
||||||
|
|
||||||
[source,yaml,indent=0]
|
[source,yaml,indent=0]
|
||||||
----
|
----
|
||||||
@ -850,11 +851,11 @@ versions of Spring Boot, not of your dependency. For example:
|
|||||||
- name: Foo
|
- name: Foo
|
||||||
id: foo
|
id: foo
|
||||||
...
|
...
|
||||||
versionRange: 1.2.0.M1
|
compatibilityRange: 1.2.0.M1
|
||||||
- name: Bar
|
- name: Bar
|
||||||
id: bar
|
id: bar
|
||||||
...
|
...
|
||||||
versionRange: "[1.5.0.RC1,2.0.0.M1)"
|
compatibilityRange: "[1.5.0.RC1,2.0.0.M1)"
|
||||||
----
|
----
|
||||||
|
|
||||||
In this example `Foo` is available for Spring Boot 1.2.0 (or any milestone of 1.2.0) or
|
In this example `Foo` is available for Spring Boot 1.2.0 (or any milestone of 1.2.0) or
|
||||||
@ -862,7 +863,7 @@ greater, and `Bar` is available for Spring Boot 1.5.0 up to, but not including 2
|
|||||||
|
|
||||||
If different versions of your dependency work with different versions of Spring Boot,
|
If different versions of your dependency work with different versions of Spring Boot,
|
||||||
that's when you need the `mappings` property. A mapping is a combination of a
|
that's when you need the `mappings` property. A mapping is a combination of a
|
||||||
`versionRange` and some or all of the other properties of the dependency, overriding
|
`compatibilityRange` and some or all of the other properties of the dependency, overriding
|
||||||
the values defined at the top level. For example:
|
the values defined at the top level. For example:
|
||||||
|
|
||||||
[source,yaml,indent=0]
|
[source,yaml,indent=0]
|
||||||
@ -875,12 +876,12 @@ the values defined at the top level. For example:
|
|||||||
id: foo
|
id: foo
|
||||||
groupId: org.acme.foo
|
groupId: org.acme.foo
|
||||||
artifactId: foo-spring-boot-starter
|
artifactId: foo-spring-boot-starter
|
||||||
versionRange: 1.3.0.RELEASE
|
compatibilityRange: 1.3.0.RELEASE
|
||||||
bom: cloud-task-bom
|
bom: cloud-task-bom
|
||||||
mappings:
|
mappings:
|
||||||
- versionRange: "[1.3.0.RELEASE,1.3.x.RELEASE]"
|
- compatibilityRange: "[1.3.0.RELEASE,1.3.x.RELEASE]"
|
||||||
artifactId: foo-starter
|
artifactId: foo-starter
|
||||||
- versionRange: "1.4.0.RELEASE"
|
- compatibilityRange: "1.4.0.RELEASE"
|
||||||
----
|
----
|
||||||
|
|
||||||
In this example, The artifact of `foo` was changed to `foo-spring-boot-starter` as of the
|
In this example, The artifact of `foo` was changed to `foo-spring-boot-starter` as of the
|
||||||
@ -899,10 +900,10 @@ A mapping can also be applied to a BOM declaration. For example:
|
|||||||
artifactId: my-api-bom
|
artifactId: my-api-bom
|
||||||
additionalBoms: ['my-api-dependencies-bom']
|
additionalBoms: ['my-api-dependencies-bom']
|
||||||
mappings:
|
mappings:
|
||||||
- versionRange: "[1.0.0.RELEASE,1.1.6.RELEASE)"
|
- compatibilityRange: "[1.0.0.RELEASE,1.1.6.RELEASE)"
|
||||||
version: 1.0.0.RELEASE
|
version: 1.0.0.RELEASE
|
||||||
repositories: my-api-repo-1
|
repositories: my-api-repo-1
|
||||||
- versionRange: "1.2.1.RELEASE"
|
- compatibilityRange: "1.2.1.RELEASE"
|
||||||
version: 2.0.0.RELEASE
|
version: 2.0.0.RELEASE
|
||||||
repositories: my-api-repo-2
|
repositories: my-api-repo-2
|
||||||
----
|
----
|
||||||
@ -971,7 +972,7 @@ Spring Boot starter is added as well.
|
|||||||
A dependency group is a hint for user interface implementations, to group things together
|
A dependency group is a hint for user interface implementations, to group things together
|
||||||
for users when they are selecting dependencies. It is also a convenient way to share
|
for users when they are selecting dependencies. It is also a convenient way to share
|
||||||
settings between dependencies because every dependency inherits all the settings. The most
|
settings between dependencies because every dependency inherits all the settings. The most
|
||||||
common settings in a group are the `groupId`, `versionRange` and `bom`:
|
common settings in a group are the `groupId`, `compatibilityRange` and `bom`:
|
||||||
|
|
||||||
[source,yaml,indent=0]
|
[source,yaml,indent=0]
|
||||||
----
|
----
|
||||||
@ -979,7 +980,7 @@ common settings in a group are the `groupId`, `versionRange` and `bom`:
|
|||||||
dependencies:
|
dependencies:
|
||||||
- name: Stuff
|
- name: Stuff
|
||||||
bom: stuff-bom
|
bom: stuff-bom
|
||||||
versionRange: "[1.3.0.RELEASE,2.0.0.M1)"
|
compatibilityRange: "[1.3.0.RELEASE,2.0.0.M1)"
|
||||||
content:
|
content:
|
||||||
...
|
...
|
||||||
----
|
----
|
||||||
|
@ -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
|
||||||
|
@ -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 + ", " : "")
|
||||||
|
@ -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());
|
||||||
|
@ -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;
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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() {
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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");
|
||||||
|
@ -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
|
||||||
|
@ -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,
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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"));
|
||||||
|
@ -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
|
||||||
|
@ -29,8 +29,8 @@ import org.springframework.hateoas.UriTemplate;
|
|||||||
/**
|
/**
|
||||||
* A {@link InitializrMetadataJsonMapper} handling the metadata format for v2.1
|
* A {@link InitializrMetadataJsonMapper} handling the metadata format for v2.1
|
||||||
* <p>
|
* <p>
|
||||||
* Version 2.1 brings the "versionRange" attribute for a dependency to restrict the Spring
|
* Version 2.1 brings the "compatibilityRange" attribute for a dependency to restrict the
|
||||||
* Boot versions that can be used against it. That version also adds an additional
|
* Spring Boot versions that can be used against it. That version also adds an additional
|
||||||
* `dependencies` endpoint.
|
* `dependencies` endpoint.
|
||||||
*
|
*
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
@ -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()));
|
||||||
|
@ -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;
|
||||||
|
@ -31,7 +31,7 @@ public enum InitializrMetadataVersion {
|
|||||||
V2("application/vnd.initializr.v2+json"),
|
V2("application/vnd.initializr.v2+json"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add "versionRange" attribute to any dependency to specify which Spring Boot
|
* Add "compatibilityRange" attribute to any dependency to specify which Spring Boot
|
||||||
* versions are compatible with it. Also provide a separate "dependencies" endpoint to
|
* versions are compatible with it. Also provide a separate "dependencies" endpoint to
|
||||||
* query dependencies metadata.
|
* query dependencies metadata.
|
||||||
*/
|
*/
|
||||||
|
@ -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");
|
||||||
|
@ -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"));
|
||||||
|
@ -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,
|
||||||
|
Loading…
Reference in New Issue
Block a user