Quodana doesn't support Java 17 apparently

This commit is contained in:
Johannes Frohnmeyer 2022-01-27 17:57:13 +01:00
parent 0eb72d859e
commit 9519ba6da3
Signed by: Johannes
GPG Key ID: E76429612C2929F4
12 changed files with 27 additions and 43 deletions

View File

@ -10,7 +10,6 @@ stages:
- build
- portable
- deploy
- test
build_test:
stage: build
@ -91,14 +90,3 @@ pages:
- public
only:
- master
qodana:
stage: test
image:
name: jetbrains/qodana-jvm
entrypoint: ['']
script:
- /opt/idea/bin/entrypoint --results-dir=$CI_PROJECT_DIR/qodana --save-report --report-dir=$CI_PROJECT_DIR/qodana/report
artifacts:
paths:
- qodana

View File

@ -150,7 +150,7 @@ public class InceptumGui {
assert is != null;
io.setFontDefault(io.getFonts().addFontFromMemoryTTF(is.readAllBytes(), 16f));
} catch (IOException e) {
e.printStackTrace();
Utils.LOGGER.error("Could not load font", e);
}
applyTheme();
}

View File

@ -28,24 +28,23 @@ public class UpdateCheckCommand extends Command {
@Override
protected void invoke(CommandArgs args) {
if (install && !args.wrapped) {
System.err.println("Automatic updates are not supported without the wrapper");
Utils.LOGGER.error("Automatic updates are not supported without the wrapper");
return;
}
UpdateInfo updateUrl = getUpdate();
if (updateUrl == null) {
System.out.println("No update was found");
Utils.LOGGER.info("No update was found");
} else {
if (install) {
System.out.println("Installing from " + updateUrl);
Utils.LOGGER.info("Installing from " + updateUrl);
try {
update(updateUrl, false);
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
System.err.println("Could not download update");
Utils.LOGGER.error("Could not download update", e);
}
}
else {
System.out.println("An update was found: " + updateUrl);
Utils.LOGGER.info("An update was found: " + updateUrl);
}
}
}
@ -55,7 +54,7 @@ public class UpdateCheckCommand extends Command {
Utils.LOGGER.error("No stable version was found, switching to experimental channel");
ConfigHolder.CONFIG.channel = channel;
ConfigHolder.saveConfig();
}, Utils.LOGGER::info, Utils.LOGGER::error, Utils.LOGGER::error);
});
}
public static void update(UpdateInfo source, boolean relaunch) throws IOException, URISyntaxException {
@ -69,14 +68,13 @@ public class UpdateCheckCommand extends Command {
if (relaunch) {
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
try {
System.out.println();
new ProcessBuilder(JvmUtils.getJvm(),
"-jar",
jarPath.toString())
.inheritIO()
.start();
} catch (IOException e) {
e.printStackTrace();
Utils.LOGGER.error("Could not relaunch", e);
}
}));
}

View File

@ -57,7 +57,7 @@ public class InstanceView {
try {
Steps.reDownload(path, Steps.createProcessState());
} catch (IOException e) {
e.printStackTrace();
Utils.LOGGER.error("Could not redownload instance, trying to start anyways", e);
}
InstanceLauncher.launchClient(path, instance);
}

View File

@ -54,7 +54,7 @@ public class AddModWindow extends Window {
if (!this.query.get().equals(query)) return;
cf = cs;
} catch (IOException e) {
e.printStackTrace();
Utils.LOGGER.error("Could not run search", e);
}
}, "search" + query).start();
}

View File

@ -41,7 +41,7 @@ public class GeneralTab extends Tab {
InceptumGui.open(new InstanceEditWindow(newPath, window.instance));
window.close();
} catch (IOException e) {
e.printStackTrace();
Inceptum.showError("Could not rename", e);
}
});
imc.snapshotsBox();

View File

@ -99,7 +99,7 @@ public class ModsTab extends Tab {
if (ImGui.button(mod.getName())) selected = mod.path();
}
} catch (IOException e) {
e.printStackTrace();
Utils.LOGGER.error("Could not show mod list", e);
}
ImGui.endChild();
ImGui.sameLine();

View File

@ -53,7 +53,7 @@ class ModsDirScannerImpl implements ModsDirScanner {
if (!descriptions.containsKey(path)) return false;
}
} catch (IOException e) {
e.printStackTrace();
Utils.LOGGER.error("Could not list files in mods dir", e);
}
return true;
}

View File

