forked from Wynntils/launchy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
151 lines (134 loc) · 4.88 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import de.undercouch.gradle.tasks.download.Download
import org.apache.tools.ant.taskdefs.condition.Os
import org.gradle.internal.deployment.RunApplication
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm")
kotlin("plugin.serialization")
id("org.jetbrains.compose") version "1.5.11"
id("de.undercouch.download") version "5.6.0"
}
repositories {
google()
mavenCentral()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
maven("https://maven.fabricmc.net")
}
dependencies {
implementation(kotlin("reflect"))
implementation(files("deps/BrowserLauncher2-all-1_3.jar"))
implementation(compose.desktop.currentOs) {
exclude(group = "org.jetbrains.compose.material", module = "material")
}
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
implementation(compose.material3)
implementation(compose.material)
implementation(compose.materialIconsExtended)
implementation(libs.kotlinx.serialization.json)
implementation(libs.kotlinx.serialization.kaml)
implementation("io.ktor:ktor-client-core:1.6.8")
implementation("io.ktor:ktor-client-cio:1.6.8")
implementation("org.json:json:20210307")
implementation("net.fabricmc:fabric-installer:1.0.1")
implementation("edu.stanford.ejalbert:BrowserLauncher2:1.3")
implementation("net.kyori:adventure-nbt:4.18.0")
}
tasks.withType<KotlinCompile> {
kotlinOptions.freeCompilerArgs = listOf(
"-opt-in=androidx.compose.material3.ExperimentalMaterial3Api",
"-opt-in=androidx.compose.foundation.ExperimentalFoundationApi",
"-opt-in=androidx.compose.ui.ExperimentalComposeUiApi",
)
}
val appName = "MCC Launcher"
compose.desktop {
application {
mainClass = "com.noxcrew.launchy.MainKt"
nativeDistributions {
when {
Os.isFamily(Os.FAMILY_MAC) -> targetFormats(TargetFormat.Dmg)
Os.isFamily(Os.FAMILY_WINDOWS) -> targetFormats(TargetFormat.Exe)
else -> targetFormats(TargetFormat.AppImage)
}
modules("java.instrument", "jdk.unsupported")
packageName = appName
packageVersion = "${project.version}"
val iconsRoot = project.file("packaging/icons")
macOS {
iconFile.set(iconsRoot.resolve("icon.icns"))
}
windows {
menu = true
menuGroup = appName
shortcut = true
upgradeUuid = "b627d78b-947c-4f5c-9f3b-ae02bfa97d08"
iconFile.set(iconsRoot.resolve("icon.ico"))
dirChooser = false
perUserInstall = false
}
linux {
iconFile.set(iconsRoot.resolve("icon.png"))
}
}
}
}
val linuxAppDir = project.file("packaging/appimage/MccLaunchy.AppDir")
val appImageTool = project.file("deps/appimagetool.AppImage")
val composePackageDir = "$buildDir/compose/binaries/main/${
when {
Os.isFamily(Os.FAMILY_MAC) -> "dmg"
Os.isFamily(Os.FAMILY_WINDOWS) -> "exe"
else -> "app"
}
}"
tasks {
val downloadAppImageBuilder by registering(Download::class) {
src("https://github.com/AppImage/AppImageKit/releases/download/13/appimagetool-x86_64.AppImage")
dest(appImageTool)
doLast {
exec {
commandLine("chmod", "+x", "deps/appimagetool.AppImage")
}
}
}
val deleteOldAppDirFiles by registering(Delete::class) {
delete("$linuxAppDir/usr/bin", "$linuxAppDir/usr/lib")
}
val copyBuildToPackaging by registering(Copy::class) {
dependsOn("package")
dependsOn(deleteOldAppDirFiles)
from("$buildDir/compose/binaries/main/app/$appName")
into("$linuxAppDir/usr")
}
val executeAppImageBuilder by registering(Exec::class) {
dependsOn(downloadAppImageBuilder)
dependsOn(copyBuildToPackaging)
environment("ARCH", "x86_64")
commandLine(appImageTool, linuxAppDir, "releases/$appName-${project.version}.AppImage")
}
val exeRelease by registering(Copy::class) {
dependsOn("package")
from(composePackageDir)
include("*.exe")
into("releases")
}
val dmgRelease by registering(Copy::class) {
dependsOn("package")
from(composePackageDir)
include("*.dmg")
into("releases")
}
val packageForRelease by registering {
mkdir(project.file("releases"))
when {
Os.isFamily(Os.FAMILY_WINDOWS) -> dependsOn(exeRelease)
Os.isFamily(Os.FAMILY_MAC) -> dependsOn(dmgRelease)
else -> dependsOn(executeAppImageBuilder)
}
}
}
// Set the main class for the jar task
tasks.jar {
manifest.attributes["Main-Class"] = "com.noxcrew.launchy.MainKt"
}