chore: bump commons and update for new modules

This commit is contained in:
Johannes Frohnmeyer 2023-11-08 09:15:59 +01:00
parent af84674c26
commit f4ed8a4bcb
Signed by: Johannes
GPG Key ID: E76429612C2929F4
24 changed files with 67 additions and 51 deletions

View File

@ -10,8 +10,8 @@ allprojects {
}
// common
val jfCommonsVersion by extra("1.3-SNAPSHOT")
val gsonCompileVersion by extra("1.3-SNAPSHOT")
val jfCommonsVersion by extra("1.5-SNAPSHOT")
val gsonCompileVersion by extra("1.4-SNAPSHOT")
val jbAnnotationsVersion by extra("24.0.1")
// launcher-imgui
val lwjglVersion by extra("3.3.2")

View File

@ -11,7 +11,10 @@ dependencies {
val jfCommonsVersion: String by rootProject.extra
api("io.gitlab.jfronny:commons:$jfCommonsVersion")
api("io.gitlab.jfronny:commons-gson:$jfCommonsVersion")
api("io.gitlab.jfronny:commons-http-client:$jfCommonsVersion")
api("io.gitlab.jfronny:commons-io:$jfCommonsVersion")
api("io.gitlab.jfronny:commons-logging:$jfCommonsVersion")
api("io.gitlab.jfronny:commons-serialize-gson:$jfCommonsVersion")
}
val javaVersion by extra(project.java.targetCompatibility)

View File

