Fix UpdateChecker
This commit is contained in:
parent
4f546014d1
commit
3c3474c6ab
|
@ -27,13 +27,18 @@ public class UpdateChecker {
|
|||
GitlabPackage stable = null;
|
||||
ComparableVersion stableVersion = null;
|
||||
packageLoop: for (GitlabPackage info : GitlabApi.getPackages(project)) {
|
||||
if (info.status.equals("default")) {
|
||||
if (info.status.equals("default") && info.name.equals("io/gitlab/jfronny/inceptum/Inceptum")) {
|
||||
for (GitlabPipeline pipeline : info.pipelines) {
|
||||
for (GitlabJob job : GitlabApi.getJobs(project, pipeline.id)) {
|
||||
if (!job.name.equals("build_test")) continue;
|
||||
InceptumVersion iv = GitlabApi.downloadObject("projects/" + project.id + "/jobs/" + job.id + "/artifacts/version.json", InceptumVersion.class);
|
||||
if (iv.jvm > jvm) {
|
||||
error.accept("A newer JVM is required to use the latest inceptum version. Please update!");
|
||||
try {
|
||||
InceptumVersion iv = GitlabApi.downloadObject("projects/" + project.id + "/jobs/" + job.id + "/artifacts/version.json", InceptumVersion.class);
|
||||
if (iv.jvm > jvm) {
|
||||
error.accept("A newer JVM is required to use the latest inceptum version. Please update!");
|
||||
continue packageLoop;
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
continue packageLoop;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +1,28 @@
|
|||
package io.gitlab.jfronny.inceptum.util.api;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import io.gitlab.jfronny.inceptum.gson.ComparableVersionAdapter;
|
||||
import io.gitlab.jfronny.inceptum.model.ComparableVersion;
|
||||
import io.gitlab.jfronny.inceptum.model.gitlab.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.Type;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class GitlabApi {
|
||||
private static final Gson GSON = new Gson();
|
||||
private static final Gson GSON = new GsonBuilder()
|
||||
.registerTypeAdapter(ComparableVersion.class, new ComparableVersionAdapter())
|
||||
.excludeFieldsWithModifiers(Modifier.TRANSIENT)
|
||||
.excludeFieldsWithModifiers(Modifier.PRIVATE)
|
||||
.setPrettyPrinting()
|
||||
.create();
|
||||
private static final Type packageInfoListType = new TypeToken<List<GitlabPackage>>() {}.getType();
|
||||
private static final Type jobListType = new TypeToken<List<GitlabJob>>() {}.getType();
|
||||
private static final Type packageFileInfoListType = new TypeToken<List<GitlabPackageFile>>() {}.getType();
|
||||
|
@ -23,7 +32,9 @@ public class GitlabApi {
|
|||
}
|
||||
|
||||
public static List<GitlabPackage> getPackages(GitlabProject project) throws IOException {
|
||||
return downloadObject("projects/" + project.id + "/packages", packageInfoListType);
|
||||
List<GitlabPackage> list = downloadObject("projects/" + project.id + "/packages", packageInfoListType);
|
||||
list.sort((left, right) -> right.created_at.compareTo(left.created_at));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<GitlabJob> getJobs(GitlabProject project, Long pipelineId) throws IOException {
|
||||
|
|
Loading…
Reference in New Issue