help tooling detect which versions to use

Co-authored-by: Daniel Garnier-Moiroux <git@garnier.wf>

Enhance SpringBootVersionResolver

[issue] Make this package-protected ; you don't want this class to be a part of your public API (same as MapMapper).
[suggestion] set the default value for forcedVersion to -1, it's a usual convention for "this is invalid".

Co-authored-by: Daniel Garnier-Moiroux <git@garnier.wf>
This commit is contained in:
Anthony Dahanne
2023-02-16 09:39:58 -05:00
parent 81739ee14f
commit 34316c314e
3 changed files with 9 additions and 5 deletions

View File

@@ -12,6 +12,8 @@
<description>Test project to verify Spring Cloud Bindings works properly with Spring Boot 2</description>
<properties>
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<spring-boot.version>2.5.14</spring-boot.version>
</properties>
<dependencies>

View File

@@ -12,6 +12,8 @@
<description>Test project to verify Spring Cloud Bindings works properly with Spring Boot 2</description>
<properties>
<java.version>17</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<spring-boot.version>3.0.2</spring-boot.version>
</properties>
<dependencies>

View File

@@ -2,19 +2,19 @@ package org.springframework.cloud.bindings.boot;
import org.springframework.boot.SpringBootVersion;
public class SpringBootVersionResolver {
class SpringBootVersionResolver {
private int forcedVersion;
private int forcedVersion = -1;
public SpringBootVersionResolver() {
SpringBootVersionResolver() {
}
protected SpringBootVersionResolver(int forcedVersion) {
this.forcedVersion = forcedVersion;
}
public boolean isBootMajorVersionEnabled(int bootVersion) {
if (forcedVersion != 0) {
protected boolean isBootMajorVersionEnabled(int bootVersion) {
if (forcedVersion != -1) {
return forcedVersion == bootVersion;
}
int major = Integer.parseInt(SpringBootVersion.getVersion().split("\\.")[0]);