The Distributable Task - acrimi/Raven GitHub Wiki

Launch4j provides a createExe that will build your project and produce an executable wrapper. However, the default configuration for this task doesn't ensure that module dependencies are compiled to jars first, which can lead to problems if previous build outputs are out of date or missing entirely. This can be fixed by adding a few manual dependencies for the task:

createExe.dependsOn ':Raven-core:jar'
createExe.dependsOn ':Raven-pc:jar'
createExe.dependsOn ':core:jar'

Now createExe can be used to build your project and include all of its dependencies, but it's a good idea to create a wrapper task to automate the entire build sequence (including custom tasks from previous steps) rather than using createExe directly:

// `createExe` does not clear its target directory first, so it's a good idea 
// to make sure no outdated files are being included in your new build
task cleanExe(type: Delete) {
    delete "${buildDir}/${launch4j.outputDir}"
}

task prepareDistributable {
    dependsOn 'cleanExe'
    dependsOn 'createExe'
    dependsOn 'copyAssets'
    dependsOn 'bundleJre'
    tasks.findByName('createExe').mustRunAfter 'cleanExe'
    tasks.findByName('copyAssets').mustRunAfter 'createExe'
    tasks.findByName('bundleJre').mustRunAfter 'createExe'
}

Now you can simply run the prepareDistributable task any time you want to package a new version of your game. The executable, along with all required resources, will be in the build/launch4j folder of your pc module.