@ -42,10 +42,7 @@ public class Wrapper {
private static void downloadLatest() throws IOException {
System.err.println("No Inceptum jar was identified");
UpdateInfo ui = UpdateChecker.check(UpdateChannel.Stable, new ComparableVersion("0"), OSCheck.OS.getMojName(), c -> {}, System.out::println, System.err::println, (s, e) -> {
e.printStackTrace();
System.err.println(s);
});
UpdateInfo ui = UpdateChecker.check(UpdateChannel.Stable, new ComparableVersion("0"), OSCheck.OS.getMojName(), c -> {});
if (ui == null) {
throw new FileNotFoundException("Could not identify a valid inceptum version. Are you connected to the internet?");
}
@ -73,13 +70,13 @@ public class Wrapper {
pathChosen = inceptumVersionPath;
}
else {
System.out.println("Candidate " + inceptumVersionPath + " failed: doesn't exist");
Utils.LOGGER.error("Candidate " + inceptumVersionPath + " failed: doesn't exist");
}
}
}
}
if (pathChosen == null) {
System.err.println("Something went wrong, please try again");
Utils.LOGGER.error("Something went wrong, please try again");
return Optional.empty();
}
return Optional.of(pathChosen);

View File

@ -1,5 +1,7 @@
package io.gitlab.jfronny.inceptum;
import io.gitlab.jfronny.inceptum.util.Utils;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
@ -10,7 +12,7 @@ public class WrapperStrap {
public static final ClassLoader SYSTEM_LOADER = ClassLoader.getSystemClassLoader();
public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, IOException, URISyntaxException, NoSuchFieldException {
System.out.println("Starting Inceptum Wrapper ClassLoader");
Utils.LOGGER.info("Starting Inceptum Wrapper ClassLoader");
switchEnv(new File(WrapperStrap.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toPath(),
"io.gitlab.jfronny.inceptum.Wrapper",
args);

View File

@ -71,7 +71,7 @@ public class MetaHolder {
try {
return new File(url.toURI()).toPath().getParent().resolve("run");
} catch (URISyntaxException e) {
e.printStackTrace();
Utils.LOGGER.error("Could not resolve dev env run dir");
return simpleRunDir;
}
} else {

View File

@ -9,17 +9,16 @@ import io.gitlab.jfronny.inceptum.util.api.GitlabApi;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
public class UpdateChecker {
private static final long PROJECT_ID = 30862253L;
public static UpdateInfo check(UpdateChannel channel, ComparableVersion current, String flavor, Consumer<UpdateChannel> channelInvalid, Consumer<String> out, Consumer<String> error, BiConsumer<String, Exception> showError) {
public static UpdateInfo check(UpdateChannel channel, ComparableVersion current, String flavor, Consumer<UpdateChannel> channelInvalid) {
try {
int jvm = Runtime.version().feature();
if (flavor.equals("custom")) {
out.accept("Custom build, skipping update check");
Utils.LOGGER.error("Custom build, skipping update check");
return null;
}
GitlabProject project = GitlabApi.getProject(PROJECT_ID);
@ -35,7 +34,7 @@ public class UpdateChecker {
try {
InceptumVersion iv = HttpUtils.get(GitlabApi.PROJECTS + project.id + "/jobs/" + job.id + "/artifacts/version.json").sendJson(InceptumVersion.class);
if (iv.jvm > jvm) {
error.accept("A newer JVM is required to use the latest inceptum version. Please update!");
Utils.LOGGER.error("A newer JVM is required to use the latest inceptum version. Please update!");
continue packageLoop;
}
}
@ -68,17 +67,17 @@ public class UpdateChecker {
case CI -> experimental;
case Stable -> stable;
};
out.accept("Latest version is " + info.version + ", current is " + current);
Utils.LOGGER.info("Latest version is " + info.version + ", current is " + current);
if (current.compareTo(new ComparableVersion(info.version)) >= 0) {
out.accept("Up-to-date");
Utils.LOGGER.info("Up-to-date");
return null;
}
GitlabPackageFile file = GitlabApi.getFile(project, info, f -> f.file_name.endsWith('-' + flavor + ".jar"));
if (file == null)
error.accept("No valid package was discovered");
Utils.LOGGER.error("No valid package was discovered");
else return new UpdateInfo("https://gitlab.com/" + project.path_with_namespace + "/-/package_files/" + file.id + "/download", file.file_sha1, new ComparableVersion(info.version));
} catch (IOException | URISyntaxException e) {
showError.accept("Could not check for updates", e);
Utils.LOGGER.error("Could not check for updates", e);
}
return null;
}