executable-jarjavafxportsgluongluon-desktop

Gluon build as single Jar


I'd like to build my Gluon Project as a SINGLE executable jar file.

Currently there is a startup script included with a bin folder and so on.

Is it possible to build a single jar? Or can I include an own gradle task that accomplishes this?


Solution

  • Since I had to build the jar with javapackager I used this plugin: javafx-gradle-plugin

    I am relatively new to Gradle so adding the dependencies is just a temporary solution but it works

    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'org.javafxports:jfxmobile-plugin:1.0.8'
            classpath group: 'de.dynamicfiles.projects.gradle.plugins', name: 'javafx-gradle-plugin', version: '8.4.1'
        }
    }
    
    jfx {
        verbose = true
        mainClass = "package.path.to.main.class.MainClass"
        jfxAppOutputDir = "build/jfx/app" //configurable
        jfxMainAppJarName = "ProjectName.jar"
        deployDir = "src/main/deploy" //for signing
    
        //many more options, go to link to learn about them
    }
    
    
    jfxJar.doFirst {
        //TODO add all desktop dependencies
        println("adding desktop dependency")
        project.dependencies.add("runtime", "com.gluonhq:charm-desktop:2.1.0")
    }