From f8382b55c3947943d74cb8d4a38856b8bf7b42c3 Mon Sep 17 00:00:00 2001 From: Danielle Voznyy Date: Fri, 31 May 2024 13:17:56 -0400 Subject: [PATCH] chore: Update deps chore: Use versions toml for all deps --- build.gradle.kts | 76 ++++++++++++++----- gradle.properties | 4 +- gradle/libs.versions.toml | 16 ++++ .../launchy/data/auth/SessionStorage.kt | 8 +- .../mineinabyss/launchy/data/config/Config.kt | 1 + .../launchy/data/config/GameInstanceConfig.kt | 1 + .../com/mineinabyss/launchy/logic/Auth.kt | 16 +++- .../modpack/settings/ModInfoDisplay.kt | 3 +- 8 files changed, 97 insertions(+), 28 deletions(-) create mode 100644 gradle/libs.versions.toml diff --git a/build.gradle.kts b/build.gradle.kts index 0ad25bd..2f48904 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,12 +1,14 @@ import de.undercouch.gradle.tasks.download.Download import org.apache.tools.ant.taskdefs.condition.Os import org.jetbrains.compose.desktop.application.dsl.TargetFormat -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { alias(idofrontLibs.plugins.mia.kotlin.jvm) alias(idofrontLibs.plugins.kotlinx.serialization) - alias(idofrontLibs.plugins.compose) + alias(idofrontLibs.plugins.jetbrainsCompose) + alias(idofrontLibs.plugins.compose.compiler) + alias(idofrontLibs.plugins.dependencyversions) + alias(idofrontLibs.plugins.version.catalog.update) id("de.undercouch.download") version "5.3.1" } @@ -26,25 +28,31 @@ dependencies { implementation(compose.materialIconsExtended) implementation(idofrontLibs.kotlinx.serialization.json) implementation(idofrontLibs.kotlinx.serialization.kaml) - implementation("io.ktor:ktor-client-core:2.3.8") - implementation("io.ktor:ktor-client-cio:2.3.8") - implementation("io.ktor:ktor-client-cio-jvm:2.3.8") + implementation(libs.ktor.core) + implementation(libs.ktor.cio) + implementation(libs.ktor.cio.jvm) - implementation("com.darkrockstudios:mpfilepicker:3.1.0") - implementation("org.rauschig:jarchivelib:1.2.0") + implementation(libs.mpfilepicker) + implementation(libs.jarchivelib) - implementation("net.raphimc:MinecraftAuth:4.0.0") - implementation("dev.3-3:jmccc-mcdownloader:3.1.4") - implementation("dev.3-3:jmccc:3.1.4") -// implementation("dev.3-3:jmccc-microsoft-authenticator:3.1.4") + implementation(libs.minecraftAuth) + implementation(libs.jmccc.mcdownloader) + implementation(libs.jmccc) } -tasks.withType { - kotlinOptions.freeCompilerArgs = listOf( - "-opt-in=androidx.compose.material3.ExperimentalMaterial3Api", - "-opt-in=androidx.compose.foundation.ExperimentalFoundationApi", - "-opt-in=androidx.compose.ui.ExperimentalComposeUiApi", - ) +idofront { + setJvmToolchain = false +} + +kotlin { + jvmToolchain(17) + compilerOptions { + freeCompilerArgs.addAll( + "-opt-in=androidx.compose.material3.ExperimentalMaterial3Api", + "-opt-in=androidx.compose.foundation.ExperimentalFoundationApi", + "-opt-in=androidx.compose.ui.ExperimentalComposeUiApi", + ) + } } val appInstallerName = "Launchy-" + when { @@ -74,7 +82,14 @@ compose.desktop { else -> targetFormats(TargetFormat.AppImage) } - modules("java.instrument", "java.management", "java.naming", "java.security.jgss", "jdk.httpserver", "jdk.unsupported") + modules( + "java.instrument", + "java.management", + "java.naming", + "java.security.jgss", + "jdk.httpserver", + "jdk.unsupported" + ) packageName = appName packageVersion = "${project.version}" val strippedVersion = project.version.toString().substringBeforeLast("-") @@ -163,3 +178,28 @@ tasks { } } } + +versionCatalogUpdate { + keep { + keepUnusedPlugins = true + keepUnusedVersions = true + keepUnusedLibraries = true + } +} + +tasks { + dependencyUpdates { + rejectVersionIf { + fun isNonStable(version: String): Boolean { + val unstableKeywords = listOf( + "-beta", + "-rc", + "-alpha", + ) + + return unstableKeywords.any { version.contains(it, ignoreCase = true) } + } + isNonStable(candidate.version) + } + } +} diff --git a/gradle.properties b/gradle.properties index 34f3992..f3198da 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ group=com.mineinabyss -version=2.0.0-beta.0 -idofrontVersion=0.23.0 +version=2.0.0-beta.1 +idofrontVersion=0.24.3 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..265cf86 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,16 @@ +[versions] +jarchivelib = "1.2.0" +jmccc = "3.1.4" +ktor = "2.3.11" +minecraftAuth = "4.0.2" +mpfilepicker = "3.1.0" + +[libraries] +jarchivelib = { module = "org.rauschig:jarchivelib", version.ref = "jarchivelib" } +jmccc = { module = "dev.3-3:jmccc", version.ref = "jmccc" } +jmccc-mcdownloader = { module = "dev.3-3:jmccc-mcdownloader", version.ref = "jmccc" } +ktor-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" } +ktor-cio-jvm = { module = "io.ktor:ktor-client-cio-jvm", version.ref = "ktor" } +ktor-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" } +minecraftAuth = { module = "net.raphimc:MinecraftAuth", version.ref = "minecraftAuth" } +mpfilepicker = { module = "com.darkrockstudios:mpfilepicker", version.ref = "mpfilepicker" } diff --git a/src/main/kotlin/com/mineinabyss/launchy/data/auth/SessionStorage.kt b/src/main/kotlin/com/mineinabyss/launchy/data/auth/SessionStorage.kt index cde24f6..540e9f7 100644 --- a/src/main/kotlin/com/mineinabyss/launchy/data/auth/SessionStorage.kt +++ b/src/main/kotlin/com/mineinabyss/launchy/data/auth/SessionStorage.kt @@ -3,11 +3,9 @@ package com.mineinabyss.launchy.data.auth import com.google.gson.GsonBuilder import com.google.gson.JsonParser import com.mineinabyss.launchy.data.Dirs -import kotlinx.serialization.ExperimentalSerializationApi +import com.mineinabyss.launchy.logic.Auth import kotlinx.serialization.Serializable -import net.raphimc.minecraftauth.MinecraftAuth import net.raphimc.minecraftauth.step.java.session.StepFullJavaSession.FullJavaSession -import java.io.InputStreamReader import java.util.* import kotlin.io.path.* @@ -25,7 +23,7 @@ data class SessionStorage( val targetFile = (Dirs.accounts / "$uuid.json") if (!targetFile.exists()) return null return runCatching { - MinecraftAuth.JAVA_DEVICE_CODE_LOGIN.fromJson( + Auth.JAVA_DEVICE_CODE_LOGIN.fromJson( JsonParser.parseString( targetFile.readText() ).asJsonObject @@ -42,7 +40,7 @@ data class SessionStorage( } fun save(session: FullJavaSession) { - val json = MinecraftAuth.JAVA_DEVICE_CODE_LOGIN.toJson(session) + val json = Auth.JAVA_DEVICE_CODE_LOGIN.toJson(session) val targetFile = (Dirs.accounts / "${session.mcProfile.id}.json").createParentDirectories() targetFile.deleteIfExists() targetFile.createFile() diff --git a/src/main/kotlin/com/mineinabyss/launchy/data/config/Config.kt b/src/main/kotlin/com/mineinabyss/launchy/data/config/Config.kt index 916e9c1..39b18bb 100644 --- a/src/main/kotlin/com/mineinabyss/launchy/data/config/Config.kt +++ b/src/main/kotlin/com/mineinabyss/launchy/data/config/Config.kt @@ -1,5 +1,6 @@ package com.mineinabyss.launchy.data.config +import com.charleskorn.kaml.decodeFromStream import com.mineinabyss.launchy.data.Dirs import com.mineinabyss.launchy.data.Formats import kotlinx.serialization.Serializable diff --git a/src/main/kotlin/com/mineinabyss/launchy/data/config/GameInstanceConfig.kt b/src/main/kotlin/com/mineinabyss/launchy/data/config/GameInstanceConfig.kt index 601b2f1..492bf0b 100644 --- a/src/main/kotlin/com/mineinabyss/launchy/data/config/GameInstanceConfig.kt +++ b/src/main/kotlin/com/mineinabyss/launchy/data/config/GameInstanceConfig.kt @@ -3,6 +3,7 @@ package com.mineinabyss.launchy.data.config import androidx.compose.runtime.mutableStateOf import androidx.compose.ui.graphics.painter.BitmapPainter import androidx.compose.ui.res.loadImageBitmap +import com.charleskorn.kaml.decodeFromStream import com.charleskorn.kaml.encodeToStream import com.mineinabyss.launchy.data.Dirs import com.mineinabyss.launchy.data.Formats diff --git a/src/main/kotlin/com/mineinabyss/launchy/logic/Auth.kt b/src/main/kotlin/com/mineinabyss/launchy/logic/Auth.kt index 3e56c0b..117eaa2 100644 --- a/src/main/kotlin/com/mineinabyss/launchy/logic/Auth.kt +++ b/src/main/kotlin/com/mineinabyss/launchy/logic/Auth.kt @@ -18,6 +18,16 @@ import java.util.* object Auth { + val JAVA_DEVICE_CODE_LOGIN = MinecraftAuth.ALT_JAVA_DEVICE_CODE_LOGIN + //TODO override with our own oauth app +// .builder() +// .withClientId("00000000402b5328") +// .withScope("service::user.auth.xboxlive.com::MBI_SSL") +// .deviceCode() +// .withDeviceToken("Win32") +// .sisuTitleAuthentication("rp://api.minecraftservices.com/") +// .buildMinecraftJavaProfileStep(true) + suspend fun authOrShowDialog( state: LaunchyState, profile: ProfileState, @@ -59,14 +69,16 @@ object Auth { onVerificationRequired: (VerificationRequired) -> Unit, onAuthenticate: (FullJavaSession) -> Unit, ) { + MinecraftAuth.builder() val httpClient = MinecraftAuth.createHttpClient() val previousSession = state.currentProfile?.let { SessionStorage.load(it.uuid) } if (previousSession != null) { - val refreshedSession = MinecraftAuth.JAVA_DEVICE_CODE_LOGIN.refresh(httpClient, previousSession) + println("refreshing token") + val refreshedSession = JAVA_DEVICE_CODE_LOGIN.refresh(httpClient, previousSession) onAuthenticate(refreshedSession) return } - val javaSession = MinecraftAuth.JAVA_DEVICE_CODE_LOGIN.getFromInput( + val javaSession = JAVA_DEVICE_CODE_LOGIN.getFromInput( httpClient, MsaDeviceCodeCallback { msaDeviceCode: MsaDeviceCode -> onVerificationRequired( diff --git a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/settings/ModInfoDisplay.kt b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/settings/ModInfoDisplay.kt index 294481d..ac40edc 100644 --- a/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/settings/ModInfoDisplay.kt +++ b/src/main/kotlin/com/mineinabyss/launchy/ui/screens/modpack/settings/ModInfoDisplay.kt @@ -8,6 +8,7 @@ import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* import androidx.compose.material.LinearProgressIndicator import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.rounded.OpenInNew import androidx.compose.material.icons.rounded.* import androidx.compose.material3.* import androidx.compose.runtime.* @@ -147,7 +148,7 @@ fun ModInfoDisplay(group: Group, mod: Mod) { ) { IconButton(onClick = { DesktopHelpers.browse(mod.info.homepage) }) { Icon( - imageVector = Icons.Rounded.OpenInNew, + imageVector = Icons.AutoMirrored.Rounded.OpenInNew, contentDescription = "Homepage" ) }