Skip to content

How to create setup of desktop application using with the Gradle Application plugin

Greg Stewart edited this page Aug 14, 2019 · 1 revision

Below is a working example of how to correctly package a desktop application made using Gradle's application plugin:

// tell gradle to make a fat jar, with all dependencies wrapped up in it.
jar {
    manifest {
        attributes(
                'Main-Class': mainClassName //the main classname, same as in setupBuilder
        )
    }
    from {
        configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
    }
}

/*
 * Setup for building .deb, .dmg, .msi, and .rpm installers.
 * https://github.com/i-net-software/SetupBuilder/wiki/DSL-of-setupBuilder
 */
setupBuilder {

    vendor = '<your name>'
    appIdentifier = applicationName
    this.version = version // '0.1'

    application = "<app name>"
    description = '<app description>'
    icons = "src/main/resources/test-icon.icns"

    licenseFile = "../LICENSE"

    from jar.outputs

    mainClass = mainClassName
    mainJar = // the name of the generated jar file

    // https://github.com/i-net-software/SetupBuilder/wiki/DSL-of-desktopStarter
    desktopStarter {

        displayName   = "<name>" // the name of the program when installed

        description   = "<description>"

        // The working directory of the service, relative to installation root
        workDir        = "."
    }
}