-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
269 lines (237 loc) · 10 KB
/
build.gradle.kts
File metadata and controls
269 lines (237 loc) · 10 KB
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import com.mikepenz.aboutlibraries.plugin.DuplicateMode
import com.mikepenz.aboutlibraries.plugin.DuplicateRule
plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.compose)
alias(libs.plugins.about.libraries)
// Shadow plugin is provided by buildSrc to enable the custom NoticeMergeTransformer.
// Applied without a version here; the version is pinned in buildSrc/build.gradle.kts.
id("com.gradleup.shadow")
application
`maven-publish`
signing
}
group = "app.morphe"
// ============================================================================
// JVM / Kotlin Configuration
// ============================================================================
kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(17))
vendor.set(JvmVendorSpec.JETBRAINS)
}
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
}
// ============================================================================
// Application Entry Point
// ============================================================================
// Shadow JAR reads this for Main-Class manifest attribute.
//
// No args / double-click → GUI (Compose Desktop)
// With args (terminal) → CLI (PicoCLI)
application {
mainClass.set("app.morphe.MorpheLauncherKt")
}
// ============================================================================
// Repositories
// ============================================================================
repositories {
mavenLocal()
mavenCentral()
google()
maven {
// A repository must be specified for some reason. "registry" is a dummy.
url = uri("https://maven.pkg.github.com/MorpheApp/registry")
credentials {
username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_ACTOR")
password = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN")
}
}
// Obtain baksmali/smali from source builds - https://github.com/iBotPeaches/smali
// Remove when official smali releases come out again.
maven { url = uri("https://jitpack.io") }
}
dependencies {
api(libs.morphe.patcher)
implementation(libs.arsclib)
implementation(libs.morphe.library)
implementation(libs.picocli)
// -- Compose Desktop ---------------------------------------------------
// Platform-independent: single JAR runs on all supported OSes.
// Skiko auto-detects the OS at runtime and loads the correct native library.
implementation(compose.desktop.macos_arm64)
implementation(compose.desktop.macos_x64)
implementation(compose.desktop.linux_x64)
implementation(compose.desktop.linux_arm64)
implementation(compose.desktop.windows_x64)
implementation(compose.components.resources)
@Suppress("DEPRECATION")
implementation(compose.material3)
implementation(compose.materialIconsExtended)
// -- Async / Serialization ---------------------------------------------
implementation(libs.kotlinx.coroutines.core)
implementation(libs.kotlinx.coroutines.swing)
implementation(libs.kotlinx.serialization.json)
// testImplementation(libs.kotlin.test)
//}
// -- Networking (GUI) --------------------------------------------------
implementation(libs.ktor.client.core)
implementation(libs.ktor.client.cio)
implementation(libs.ktor.client.content.negotiation)
implementation(libs.ktor.serialization.kotlinx.json)
implementation(libs.ktor.client.logging)
// -- DI / Navigation (GUI) ---------------------------------------------
implementation(platform(libs.koin.bom))
implementation(libs.koin.core)
implementation(libs.koin.compose)
implementation(libs.voyager.navigator)
implementation(libs.voyager.screenmodel)
implementation(libs.voyager.koin)
implementation(libs.voyager.transitions)
// -- JNA (Windows DWM title bar tinting) -------------------------------
implementation(libs.jna)
implementation(libs.jna.platform)
// -- APK Parsing (GUI) -------------------------------------------------
implementation(libs.apk.parser)
implementation(libs.about.libraries.core)
implementation(libs.about.libraries.m3)
// -- Testing -----------------------------------------------------------
testImplementation(libs.kotlin.test)
testImplementation(libs.junit.params)
testImplementation(libs.mockk)
}
aboutLibraries {
collect {
configPath = file("aboutlibraries")
}
library {
duplicationMode = DuplicateMode.MERGE
duplicationRule = DuplicateRule.EXACT
}
}
// ============================================================================
// Tasks
// ============================================================================
tasks {
jar {
manifest {
attributes(
"Implementation-Title" to project.name,
"Implementation-Version" to project.version
)
}
}
test {
useJUnitPlatform()
testLogging {
events("PASSED", "SKIPPED", "FAILED")
}
}
processResources {
// Make sure the licenses are generated before the resources are processed
dependsOn("exportLibraryDefinitions")
from(layout.buildDirectory.file("generated/aboutLibraries/aboutlibraries.json"))
// Only expand properties files, not binary files like PNG/ICO
filesMatching("**/*.properties") {
expand("projectVersion" to project.version)
}
// Bundle the project's NOTICE (GPL 7b/7c) and LICENSE into META-INF so they
// land in the main JAR before the Shadow merge. Source of truth stays at the
// repo root — these are copied at build time, not duplicated in source control.
from(arrayOf(rootProject.file("NOTICE"), rootProject.file("LICENSE"))) {
into("META-INF")
}
}
// -------------------------------------------------------------------------
// Shadow JAR — the only distribution artifact
// -------------------------------------------------------------------------
shadowJar {
exclude(
"/prebuilt/linux/aapt",
"/prebuilt/windows/aapt.exe",
"/prebuilt/*/aapt_*",
)
// NOTICE/LICENSE handling:
// * Global strategy is EXCLUDE (first-wins) so duplicates at non-transformed
// paths — including native libs like libskiko-*.dylib — are deduplicated.
// INCLUDE globally would double-pack every colliding resource and bloat the
// JAR by tens of MB.
// * For META-INF/NOTICE* paths specifically, strategy is flipped to INCLUDE
// via filesMatching below so all dep NOTICEs reach NoticeMergeTransformer
// (Shadow drops duplicates before transformers run under EXCLUDE — see
// ShadowJar.kt Kdoc).
// * Root /NOTICE and /LICENSE — our project's files, added below via from().
// With EXCLUDE, the first occurrence wins. Dep JARs with root-level NOTICE/
// LICENSE lose because our from() block is declared before Shadow processes
// dependency configurations.
// * META-INF/LICENSE — our GPL LICENSE, placed via processResources so it
// lands in the main JAR ahead of dep copies. Dep LICENSE files at unique
// paths (META-INF/androidx/**/LICENSE.txt, etc.) are preserved untouched.
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
filesMatching(listOf(
"META-INF/NOTICE",
"META-INF/NOTICE.txt",
"META-INF/NOTICE.md",
)) {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
from(rootProject.file("NOTICE"), rootProject.file("LICENSE"))
minimize {
exclude(dependency("org.bouncycastle:.*"))
exclude(dependency("com.github.REAndroid:ARSCLib"))
exclude(dependency("app.morphe:morphe-patcher"))
// Ktor uses ServiceLoader
exclude(dependency("io.ktor:.*"))
// Koin uses reflection
exclude(dependency("io.insert-koin:.*"))
// Coroutines Swing provides Dispatchers.Main via ServiceLoader
exclude(dependency("org.jetbrains.kotlinx:kotlinx-coroutines-swing"))
// JNA uses reflection + native loading for DWM title bar tinting
exclude(dependency("net.java.dev.jna:.*"))
}
mergeServiceFiles()
// Concatenate every META-INF/NOTICE (and .txt/.md variants) from all dep JARs
// plus our own into a single merged file. Satisfies Apache 2.0 §4(d) which
// requires preserving attribution NOTICEs of Apache-licensed dependencies.
//
// Shadow's built-in ApacheNoticeResourceTransformer hardcodes ASF-branded
// copyright text that cannot be fully disabled, which would falsely attribute
// this GPL project to the Apache Software Foundation. NoticeMergeTransformer
// (in buildSrc) is a minimal verbatim concatenator with no boilerplate.
transform(NoticeMergeTransformer::class.java)
}
distTar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
distZip {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
publish {
dependsOn(shadowJar)
}
}
// ============================================================================
// Publishing / Signing
// ============================================================================
// Needed by gradle-semantic-release-plugin.
// Tracking: https://github.com/KengoTODA/gradle-semantic-release-plugin/issues/435
// The maven-publish is also necessary to make the signing plugin work.
publishing {
repositories {
mavenLocal()
}
publications {
create<MavenPublication>("morphe-cli-publication") {
from(components["java"])
}
}
}
signing {
useGpgCmd()
sign(publishing.publications["morphe-cli-publication"])
}