Skip to content

Convenient Exe Task

alessandroscarlatti edited this page May 25, 2018 · 11 revisions

You want to create a great-looking distributable exe quickly. This is now easy to set up with the Launch4jTemplateTask Gradle task.

How to Use

Pull in the dependency.

buildscript {
    repositories {
        jcenter()
        maven {
            url "https://dl.bintray.com/alessandroscarlatti/maven"
        }
    }
    dependencies {
        classpath 'com.scarlatti:launch4j-gradle-plugin:1.0.1'
    }
}

apply plugin: 'java'  // and other plugins...
apply plugin: 'com.scarlatti.launch4j.integration'

You will need the jcenter() repository in order to download the plugin dependencies.

Configure an exe build. If you are producing an executable jar via the jar task this can be as simple as

import com.scarlatti.launch4j.Launch4jTemplateTask

task basicExe(type: Launch4jTemplateTask) {
}

When you run this task you should now have an exe waiting for you in /build/launch4j/basicExe/basicExe.exe.

That's it!

Configurations

Of course, there are several properties to the task that can be configured.

Example syntax:

task communityDisributionGuiExe(type: Launch4jExeTemplateTask) {
	resourcesDir = "/release/community/gui"

        // configure the actual launch4j task
	config {
		myCustomProperty = "someCustomValue"
		dependsOn someCustomJarTask
		copyConfigurable = someCustomJarTask.outputs.files
	}
}

Properties: https://github.com/alessandroscarlatti/launch4j-gradle-plugin/blob/rewrite_syntax/docs.csv

An exe build with launch4j needs several resource files, such as an icon, splash, manifest, for example. This task will take an opinionated approach that all of these files should be in a single directory, with conventional names. However, those files should be able to be overriden by configuration of the actual launch4j task.

Property Function Notes
iconPath
splashPath
manifestPath
propertiesPath

Configurable via the above, in addition to:

resourcesDir(String resourceDir) (plus overloads)

Clone this wiki locally