Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: native distribution #3171

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ minecraft-exported-crash-info*
/build/
/HMCL/build/
/HMCLCore/build/
/HMCLauncher/build/
/HMCLTransformerDiscoveryService/build/
/minecraft/libraries/HMCLTransformerDiscoveryService/build/

Expand Down
Binary file added HMCL/image/hmcl.icns
Binary file not shown.
Binary file added HMCL/image/hmcl.ico
Binary file not shown.
89 changes: 89 additions & 0 deletions HMCLauncher/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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")
}
}
}
}
7 changes: 7 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ rootProject.name = "HMCL3"
include(
"HMCL",
"HMCLCore",
"HMCLauncher",
"HMCLTransformerDiscoveryService"
)

Expand Down