Move common code to "common" module and launcher to "launcher" module
This commit is contained in:
parent
66c80af2d7
commit
2677e49743
|
@ -20,7 +20,8 @@ build_test:
|
|||
- gradle --build-cache build publish -Pflavor=windows -Ppublic -Ptimestamp=$TIMESTAMP
|
||||
- gradle --build-cache build publish -Pflavor=linux -Ppublic -Ptimestamp=$TIMESTAMP
|
||||
- gradle --build-cache build publish -Pflavor=macos -Ppublic -Ptimestamp=$TIMESTAMP
|
||||
- cp build/libs/*-*-*-*.jar ./
|
||||
- mkdir -p build/libs
|
||||
- cp launcher/build/libs/*-*-*-*.jar ./
|
||||
- cp wrapper/build/libs/* build/libs/
|
||||
- cp wrapper/build/libs/*.exe wrapper.exe
|
||||
- cp wrapper/build/libs/*-all.jar wrapper.jar
|
||||
|
|
|
@ -2,24 +2,9 @@ import org.gradle.internal.os.OperatingSystem
|
|||
import org.ajoberstar.grgit.Grgit
|
||||
|
||||
plugins {
|
||||
java
|
||||
application
|
||||
`maven-publish`
|
||||
id("com.github.johnrengelman.shadow") version "7.1.2"
|
||||
id("org.ajoberstar.grgit") version "5.0.0" apply false
|
||||
}
|
||||
|
||||
application {
|
||||
mainClass.set("io.gitlab.jfronny.inceptum.Inceptum")
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
setUrl("https://gitlab.com/api/v4/projects/35745143/packages/maven")
|
||||
}
|
||||
}
|
||||
|
||||
var currentVer = "0.0.0+nogit"
|
||||
if (File(".git").exists()) {
|
||||
val grgit: Grgit = Grgit.open(mapOf("dir" to rootProject.projectDir.toString()))
|
||||
|
@ -51,75 +36,4 @@ val flavor: String by extra(if (flavorProp != "custom") flavorProp else when (Op
|
|||
else -> throw IllegalStateException()
|
||||
})
|
||||
val isPublic by extra(project.hasProperty("public"))
|
||||
val isRelease by extra(project.hasProperty("release"))
|
||||
|
||||
dependencies {
|
||||
implementation("ch.qos.logback:logback-classic:$logbackVersion")
|
||||
implementation("io.gitlab.jfronny:commons:$jfCommonsVersion")
|
||||
implementation("io.gitlab.jfronny:commons-gson:$jfCommonsVersion")
|
||||
implementation("io.gitlab.jfronny:commons-slf4j:$jfCommonsVersion")
|
||||
implementation("org.eclipse.jgit:org.eclipse.jgit:$jgitVersion")
|
||||
implementation(project(":wrapper"))
|
||||
|
||||
implementation(platform("org.lwjgl:lwjgl-bom:$lwjglVersion"))
|
||||
|
||||
arrayOf("", "-opengl", "-glfw", "-tinyfd").forEach { it ->
|
||||
implementation("org.lwjgl:lwjgl$it:$lwjglVersion")
|
||||
if (flavor == "windows" || flavor == "fat") implementation("org.lwjgl:lwjgl$it::natives-windows")
|
||||
if (flavor == "linux" || flavor == "fat") implementation("org.lwjgl:lwjgl$it::natives-linux")
|
||||
if (flavor == "macos" || flavor == "fat") implementation("org.lwjgl:lwjgl$it::natives-macos")
|
||||
}
|
||||
|
||||
implementation("io.github.spair:imgui-java-binding:$imguiVersion") // https://github.com/SpaiR/imgui-java
|
||||
implementation ("io.github.spair:imgui-java-lwjgl3:$imguiVersion")
|
||||
|
||||
if (flavor == "windows" || flavor == "fat") implementation("io.github.spair:imgui-java-natives-windows:$imguiVersion")
|
||||
if (flavor == "linux" || flavor == "fat") implementation("io.github.spair:imgui-java-natives-linux:$imguiVersion")
|
||||
if (flavor == "macos" || flavor == "fat") implementation("io.github.spair:imgui-java-natives-macos:$imguiVersion")
|
||||
}
|
||||
|
||||
tasks.processResources {
|
||||
inputs.property("version", project.version)
|
||||
|
||||
filesMatching("version.json") {
|
||||
expand(
|
||||
"version" to project.version,
|
||||
"flavor" to flavorProp,
|
||||
"isPublic" to isPublic,
|
||||
"isRelease" to isRelease,
|
||||
"jvm" to project.java.targetCompatibility
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
tasks.shadowJar {
|
||||
archiveClassifier.set(flavorProp)
|
||||
exclude("about.html")
|
||||
exclude("plugin.properties")
|
||||
exclude("META-INF/**")
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("mavenJava") {
|
||||
artifact(tasks.shadowJar) {
|
||||
builtBy(tasks.shadowJar)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isPublic) {
|
||||
repositories.maven {
|
||||
url = uri("https://gitlab.com/api/v4/projects/30862253/packages/maven")
|
||||
name = "gitlab"
|
||||
|
||||
credentials(HttpHeaderCredentials::class) {
|
||||
name = "Job-Token"
|
||||
value = System.getenv()["CI_JOB_TOKEN"]
|
||||
}
|
||||
authentication {
|
||||
create<HttpHeaderAuthentication>("header")
|
||||
}
|
||||
}
|
||||
}
|
||||
repositories.mavenLocal()
|
||||
}
|
||||
val isRelease by extra(project.hasProperty("release"))
|
|
@ -0,0 +1,29 @@
|
|||
plugins {
|
||||
`java-library`
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
setUrl("https://gitlab.com/api/v4/projects/35745143/packages/maven")
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api("io.gitlab.jfronny:commons:${rootProject.extra["jfCommonsVersion"]}")
|
||||
api("io.gitlab.jfronny:commons-gson:${rootProject.extra["jfCommonsVersion"]}")
|
||||
implementation("io.gitlab.jfronny:commons-slf4j:${rootProject.extra["jfCommonsVersion"]}")
|
||||
implementation("ch.qos.logback:logback-classic:${rootProject.extra["logbackVersion"]}")
|
||||
}
|
||||
|
||||
tasks.processResources {
|
||||
filesMatching("version.json") {
|
||||
expand(
|
||||
"version" to project.version,
|
||||
"flavor" to rootProject.extra["flavorProp"],
|
||||
"isPublic" to rootProject.extra["isPublic"],
|
||||
"isRelease" to rootProject.extra["isRelease"],
|
||||
"jvm" to project.java.targetCompatibility
|
||||
)
|
||||
}
|
||||
}
|
|
@ -37,6 +37,7 @@ public class MetaHolder {
|
|||
public static final Path ASSETS_DIR = BASE_PATH.resolve("assets");
|
||||
public static final Path INSTANCE_DIR = BASE_PATH.resolve("instances");
|
||||
public static final Path CACHE_DIR = BASE_PATH.resolve("cache");
|
||||
private static boolean isWrapper = false;
|
||||
|
||||
private static Path getConfigPath() {
|
||||
return switch (OSUtils.TYPE) {
|
||||
|
@ -69,4 +70,12 @@ public class MetaHolder {
|
|||
return simpleRunDir;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setWrapperFlag() {
|
||||
isWrapper = true;
|
||||
}
|
||||
|
||||
public static boolean isWrapper() {
|
||||
return isWrapper;
|
||||
}
|
||||
}
|
|
@ -6,7 +6,6 @@ import io.gitlab.jfronny.commons.log.Logger;
|
|||
import io.gitlab.jfronny.commons.serialize.gson.api.GsonHolder;
|
||||
import io.gitlab.jfronny.commons.throwable.ThrowingConsumer;
|
||||
import io.gitlab.jfronny.commons.throwable.ThrowingSupplier;
|
||||
import io.gitlab.jfronny.inceptum.WrapperStrap;
|
||||
import io.gitlab.jfronny.inceptum.util.cache.GsonFileCache;
|
||||
|
||||
import java.awt.*;
|
||||
|
@ -25,6 +24,7 @@ import java.util.stream.Stream;
|
|||
public class Utils {
|
||||
public static final Pattern VALID_FILENAME = Pattern.compile("[a-zA-Z0-9_\\-.][a-zA-Z0-9 _\\-.]*[a-zA-Z0-9_\\-.]");
|
||||
public static final Logger LOGGER = Logger.forName("Inceptum");
|
||||
private static ClassLoader SYSTEM_LOADER = ClassLoader.getSystemClassLoader();
|
||||
private static final GsonFileCache OBJECT_CACHE = new GsonFileCache(MetaHolder.CACHE_DIR);
|
||||
|
||||
public static byte[] downloadData(String url) throws IOException, URISyntaxException {
|
||||
|
@ -263,9 +263,13 @@ public class Utils {
|
|||
synchronized (zipFsCache) {
|
||||
if (!zipFsCache.containsKey(zip) || zipFsCache.get(zip).isClosed()) {
|
||||
URI fileUri = zip.toUri();
|
||||
zipFsCache.put(zip, MultiAccessFileSystem.create(new URI("jar:" + fileUri.getScheme(), fileUri.getPath(), null), create ? Map.of("create", "true") : Map.of(), WrapperStrap.SYSTEM_LOADER));
|
||||
zipFsCache.put(zip, MultiAccessFileSystem.create(new URI("jar:" + fileUri.getScheme(), fileUri.getPath(), null), create ? Map.of("create", "true") : Map.of(), SYSTEM_LOADER));
|
||||
}
|
||||
return zipFsCache.get(zip).createLens();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setSystemLoader(ClassLoader loader) {
|
||||
SYSTEM_LOADER = loader;
|
||||
}
|
||||
}
|
|
@ -49,6 +49,7 @@ public class GsonFileCache {
|
|||
}
|
||||
else container.put(key, builder.get());
|
||||
}
|
||||
//noinspection unchecked
|
||||
return (T) container.get(key);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
plugins {
|
||||
java
|
||||
application
|
||||
`maven-publish`
|
||||
id("com.github.johnrengelman.shadow") version "7.1.2"
|
||||
}
|
||||
|
||||
application {
|
||||
mainClass.set("io.gitlab.jfronny.inceptum.Inceptum")
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
setUrl("https://gitlab.com/api/v4/projects/35745143/packages/maven")
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
val flavor: String by rootProject.extra
|
||||
val lwjglVersion: String by rootProject.extra
|
||||
val imguiVersion: String by rootProject.extra
|
||||
|
||||
implementation(project(":common"))
|
||||
implementation("org.eclipse.jgit:org.eclipse.jgit:${rootProject.extra["jgitVersion"]}")
|
||||
implementation(platform("org.lwjgl:lwjgl-bom:$lwjglVersion"))
|
||||
|
||||
arrayOf("", "-opengl", "-glfw", "-tinyfd").forEach { it ->
|
||||
implementation("org.lwjgl:lwjgl$it:$lwjglVersion")
|
||||
if (flavor == "windows" || flavor == "fat") implementation("org.lwjgl:lwjgl$it::natives-windows")
|
||||
if (flavor == "linux" || flavor == "fat") implementation("org.lwjgl:lwjgl$it::natives-linux")
|
||||
if (flavor == "macos" || flavor == "fat") implementation("org.lwjgl:lwjgl$it::natives-macos")
|
||||
}
|
||||
|
||||
implementation("io.github.spair:imgui-java-binding:$imguiVersion") // https://github.com/SpaiR/imgui-java
|
||||
implementation ("io.github.spair:imgui-java-lwjgl3:$imguiVersion")
|
||||
|
||||
if (flavor == "windows" || flavor == "fat") implementation("io.github.spair:imgui-java-natives-windows:$imguiVersion")
|
||||
if (flavor == "linux" || flavor == "fat") implementation("io.github.spair:imgui-java-natives-linux:$imguiVersion")
|
||||
if (flavor == "macos" || flavor == "fat") implementation("io.github.spair:imgui-java-natives-macos:$imguiVersion")
|
||||
}
|
||||
|
||||
tasks.shadowJar {
|
||||
archiveClassifier.set(rootProject.extra["flavorProp"] as String)
|
||||
exclude("about.html")
|
||||
exclude("plugin.properties")
|
||||
exclude("META-INF/**")
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("mavenJava") {
|
||||
artifact(tasks.shadowJar) {
|
||||
builtBy(tasks.shadowJar)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (rootProject.extra["isPublic"] == true) {
|
||||
repositories.maven {
|
||||
url = uri("https://gitlab.com/api/v4/projects/30862253/packages/maven")
|
||||
name = "gitlab"
|
||||
|
||||
credentials(HttpHeaderCredentials::class) {
|
||||
name = "Job-Token"
|
||||
value = System.getenv()["CI_JOB_TOKEN"]
|
||||
}
|
||||
authentication {
|
||||
create<HttpHeaderAuthentication>("header")
|
||||
}
|
||||
}
|
||||
}
|
||||
repositories.mavenLocal()
|
||||
}
|
|
@ -16,6 +16,7 @@ import io.gitlab.jfronny.inceptum.util.api.McApi;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.sql.Wrapper;
|
||||
import java.util.Scanner;
|
||||
import java.util.function.Consumer;
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
package io.gitlab.jfronny.inceptum.frontend.cli.commands;
|
||||
|
||||
import io.gitlab.jfronny.inceptum.Inceptum;
|
||||
import io.gitlab.jfronny.inceptum.WrapperStrap;
|
||||
import io.gitlab.jfronny.inceptum.frontend.cli.*;
|
||||
import io.gitlab.jfronny.inceptum.util.MetaHolder;
|
||||
|
||||
public class WrapperCommand extends Command {
|
||||
public WrapperCommand() {
|
||||
|
@ -16,7 +15,7 @@ public class WrapperCommand extends Command {
|
|||
|
||||
@Override
|
||||
public CommandResolution resolve(CommandArgs args) {
|
||||
if (WrapperStrap.class.getClassLoader() == Inceptum.class.getClassLoader()) {
|
||||
if (MetaHolder.isWrapper()) {
|
||||
throw new IllegalStateException("The WrapperStrap classloader does not match the inceptum loader. Are you using the latest wrapper?");
|
||||
}
|
||||
return Commands.COMMANDS_ROOT.resolve(args);
|
|
@ -2,6 +2,8 @@ package io.gitlab.jfronny.inceptum.frontend.gui.window;
|
|||
|
||||
import com.sun.net.httpserver.*;
|
||||
import imgui.*;
|
||||
import io.gitlab.jfronny.commons.serialize.Serializer;
|
||||
import io.gitlab.jfronny.commons.serialize.SerializerHolder;
|
||||
import io.gitlab.jfronny.commons.serialize.gson.api.*;
|
||||
import io.gitlab.jfronny.inceptum.*;
|
||||
import io.gitlab.jfronny.inceptum.model.microsoft.*;
|
||||
|
@ -131,7 +133,7 @@ public class MicrosoftLoginWindow extends Window {
|
|||
|
||||
Store store = MicrosoftAuthAPI.getMcEntitlements(loginResponse.accessToken);
|
||||
|
||||
Utils.LOGGER.info(GsonHolder.getGson().toJson(store));
|
||||
Utils.LOGGER.info(SerializerHolder.getInstance().serialize(store));
|
||||
|
||||
if (!(store.items.stream().anyMatch(i -> i.name.equalsIgnoreCase("product_minecraft"))
|
||||
&& store.items.stream().anyMatch(i -> i.name.equalsIgnoreCase("game_minecraft")))) {
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue