https://kotlinlang.org logo
Title
s

Shabinder Singh

03/18/2021, 1:22 AM
I am not able to build Distributable Packages..... Error: --module-path is not specified and this runtime image does not contain jmods directory. Usage: jlink <options> --module-path <modulepath> --add-modules <module>[,<module>...] Use --help for a list of possible options Commands Tried:
./gradlew :desktop:packageDeb
./gradlew :desktop:runDistributable
./gradlew :desktop:createDistributable
Running Locally using
./gradlew :desktop:run
works fine!
g

gildor

03/18/2021, 1:36 AM
Which version of JVM do you use?
s

Shabinder Singh

03/18/2021, 9:08 AM
@gildor 11
g

gildor

03/18/2021, 9:09 AM
I believe you need at least 14
☝️ 1
s

Shabinder Singh

03/18/2021, 9:10 AM
I thought 11 was least , however will try with 14 , however run works fin in 11 just packaging fails because of
jmods directory
........... Will try on 14 and report back
g

gildor

03/18/2021, 9:11 AM
run doesn’t build image, it just assemble standard jar and run it on your jvm
It also mentioned in docs:
run is used to run an app locally. You need to define a mainClass — an fq-name of a class, containing the main function. Note, that run starts a non-packaged JVM application with full runtime. This is faster and easier to debug, than creating a compact binary image with minified runtime. To run a final binary image, use runDistributable instead.
It uses jpackage, which is available only from Java 14 https://openjdk.java.net/jeps/343
s

Shabinder Singh

03/18/2021, 9:15 AM
@gildor thanks
d

Dirk Hoffmann

03/18/2021, 9:29 AM
I also noticed that on Mac OS Version is not allowed to start with a 0. (maybe also worth mentioning in the docs!)
s

Shabinder Singh

03/18/2021, 11:29 AM
@gildor tried with java 15 , still same error
d

Dirk Hoffmann

03/18/2021, 11:30 AM
here's my gradle on mac snippet (also beware to have version not starting with zero, as I mentioned:
compose.desktop {
    application {
        mainClass = theMainClass
        nativeDistributions {
            targetFormats(
                org.jetbrains.compose.desktop.application.dsl.TargetFormat.Dmg,
                org.jetbrains.compose.desktop.application.dsl.TargetFormat.Msi,
                org.jetbrains.compose.desktop.application.dsl.TargetFormat.Deb)
            packageName = "AccordDeskFrontend"
            version = "${rootProject.version}" // "${rootProject.version}" // must not start with '0'
            description = "NdaDesk by AccordDesk"
            copyright = "© 2021 AccordDesk. All rights reserved."
            vendor = "Dirk Hoffmann"

            macOS {
                bundleID = "com.accorddesk.AccordDeskFrontend"
            }
        }
    }
}
s

Shabinder Singh

03/18/2021, 12:15 PM
mine is quite simple and close to Intellij Starter template , not much modification while producing packages:
import org.jetbrains.compose.compose
import org.jetbrains.compose.desktop.application.dsl.TargetFormat

plugins {
    kotlin("multiplatform")
    id("org.jetbrains.compose")
}

group = "com.shabinder"
version = Versions.versionName

kotlin {
    jvm {
        compilations.all {
            kotlinOptions.jvmTarget = "14"
        }
    }
    sourceSets {
        val jvmMain by getting {
            dependencies {
                implementation(compose.desktop.currentOs)
                implementation(project(":common:database"))
                implementation(project(":common:dependency-injection"))
                implementation(project(":common:compose"))
                implementation(project(":common:root"))
                implementation(Decompose.decompose)
                implementation(Decompose.extensionsCompose)
                implementation(MVIKotlin.mvikotlin)
                implementation(MVIKotlin.mvikotlinMain)
            }
        }
        val jvmTest by getting
    }
}

compose.desktop {
    application {
        mainClass = "MainKt"
        description = "Music Downloader for Spotify, Gaana, Youtube Music."
        nativeDistributions {
            targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
            packageName = "SpotiFlyer"
        }
    }
}
d

Dirk Hoffmann

03/18/2021, 12:45 PM
nativeDistributions might need a
packageVersion = "1.0.0"
(needs it on Mac, not sure about msi and deb) on mac also a
macOS {
        bundleID = "my.group"
    }