diff --git a/.gitignore b/.gitignore index f6dfb93727..5b95c6c357 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ minecraft-exported-crash-info* /build/ /HMCL/build/ /HMCLCore/build/ +/HMCLauncher/build/ /HMCLTransformerDiscoveryService/build/ /minecraft/libraries/HMCLTransformerDiscoveryService/build/ diff --git a/HMCL/image/hmcl.icns b/HMCL/image/hmcl.icns new file mode 100644 index 0000000000..1308778725 Binary files /dev/null and b/HMCL/image/hmcl.icns differ diff --git a/HMCL/image/hmcl.ico b/HMCL/image/hmcl.ico new file mode 100644 index 0000000000..421a9aff4f Binary files /dev/null and b/HMCL/image/hmcl.ico differ diff --git a/HMCLauncher/build.gradle.kts b/HMCLauncher/build.gradle.kts new file mode 100644 index 0000000000..dd31767b13 --- /dev/null +++ b/HMCLauncher/build.gradle.kts @@ -0,0 +1,89 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.compose.desktop.application.dsl.TargetFormat + +plugins { + id("org.jetbrains.kotlin.multiplatform") version "2.0.0" + id("org.jetbrains.kotlin.plugin.compose") version "2.0.0" + id("org.jetbrains.compose") version "1.6.11" +} + +kotlin { + jvm("desktop") { + compilerOptions { + jvmTarget = JvmTarget.JVM_11 + noJdk = true + } + } + + sourceSets { + commonMain.dependencies { + implementation(project(":HMCL")) + } + } +} + +val mVersion = Unit.let { + val VERSION_ROOT = System.getenv("VERSION_ROOT") ?: "3.5" + val BUILD_NUMBER_OFFSET = System.getenv("BUILD_NUMBER_OFFSET")?.toIntOrNull() ?: 0 + val BUILD_NUMBER = System.getenv("BUILD_NUMBER")?.toIntOrNull()?.let BUILD_NUMBER@{ + return@BUILD_NUMBER it - BUILD_NUMBER_OFFSET + } ?: 0 + return@let "$VERSION_ROOT.$BUILD_NUMBER" +} + +compose.desktop { + application { + mainClass = "org.jackhuang.hmcl.Main" + + jvmArgs( + "--add-exports=java.base/jdk.internal.loader=ALL-UNNAMED", + "--add-opens=java.base/java.lang=ALL-UNNAMED", + "-XX:MinHeapFreeRatio=5", + "-XX:MaxHeapFreeRatio=15", + ) + + buildTypes.release { + proguard { + isEnabled = false + } + } + + nativeDistributions { + targetFormats( + TargetFormat.Dmg, + TargetFormat.Msi, TargetFormat.Exe, + TargetFormat.Deb, + ) + + modules( + "jdk.unsupported", + "jdk.zipfs", + "jdk.management", + "jdk.jsobject", + "jdk.xml.dom", + "java.net.http", + ) + + packageName = rootProject.name + packageVersion = mVersion + copyright = "Copyright(c) 2013-2024 huangyuhui." + + val iconBasePath = "../HMCL/image" + macOS { + bundleID = "org.jackhuang.hmcl" + appCategory = "public.app-category.games" + iconFile = file("$iconBasePath/hmcl.icns") + } + windows { + dirChooser = true + perUserInstall = true + menuGroup = rootProject.name + upgradeUuid = "e8917524-75d2-a935-3314-8167bf4a9209" + iconFile = file("$iconBasePath/hmcl.ico") + } + linux { + iconFile = file("$iconBasePath/hmcl.png") + } + } + } +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000000..5ef5731758 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,7 @@ +kotlin.code.style=official + +#Gradle +org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\="-Xmx2048M" + +#Kotlin Multiplatform +kotlin.mpp.enableCInteropCommonization=true diff --git a/settings.gradle.kts b/settings.gradle.kts index 6cb5238d6a..69f7fb77d5 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -2,6 +2,7 @@ rootProject.name = "HMCL3" include( "HMCL", "HMCLCore", + "HMCLauncher", "HMCLTransformerDiscoveryService" )