import org.jetbrains.compose.desktop.application.dsl.TargetFormat import org.jetbrains.compose.desktop.tasks.AbstractJarsFlattenTask import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig plugins { alias(libs.plugins.kotlinMultiplatform) alias(libs.plugins.androidApplication) alias(libs.plugins.jetbrainsCompose) alias(libs.plugins.compose.compiler) alias(libs.plugins.kotlinxSerialization) } kotlin { @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { // suppresses compiler warning: [EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING] 'expect'/'actual' classes (including interfaces, objects, annotations, enums, and 'actual' typealiases) are in Beta. freeCompilerArgs.add("-Xexpect-actual-classes") } js { moduleName = "Bankmeister" browser { val projectDirPath = project.projectDir.path commonWebpackConfig { outputFileName = "Bankmeister.js" devServer = (devServer ?: KotlinWebpackConfig.DevServer()).apply { static = (static ?: mutableListOf()).apply { // Serve sources to debug inside browser add(projectDirPath) } } } } binaries.executable() useEsModules() } androidTarget { @OptIn(ExperimentalKotlinGradlePluginApi::class) compilerOptions { jvmTarget.set(JvmTarget.JVM_11) } } jvm("desktop") listOf( iosX64(), iosArm64(), iosSimulatorArm64() ).forEach { iosTarget -> iosTarget.binaries.framework { baseName = "BankmeisterFramework" isStatic = false } // don't know why but this has to be added here, adding it in BankingPersistence.build.gradle.kt does not work iosTarget.binaries.forEach { binary -> if (binary is org.jetbrains.kotlin.gradle.plugin.mpp.Framework) { binary.linkerOpts.add("-lsqlite3") // without this we get a lot of "Undefined symbol _co_touchlab_sqliter..." errors in Xcode } } } applyDefaultHierarchyTemplate() sourceSets { val desktopMain by getting commonMain.dependencies { implementation(project(":BankingPersistence")) implementation(libs.banking.client.model) implementation(libs.fints4k.banking.client) implementation(libs.epcqrcode) implementation(libs.kcsv) implementation(libs.klf) implementation(libs.kotlinx.serializable) // UI implementation(compose.runtime) implementation(compose.foundation) implementation(compose.material) implementation(compose.materialIconsExtended) implementation(compose.ui) implementation(compose.components.resources) implementation(compose.components.uiToolingPreview) implementation(libs.androidx.lifecycle.viewmodel) implementation(libs.androidx.lifecycle.runtime.compose) } commonTest.dependencies { implementation(libs.kotlin.test) implementation(libs.coroutines.test) } androidMain.dependencies { implementation(compose.preview) implementation(libs.androidx.activity.compose) implementation(libs.androidx.fragment) // to fix bug IllegalArgumentException: Can only use lower 16 bits for requestCode implementation(libs.androidx.biometric) implementation(libs.favre.bcrypt) // for reading EPC QR Codes from camera implementation(libs.zxing.core) implementation(libs.camerax.camera2) implementation(libs.camerax.view) implementation(libs.camerax.lifecycle) } iosMain.dependencies { } jvmTest.dependencies { implementation(libs.kotlin.test.junit) } desktopMain.dependencies { implementation(compose.desktop.currentOs) implementation(libs.kotlinx.coroutines.swing) implementation(libs.favre.bcrypt) implementation(libs.logback) implementation(libs.janino) } } } android { namespace = "net.codinux.banking.ui" compileSdk = libs.versions.android.compileSdk.get().toInt() sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") sourceSets["main"].res.srcDirs("src/androidMain/res") sourceSets["main"].resources.srcDirs("src/commonMain/resources") defaultConfig { applicationId = "net.codinux.banking.android" // the appId of the old Bankmeister app to be able to use the old PlayStore entry minSdk = libs.versions.android.minSdk.get().toInt() targetSdk = libs.versions.android.targetSdk.get().toInt() versionCode = 17 versionName = "1.0.0-Alpha-14" } packaging { resources { excludes += "/META-INF/{AL2.0,LGPL2.1}" } } buildTypes { named("debug") { applicationIdSuffix = ".develop" } named("release") { isMinifyEnabled = false } } compileOptions { sourceCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_11 } buildFeatures { compose = true } dependencies { debugImplementation(compose.uiTooling) } signingConfigs { named("debug") { // so that all machines have the same signing key, no matter if app is installed from developer's machine or from Jenkins storeFile = file("src/androidMain/debug-keystore.jks") storePassword = "find_my_bugs_before_releasing_me" keyAlias = "DebugKey" keyPassword = "find_my_bugs_before_releasing_me" } } } compose.desktop { application { mainClass = "net.codinux.banking.ui.MainKt" nativeDistributions { targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) modules("java.sql", "java.naming") // java.naming is required by logback packageName = "Bankmeister" packageVersion = "0.9.0" // minor version < 1 (DMG) and dashes as in '1.0.0-Alpha-14' (DMG, MSI, RPM) are not allowed description = "Datenschutzfreundliche Multi-Banking App für die meisten deutschen Banken" copyright = "© 2024 codinux GmbH & Co.KG. All rights reserved." vendor = "codinux GmbH & Co.KG" macOS { bundleID = "net.codinux.banking.ui" appCategory = "public.app-category.finance" dmgPackageVersion = "1.0.0" iconFile = project.file("../docs/res/AppIcons/distributions/AppIcon.icns") } windows { // a unique ID, which enables users to update an app via installer, when an updated version is newer, than an installed version. // The value must remain constant for a single application. See [the link](https://wixtoolset.org/documentation/manual/v3/howtos/general/generate_guids.html) for details on generating a UUID. upgradeUuid = "F62896E2-382E-4311-9683-1AB3AA4EB9E7" menu = true iconFile = project.file("../docs/res/AppIcons/distributions/AppIcon.ico") } linux { iconFile = project.file("../docs/res/AppIcons/distributions/AppIcon.png") } } buildTypes.release.proguard { isEnabled = false version = "7.4.2" } } } gradle.taskGraph.whenReady { tasks.named("flattenJars") { removeThirdPartySignaturesFromJar() } tasks.named("flattenReleaseJars") { removeThirdPartySignaturesFromJar() } } // Signatures of third party libraries get copied to output jar's META-INF folder so that java -jar refuses to run created uber jar: // Error: A JNI error has occurred, please check your installation and try again // Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes // at java.base/sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:340) // at java.base/sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:282) // at java.base/java.util.jar.JarVerifier.processEntry(JarVerifier.java:276) // // -> remove signatures of third party libraries from jar's META-INF folder fun AbstractJarsFlattenTask.removeThirdPartySignaturesFromJar() { val outputJar = (this.flattenedJar as? FileSystemLocationProperty<*>)?.asFile?.get() doLast { if (outputJar != null && outputJar.exists()) { val extractedFilesFolder = File(outputJar.parentFile, "extracted").also { it.mkdirs() } extractedFilesFolder.deleteRecursively() project.copy { // unzip jar file from(project.zipTree(outputJar)) into(extractedFilesFolder) } // Remove unwanted META-INF files (*.SF, *.DSA, *.RSA) project.fileTree(extractedFilesFolder.resolve("META-INF")).matching { include("*.SF", "*.DSA", "*.RSA") }.forEach { it.delete() // Delete the matching signature files } outputJar.delete() // Remove the original JAR // Zip the modified content back into a new JAR using Ant ant.withGroovyBuilder { "zip"( "destfile" to outputJar, "basedir" to extractedFilesFolder ) } // Clean up the temporary directory extractedFilesFolder.deleteRecursively() } } }