From 613610eb147298e06b44886c9951cf3c58c7f571 Mon Sep 17 00:00:00 2001 From: Fabrice Drouin Date: Mon, 25 Mar 2024 17:52:09 +0100 Subject: [PATCH] Build a jvm application (#7) Application is build and packaged with the `application plugin`, which will create a .zip file that includes all runtime dependencies and a starter script. --------- Co-authored-by: pm47 --- README.md | 13 ++++++++++--- build.gradle.kts | 18 +++++++++++++++++- src/jvmMain/resources/logback.xml | 4 ++++ 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 src/jvmMain/resources/logback.xml diff --git a/README.md b/README.md index 4965606..ff86650 100644 --- a/README.md +++ b/README.md @@ -10,18 +10,25 @@ It is written in [Kotlin Multiplatform](https://kotlinlang.org/docs/multiplatfor ## Build -### Linux/WSL +### Native Linux/WSL + +Requires `libsqlite-dev` and `libcurl4-gnutls-dev`, both compiled against `glibc 2.19`. ```shell ./gradlew packageLinuxX64 ``` -### MacOS x64 +### Native MacOS x64 ```shell ./gradlew packageMacOSX64 ``` -### MacOS arm64 +### Native MacOS arm64 ```shell ./gradlew packageMacOSArm64 ``` + +### JVM +```shell +./gradlew distZip +``` \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 950b73a..f976c1f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,6 @@ import Versions.ktor import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetWithHostTests +import org.jetbrains.kotlin.ir.util.dumpKotlinLike import java.io.ByteArrayOutputStream buildscript { @@ -16,6 +17,7 @@ plugins { kotlin("multiplatform") version Versions.kotlin kotlin("plugin.serialization") version Versions.kotlin id("app.cash.sqldelight") version Versions.sqlDelight + application } allprojects { @@ -69,7 +71,9 @@ val buildVersionsTask by tasks.registering(Sync::class) { } kotlin { - jvm() + jvm { + withJava() + } fun KotlinNativeTargetWithHostTests.phoenixBinaries() { binaries { @@ -129,6 +133,7 @@ kotlin { dependencies { implementation("app.cash.sqldelight:sqlite-driver:${Versions.sqlDelight}") implementation(ktor("client-okhttp")) + implementation("ch.qos.logback:logback-classic:1.2.3") } } nativeMain { @@ -188,6 +193,17 @@ kotlin { } } +application { + mainClass = "fr.acinq.lightning.bin.MainKt" +} + +distributions { + main { + distributionBaseName = "phoenix" + distributionClassifier = "jvm" + } +} + // forward std input when app is run via gradle (otherwise keyboard input will return EOF) tasks.withType { standardInput = System.`in` diff --git a/src/jvmMain/resources/logback.xml b/src/jvmMain/resources/logback.xml new file mode 100644 index 0000000..c8b7060 --- /dev/null +++ b/src/jvmMain/resources/logback.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file