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 <pm.padiou@gmail.com>
This commit is contained in:
Fabrice Drouin 2024-03-25 17:52:09 +01:00 committed by pm47
parent f3251e78e5
commit 613610eb14
No known key found for this signature in database
GPG Key ID: E434ED292E85643A
3 changed files with 31 additions and 4 deletions

View File

@ -10,18 +10,25 @@ It is written in [Kotlin Multiplatform](https://kotlinlang.org/docs/multiplatfor
## Build ## Build
### Linux/WSL ### Native Linux/WSL
Requires `libsqlite-dev` and `libcurl4-gnutls-dev`, both compiled against `glibc 2.19`.
```shell ```shell
./gradlew packageLinuxX64 ./gradlew packageLinuxX64
``` ```
### MacOS x64 ### Native MacOS x64
```shell ```shell
./gradlew packageMacOSX64 ./gradlew packageMacOSX64
``` ```
### MacOS arm64 ### Native MacOS arm64
```shell ```shell
./gradlew packageMacOSArm64 ./gradlew packageMacOSArm64
``` ```
### JVM
```shell
./gradlew distZip
```

View File

@ -1,5 +1,6 @@
import Versions.ktor import Versions.ktor
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetWithHostTests import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetWithHostTests
import org.jetbrains.kotlin.ir.util.dumpKotlinLike
import java.io.ByteArrayOutputStream import java.io.ByteArrayOutputStream
buildscript { buildscript {
@ -16,6 +17,7 @@ plugins {
kotlin("multiplatform") version Versions.kotlin kotlin("multiplatform") version Versions.kotlin
kotlin("plugin.serialization") version Versions.kotlin kotlin("plugin.serialization") version Versions.kotlin
id("app.cash.sqldelight") version Versions.sqlDelight id("app.cash.sqldelight") version Versions.sqlDelight
application
} }
allprojects { allprojects {
@ -69,7 +71,9 @@ val buildVersionsTask by tasks.registering(Sync::class) {
} }
kotlin { kotlin {
jvm() jvm {
withJava()
}
fun KotlinNativeTargetWithHostTests.phoenixBinaries() { fun KotlinNativeTargetWithHostTests.phoenixBinaries() {
binaries { binaries {
@ -129,6 +133,7 @@ kotlin {
dependencies { dependencies {
implementation("app.cash.sqldelight:sqlite-driver:${Versions.sqlDelight}") implementation("app.cash.sqldelight:sqlite-driver:${Versions.sqlDelight}")
implementation(ktor("client-okhttp")) implementation(ktor("client-okhttp"))
implementation("ch.qos.logback:logback-classic:1.2.3")
} }
} }
nativeMain { 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) // forward std input when app is run via gradle (otherwise keyboard input will return EOF)
tasks.withType<JavaExec> { tasks.withType<JavaExec> {
standardInput = System.`in` standardInput = System.`in`

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<root level="OFF" />
</configuration>