What I use is launch4j, but there might be alternatives. I think you want to have .exe’s?
Because when they have a JRE, the regular assemble task would be enough, maybe with a batch/shell file.
If you are talking about random people, then here’s what I do. You need to download the jre for each platform though and place it in jre/
(I ommited the x86 versions since they are the same)
task(createx64Exe, type: edu.sc.seis.launch4j.tasks.Launch4jLibraryTask, dependsOn: ['build', 'jar', 'prepareJres']) {
mainClassName = project.mainClassName
//outputDir = "distributions/base"
outfile = project.name + "64.exe"
dontWrapJar = true
bundledJrePath = "../jre"
jreMinVersion = "1.7.0"
bundledJre64Bit = true
jreRuntimeBits = "64"
headerType = "console"
chdir = "../"
}
task(prepareReleases, dependsOn: ['jar', 'build', 'startScripts', 'createx64Exe', 'createx86Exe'], type: Task) {
doLast {
def base = "build/distributions/base";
copy {
with distributions.main.getContents()
from "other/"
into "$base"
}
// Windows x86
copy {
from "$base";
into "build/distributions/windows-x86/";
}
copy {
from "build/launch4j/" + project.name + ".exe";
into "build/distributions/windows-x86/bin";
}
copy {
from "jre/$jreVersion$jreBuild/windows-i586/prepared/";
into "build/distributions/windows-x86/jre";
}
// Windows x64
copy {
from "$base";
into "build/distributions/windows-x64/";
}
copy {
from "build/launch4j/" + project.name + "64.exe";
into "build/distributions/windows-x64/bin";
}
copy {
from "jre/$jreVersion$jreBuild/windows-x64/prepared/";
into "build/distributions/windows-x64/jre";
}
}
}
task(zipW64, dependsOn: 'prepareReleases', type: Zip) {
from "build/distributions/windows-x64/";
destinationDir file("release");
appendix "windows-x64";
}
task(release, dependsOn: ['zipW32', 'zipW64'], type: Task) {
}
What prepareReleases does: copy from base (which is the folder I put the output into (distributions.main.getContent())) into a folder per platform. Then I copy launch4j’s exe and the jre into the subfolder.
Now for Linux and Mac you would need to do the same, startScripts
will generate some .sh and .bat already which search for system wide jres (so you wouldn’t need launch4j and the jre’s if your friends have installed java).
If you’d want to bundle the jre for linux, you’d need ../jre/java -jar ../MyGame.jar
as script or something.
I am uncertain about how and if you could build a MacOs App Package though, thats a bigger topic (which is unneeded for your friends)