@ -1,15 +1,15 @@
package io.gitlab.jfronny.inceptum.common;
import io.gitlab.jfronny.commons.HttpUtils;
import io.gitlab.jfronny.commons.log.Logger;
import io.gitlab.jfronny.commons.log.StdoutLogger;
import io.gitlab.jfronny.commons.http.client.HttpClient;
import io.gitlab.jfronny.commons.logging.Logger;
import io.gitlab.jfronny.commons.logging.StdoutLogger;
import java.io.IOException;
public class InceptumEnvironmentInitializer {
public static void initialize() throws IOException {
Logger.registerFactory(InceptumEnvironmentInitializer::defaultFactory);
HttpUtils.setUserAgent("jfmods/inceptum/" + BuildMetadata.VERSION);
HttpClient.setUserAgent("jfmods/inceptum/" + BuildMetadata.VERSION);
InceptumConfig.load();
}

View File

@ -1,7 +1,7 @@
package io.gitlab.jfronny.inceptum.common;
import io.gitlab.jfronny.commons.HashUtils;
import io.gitlab.jfronny.commons.HttpUtils;
import io.gitlab.jfronny.commons.http.client.HttpClient;
import io.gitlab.jfronny.commons.io.HashUtils;
import io.gitlab.jfronny.commons.throwable.ThrowingFunction;
import io.gitlab.jfronny.commons.throwable.ThrowingSupplier;
@ -18,7 +18,7 @@ public class Net {
private static final ObjectCache OBJECT_CACHE = new ObjectCache(MetaHolder.CACHE_DIR);
public static byte[] downloadData(String url) throws IOException, URISyntaxException {
try (InputStream is = HttpUtils.get(url).sendInputStream()) {
try (InputStream is = HttpClient.get(url).sendInputStream()) {
return is.readAllBytes();
}
}
@ -35,7 +35,7 @@ public class Net {
}
public static <T> T downloadObject(String url, ThrowingFunction<String, T, IOException> func, boolean cache) throws IOException {
return downloadObject(url, () -> HttpUtils.get(url).sendString(), func, cache);
return downloadObject(url, () -> HttpClient.get(url).sendString(), func, cache);
}
public static <T> T downloadObject(String url, ThrowingFunction<String, T, IOException> func, String apiKey) throws IOException {
@ -75,7 +75,7 @@ public class Net {
}
public static String downloadString(String url) throws IOException, URISyntaxException {
return HttpUtils.get(url).sendString();
return HttpClient.get(url).sendString();
}
public static String downloadString(String url, String sha1) throws IOException, URISyntaxException {
@ -83,7 +83,7 @@ public class Net {
}
public static String downloadStringAuthenticated(String url, String apiKey) throws IOException, URISyntaxException {
return HttpUtils.get(url).header("x-api-key", apiKey).sendString();
return HttpClient.get(url).header("x-api-key", apiKey).sendString();
}
public static void downloadFile(String url, Path path) throws IOException, URISyntaxException {

View File

@ -2,7 +2,7 @@ package io.gitlab.jfronny.inceptum.common;
import io.gitlab.jfronny.commons.OSUtils;
import io.gitlab.jfronny.commons.io.JFiles;
import io.gitlab.jfronny.commons.log.Logger;
import io.gitlab.jfronny.commons.logging.Logger;
import java.awt.*;
import java.io.File;

View File

@ -1,6 +1,6 @@
package io.gitlab.jfronny.inceptum.common.api;
import io.gitlab.jfronny.commons.HttpUtils;
import io.gitlab.jfronny.commons.http.client.HttpClient;
import io.gitlab.jfronny.inceptum.common.Net;
import io.gitlab.jfronny.inceptum.common.Utils;
import io.gitlab.jfronny.inceptum.common.model.maven.*;
@ -35,7 +35,7 @@ public class MavenApi {
}
public static Pom getPom(String repo, ArtifactMeta meta) throws IOException, SAXException, URISyntaxException, XMLStreamException {
try (InputStream is = HttpUtils.get(Utils.join("/", repo, meta.getPomPath())).sendInputStream()) {
try (InputStream is = HttpClient.get(Utils.join("/", repo, meta.getPomPath())).sendInputStream()) {
Document doc = FACTORY.parse(is);
doc.getDocumentElement().normalize();
if (!"project".equals(doc.getDocumentElement().getNodeName())) throw new IOException("Illegal document name");
@ -132,7 +132,7 @@ public class MavenApi {
public static ArtifactMeta getMetadata(String repo, String artifact) throws IOException, SAXException, URISyntaxException {
ArtifactMeta sourceMeta = ArtifactMeta.parse(artifact);
try (InputStream is = HttpUtils.get(Utils.join("/", repo, sourceMeta.getMetadataPath())).sendInputStream()) {
try (InputStream is = HttpClient.get(Utils.join("/", repo, sourceMeta.getMetadataPath())).sendInputStream()) {
Document doc = FACTORY.parse(is);
doc.getDocumentElement().normalize();
if (!"metadata".equals(doc.getDocumentElement().getNodeName())) throw new IOException("Illegal document name");

View File

@ -8,6 +8,9 @@ module io.gitlab.jfronny.inceptum.common {
requires java.xml;
requires transitive io.gitlab.jfronny.commons;
requires transitive io.gitlab.jfronny.commons.gson;
requires transitive io.gitlab.jfronny.commons.http.client;
requires transitive io.gitlab.jfronny.commons.io;
requires transitive io.gitlab.jfronny.commons.logging;
requires transitive io.gitlab.jfronny.gson;
requires transitive io.gitlab.jfronny.gson.compile.core;
requires static org.jetbrains.annotations;

View File

@ -3,8 +3,8 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("inceptum.application")
id("com.github.johnrengelman.shadow")
kotlin("jvm") version "1.9.0"
kotlin("plugin.sam.with.receiver") version "1.9.0"
kotlin("jvm") version "1.9.20"
kotlin("plugin.sam.with.receiver") version "1.9.20"
}
application {

View File

@ -1,6 +1,6 @@
package io.gitlab.jfronny.inceptum.gtk.util
import io.gitlab.jfronny.commons.log.Logger
import io.gitlab.jfronny.commons.logging.Logger
import io.gitlab.jfronny.inceptum.common.Utils
object Log : Logger by Utils.LOGGER

View File

@ -29,9 +29,18 @@ var Widget.marginHorizontal: Int
get() = throw NotImplementedError()
var MessageDialog.markup: String
set(value) { setMarkup(value) }
set(value) { setMarkup(value.escapedMarkup) }
get() = throw NotImplementedError()
var Label.markup: String
set(value) { setMarkup(value.escapedMarkup) }
get() = throw NotImplementedError()
val String.escapedMarkup: String
get() = replace(unmatchedAnd, "&amp;")
private val unmatchedAnd = Regex("&(?![a-z]{1,6};|#[0-9]+;|#x[0-9A-F]+;)")
fun ActionRow.fixSubtitle() = ILabel.theme(firstChild!!.lastChild!!.prevSibling!!.lastChild as Label, ILabel.Mode.SUBTITLE)
fun EntryBuffer.clear() = deleteText(0, length)

View File

@ -8,6 +8,7 @@ import io.gitlab.jfronny.inceptum.gtk.control.assistant.KAssistant
import io.gitlab.jfronny.inceptum.gtk.schedule
import io.gitlab.jfronny.inceptum.gtk.util.I18n
import io.gitlab.jfronny.inceptum.gtk.util.Log
import io.gitlab.jfronny.inceptum.gtk.util.markup
import io.gitlab.jfronny.inceptum.gtk.util.toTypedArray
import io.gitlab.jfronny.inceptum.gtk.window.dialog.ProcessStateWatcherDialog
import io.gitlab.jfronny.inceptum.launcher.api.FabricMetaApi
@ -127,7 +128,7 @@ class NewInstanceWindow(app: Application) : KAssistant(app) {
val nc = ProcessStateWatcherDialog.State(pState)
if (nc != cachedState) {
cachedState = nc
stage.setMarkup(cachedState!!.msg)
stage.markup = cachedState!!.msg
progress.fraction = cachedState!!.progress.coerceAtMost(1f).toDouble()
widget.queueDraw()
}
@ -165,9 +166,9 @@ class NewInstanceWindow(app: Application) : KAssistant(app) {
val status = Label("")
onOpen {
if (isFailure) {
status.setMarkup("Something went wrong while creating the instance.\n\n$failureMessage")
status.markup = "Something went wrong while creating the instance.\n\n$failureMessage"
} else {
status.setMarkup("The instance was successfully created. You can now launch it using the main menu")
status.markup = "The instance was successfully created. You can now launch it using the main menu"
}
}

View File

@ -6,6 +6,7 @@ import io.gitlab.jfronny.inceptum.gtk.GtkEnvBackend
import io.gitlab.jfronny.inceptum.gtk.schedule
import io.gitlab.jfronny.inceptum.gtk.util.I18n
import io.gitlab.jfronny.inceptum.gtk.util.Log
import io.gitlab.jfronny.inceptum.gtk.util.markup
import io.gitlab.jfronny.inceptum.launcher.util.ProcessState
import org.gnome.glib.GLib
import org.gnome.gtk.*
@ -54,7 +55,7 @@ class ProcessStateWatcherDialog(
val nc = State(state)
if (nc != cachedState) {
cachedState = nc
setMarkup(cachedState!!.msg)
markup = cachedState!!.msg
progress.fraction = cachedState!!.progress.coerceAtMost(1f).toDouble()
widget.queueDraw()
}

View File

@ -7,10 +7,7 @@ import io.gitlab.jfronny.inceptum.gtk.control.KDropDown
import io.gitlab.jfronny.inceptum.gtk.control.KSignalListItemFactory
import io.gitlab.jfronny.inceptum.gtk.control.LoadingRevealer
import io.gitlab.jfronny.inceptum.gtk.control.settings.SettingsTab
import io.gitlab.jfronny.inceptum.gtk.util.I18n
import io.gitlab.jfronny.inceptum.gtk.util.clear
import io.gitlab.jfronny.inceptum.gtk.util.fixSubtitle
import io.gitlab.jfronny.inceptum.gtk.util.replaceAll
import io.gitlab.jfronny.inceptum.gtk.util.*
import io.gitlab.jfronny.inceptum.launcher.LauncherEnv
import io.gitlab.jfronny.inceptum.launcher.api.CurseforgeApi
import io.gitlab.jfronny.inceptum.launcher.api.ModrinthApi
@ -163,7 +160,7 @@ class ModsTab(window: InstanceSettingsWindow) : SettingsTab<Leaflet, InstanceSet
}
fun selectMod(mod: ModState): Unit {
//TODO detailed menu for version selection, ...
descriptionLabel.setMarkup(mod.description)
descriptionLabel.markup = mod.description
}
inner class ModsListView(model: StringList): ListView(ModsListSelectionModel(model), ModsListItemFactory()) {

View File

@ -9,5 +9,7 @@ module io.gitlab.jfronny.inceptum.launcher.gtk {
// Should theoretically already be included transitively through inceptum.launcher and inceptum.common
requires io.gitlab.jfronny.commons;
requires io.gitlab.jfronny.commons.io;
requires io.gitlab.jfronny.commons.logging;
requires java.desktop;
}

View File

@ -8,6 +8,6 @@ dependencies {
val jbAnnotationsVersion: String by rootProject.extra
api(project(":common"))
implementation("io.gitlab.jfronny:commons-jlhttp:$jfCommonsVersion")
api("io.gitlab.jfronny:commons-http-server:$jfCommonsVersion") // required for launcher-gtk for some reason
compileOnly("org.jetbrains:annotations:$jbAnnotationsVersion")
}

View File

@ -1,6 +1,6 @@
package io.gitlab.jfronny.inceptum.launcher.api;
import io.gitlab.jfronny.commons.HttpUtils;
import io.gitlab.jfronny.commons.http.client.HttpClient;
import io.gitlab.jfronny.inceptum.common.Net;
import io.gitlab.jfronny.inceptum.launcher.model.curseforge.CurseforgeFile;
import io.gitlab.jfronny.inceptum.launcher.model.curseforge.CurseforgeMod;
@ -74,7 +74,7 @@ public class CurseforgeApi {
}
public static FingerprintMatchesResponse.Result checkFingerprint(long hash) throws IOException, URISyntaxException {
try (Reader r = HttpUtils.post(API_URL + "fingerprints").bodyJson("{\"fingerprints\":[" + hash + "]}").sendReader()) {
try (Reader r = HttpClient.post(API_URL + "fingerprints").bodyJson("{\"fingerprints\":[" + hash + "]}").sendReader()) {
return GC_FingerprintMatchesResponse.read(r).data();
}
}

View File

@ -1,6 +1,6 @@
package io.gitlab.jfronny.inceptum.launcher.api;
import io.gitlab.jfronny.commons.cache.MemoryOperationResultCache;
import io.gitlab.jfronny.commons.io.cache.MemoryOperationResultCache;
import io.gitlab.jfronny.gson.compile.util.GList;
import io.gitlab.jfronny.gson.stream.JsonReader;
import io.gitlab.jfronny.inceptum.common.Net;

View File

@ -1,6 +1,6 @@
package io.gitlab.jfronny.inceptum.launcher.api.account;
import io.gitlab.jfronny.commons.HttpUtils;
import io.gitlab.jfronny.commons.http.client.HttpClient;
import io.gitlab.jfronny.inceptum.launcher.model.microsoft.*;
import io.gitlab.jfronny.inceptum.launcher.model.microsoft.request.*;
import io.gitlab.jfronny.inceptum.launcher.model.microsoft.response.*;
@ -31,7 +31,7 @@ public class MicrosoftAuthAPI {
public static final String MICROSOFT_MINECRAFT_ENTITLEMENTS_URL = "https://api.minecraftservices.com/entitlements/license?requestId=";
public static OauthTokenResponse tradeCodeForAccessToken(String code) throws IOException, URISyntaxException {
try (Reader r = HttpUtils.post(MICROSOFT_AUTH_TOKEN_URL)
try (Reader r = HttpClient.post(MICROSOFT_AUTH_TOKEN_URL)
.bodyForm(Map.of("client_id", MICROSOFT_LOGIN_CLIENT_ID,
"code", code,
"grant_type", "authorization_code",
@ -43,7 +43,7 @@ public class MicrosoftAuthAPI {
}
public static OauthTokenResponse refreshAccessToken(String refreshToken) throws IOException, URISyntaxException {
try (Reader r = HttpUtils.post(MICROSOFT_AUTH_TOKEN_URL)
try (Reader r = HttpClient.post(MICROSOFT_AUTH_TOKEN_URL)
.bodyForm(Map.of("client_id", MICROSOFT_LOGIN_CLIENT_ID,
"refresh_token", refreshToken,
"grant_type", "refresh_token",
@ -54,7 +54,7 @@ public class MicrosoftAuthAPI {
}
public static XboxLiveAuthResponse getXBLToken(String accessToken) throws IOException, URISyntaxException {
try (Reader r = HttpUtils.post(MICROSOFT_XBL_AUTH_TOKEN_URL)
try (Reader r = HttpClient.post(MICROSOFT_XBL_AUTH_TOKEN_URL)
.header("x-xbl-contract-version", "1")
.bodyJson(GC_XblTokenRequest.toJson(new XblTokenRequest(
new XblTokenRequest.Properties(
@ -71,7 +71,7 @@ public class MicrosoftAuthAPI {
}
public static XboxLiveAuthResponse getXstsToken(String xblToken) throws IOException, URISyntaxException {
try (Reader r = HttpUtils.post(MICROSOFT_XSTS_AUTH_TOKEN_URL)
try (Reader r = HttpClient.post(MICROSOFT_XSTS_AUTH_TOKEN_URL)
.header("x-xbl-contract-version", "1")
.bodyJson(GC_XstsTokenRequest.toJson(new XstsTokenRequest(
new XstsTokenRequest.Properties(
@ -87,7 +87,7 @@ public class MicrosoftAuthAPI {
}
public static LoginResponse loginToMinecraft(String xstsToken) throws IOException, URISyntaxException {
try (Reader r = HttpUtils.post(MICROSOFT_MINECRAFT_LOGIN_URL)
try (Reader r = HttpClient.post(MICROSOFT_MINECRAFT_LOGIN_URL)
.bodyJson(GC_LoginRequest.toJson(new LoginRequest(
xstsToken,
"PC_LAUNCHER"
@ -98,13 +98,13 @@ public class MicrosoftAuthAPI {
}
public static Entitlements getEntitlements(String accessToken) throws IOException, URISyntaxException {
try (Reader r = HttpUtils.get(MICROSOFT_MINECRAFT_ENTITLEMENTS_URL + UUID.randomUUID()).bearer(accessToken).sendReader()) {
try (Reader r = HttpClient.get(MICROSOFT_MINECRAFT_ENTITLEMENTS_URL + UUID.randomUUID()).bearer(accessToken).sendReader()) {
return GC_Entitlements.read(r);
}
}
public static Profile getMcProfile(String accessToken) throws IOException, URISyntaxException {
try (Reader r = HttpUtils.get(MICROSOFT_MINECRAFT_PROFILE_URL).bearer(accessToken).sendReader()) {
try (Reader r = HttpClient.get(MICROSOFT_MINECRAFT_PROFILE_URL).bearer(accessToken).sendReader()) {
return GC_Profile.read(r);
}
}

View File

@ -1,7 +1,7 @@
package io.gitlab.jfronny.inceptum.launcher.api.account;
import io.gitlab.jfronny.commons.jlhttp.JLHTTPServer;
import io.gitlab.jfronny.commons.jlhttp.util.VirtualHost;
import io.gitlab.jfronny.commons.http.server.JLHTTPServer;
import io.gitlab.jfronny.commons.http.server.util.VirtualHost;
import io.gitlab.jfronny.inceptum.common.Utils;
import io.gitlab.jfronny.inceptum.launcher.LauncherEnv;
import io.gitlab.jfronny.inceptum.launcher.model.microsoft.Entitlements;

View File

@ -1,8 +1,8 @@
package io.gitlab.jfronny.inceptum.launcher.model.inceptum;
import io.gitlab.jfronny.commons.HashUtils;
import io.gitlab.jfronny.commons.data.MutCollection;
import io.gitlab.jfronny.commons.data.delegate.DelegateMap;
import io.gitlab.jfronny.commons.io.HashUtils;
import io.gitlab.jfronny.gson.compile.annotations.GPrefer;
import io.gitlab.jfronny.gson.compile.annotations.GSerializable;
import io.gitlab.jfronny.inceptum.common.GsonPreset;

View File

@ -1,8 +1,8 @@
package io.gitlab.jfronny.inceptum.launcher.system.source;
import io.gitlab.jfronny.commons.HashUtils;
import io.gitlab.jfronny.commons.StringFormatter;
import io.gitlab.jfronny.commons.cache.MemoryOperationResultCache;
import io.gitlab.jfronny.commons.io.HashUtils;
import io.gitlab.jfronny.commons.io.cache.MemoryOperationResultCache;
import io.gitlab.jfronny.commons.tuple.Triple;
import io.gitlab.jfronny.commons.tuple.Tuple;
import io.gitlab.jfronny.inceptum.common.Net;

View File

@ -1,6 +1,6 @@
package io.gitlab.jfronny.inceptum.launcher.system.source;
import io.gitlab.jfronny.commons.HashUtils;
import io.gitlab.jfronny.commons.io.HashUtils;
import io.gitlab.jfronny.inceptum.common.Net;
import java.io.IOException;

View File

@ -1,7 +1,7 @@
package io.gitlab.jfronny.inceptum.launcher.system.source;
import io.gitlab.jfronny.commons.HashUtils;
import io.gitlab.jfronny.commons.cache.MemoryOperationResultCache;
import io.gitlab.jfronny.commons.io.HashUtils;
import io.gitlab.jfronny.commons.io.cache.MemoryOperationResultCache;
import io.gitlab.jfronny.commons.tuple.Tuple;
import io.gitlab.jfronny.inceptum.common.Net;
import io.gitlab.jfronny.inceptum.common.Utils;

View File

@ -26,7 +26,7 @@ module io.gitlab.jfronny.inceptum.launcher {
exports io.gitlab.jfronny.inceptum.launcher.util.gitignore;
requires transitive io.gitlab.jfronny.inceptum.common;
requires io.gitlab.jfronny.commons.jlhttp;
requires transitive io.gitlab.jfronny.commons.http.server;
requires static org.jetbrains.annotations;
requires static io.gitlab.jfronny.gson.compile.annotations;
}