Partial implementation of Spring Boot Releases
This commit is contained in:
@@ -186,4 +186,22 @@ public class SpringProjectUtil {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Version getVersion(String version) {
|
||||
Pattern pattern = Pattern.compile(VERSION_PATTERN_STR);
|
||||
Matcher matcher = pattern.matcher(version);
|
||||
if (matcher.find() && matcher.groupCount() > 4) {
|
||||
String major = matcher.group(1);
|
||||
String minor = matcher.group(2);
|
||||
String patch = matcher.group(3);
|
||||
String qualifier = matcher.group(5);
|
||||
return new Version(
|
||||
Integer.parseInt(major),
|
||||
Integer.parseInt(minor),
|
||||
Integer.parseInt(patch),
|
||||
qualifier
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,4 @@ public class GenerationsEmbedded extends JsonHalLinks implements JsonHalEmbedded
|
||||
public Generations get_embedded() {
|
||||
return _embedded;
|
||||
}
|
||||
|
||||
public void set_embedded(Generations _embedded) {
|
||||
this._embedded = _embedded;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,4 @@ package org.springframework.ide.vscode.boot.validation.generations.json;
|
||||
public interface JsonHalEmbedded<T> {
|
||||
|
||||
T get_embedded();
|
||||
|
||||
void set_embedded(T _embedded);
|
||||
}
|
||||
|
||||
@@ -22,39 +22,19 @@ public class Links {
|
||||
return self;
|
||||
}
|
||||
|
||||
public void setSelf(Link self) {
|
||||
this.self = self;
|
||||
}
|
||||
|
||||
public Link getReleases() {
|
||||
return releases;
|
||||
}
|
||||
|
||||
public void setReleases(Link releases) {
|
||||
this.releases = releases;
|
||||
}
|
||||
|
||||
public Link getGenerations() {
|
||||
return generations;
|
||||
}
|
||||
|
||||
public void setGenerations(Link generations) {
|
||||
this.generations = generations;
|
||||
}
|
||||
|
||||
public Link getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public void setParent(Link parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public Link getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
public void setProject(Link project) {
|
||||
this.project = project;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.springframework.ide.vscode.boot.validation.generations.json;
|
||||
|
||||
import org.springframework.ide.vscode.commons.java.SpringProjectUtil;
|
||||
import org.springframework.ide.vscode.commons.java.Version;
|
||||
|
||||
public class Release {
|
||||
|
||||
private String version;
|
||||
private String status;
|
||||
private boolean current;
|
||||
|
||||
public Version getVersion() {
|
||||
return SpringProjectUtil.getVersion(version);
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public boolean isCurrent() {
|
||||
return current;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.springframework.ide.vscode.boot.validation.generations.json;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class Releases {
|
||||
|
||||
private Release[] releases;
|
||||
|
||||
public List<Release> getReleases() {
|
||||
return releases != null ? Arrays.asList(releases) : ImmutableList.of();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import org.springframework.ide.vscode.boot.validation.generations.SpringProjects
|
||||
public class SpringProject extends JsonHalLinks {
|
||||
|
||||
private Generations generations;
|
||||
private Releases releases;
|
||||
|
||||
|
||||
private String name;
|
||||
@@ -52,4 +53,18 @@ public class SpringProject extends JsonHalLinks {
|
||||
}
|
||||
return this.generations;
|
||||
}
|
||||
|
||||
public Releases getReleases(SpringProjectsClient client) throws Exception {
|
||||
// cache the releases to prevent frequent calls to the client
|
||||
if (this.releases == null) {
|
||||
Links _links = get_links();
|
||||
if (_links != null) {
|
||||
Link genLink = _links.getReleases();
|
||||
if (genLink != null) {
|
||||
// this.releases = client.getGenerations(genLink.getHref());
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.releases;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,4 @@ public class SpringProjectsEmbedded extends JsonHalLinks implements JsonHalEmbed
|
||||
public SpringProjects get_embedded() {
|
||||
return _embedded;
|
||||
}
|
||||
|
||||
public void set_embedded(SpringProjects _embedded) {
|
||||
this._embedded = _embedded;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,4 +134,26 @@ public class ProjectGenerationsValidationTest {
|
||||
version = SpringProjectUtil.getDependencyVersion("spring-boot-actuator-1.2.3.BUILD-SNAPSHOT.jar", "spring-boot");
|
||||
assertNull(version);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVersionCalculation() throws Exception {
|
||||
Version version = SpringProjectUtil.getVersion("2.7.5");
|
||||
assertEquals(2, version.getMajor());
|
||||
assertEquals(7, version.getMinor());
|
||||
assertEquals(5, version.getPatch());
|
||||
assertNull(version.getQualifier());
|
||||
|
||||
version = SpringProjectUtil.getVersion("3.0.0-SNAPSHOT");
|
||||
assertEquals(3, version.getMajor());
|
||||
assertEquals(0, version.getMinor());
|
||||
assertEquals(0, version.getPatch());
|
||||
assertEquals(version.getQualifier(), "SNAPSHOT");
|
||||
|
||||
|
||||
version = SpringProjectUtil.getVersion("2.6.14-RC2");
|
||||
assertEquals(2, version.getMajor());
|
||||
assertEquals(6, version.getMinor());
|
||||
assertEquals(14, version.getPatch());
|
||||
assertEquals(version.getQualifier(), "RC2");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user