Sam Garfinkel
07/04/2021, 4:48 PMRuckus
07/04/2021, 4:50 PMSam Garfinkel
07/04/2021, 4:55 PMAdam Powell
07/04/2021, 5:30 PMBig Chungus
07/04/2021, 7:43 PMColton Idle
07/05/2021, 2:13 AMCLOVIS
07/05/2021, 8:31 AMCLOVIS
07/05/2021, 8:34 AMStephan Schroeder
07/05/2021, 9:58 AMtasks {
register("buildInstaller") {
dependsOn("build")
doLast {
if (JavaVersion.current() < JavaVersion.VERSION_16) {
throw GradleException("Require JDK 16+ to run 'jpackage' (currently ${JavaVersion.current()})")
}
println("""
these packaging tools have to be installed because they are required by jpackage:
- on Red Hat Linux: the rpm-build package
- on Ubuntu Linux: the fakeroot package
- on macOS: Xcode command line tools
- on Windows: WiX 3.0 or later
""".trimIndent())
val projectVersion = project.version.toString()
JPackage.buildInstaller(
name = "VoidChess",
description = "a chess program",
appVersion = projectVersion,
inputDir = "build/libs",
destinationDir = "build/installer",
mainJar = "voidchess-$projectVersion-all.jar",
addModules = listOf("java.desktop"),
winIcoIconPath = "about/shortcut-icon2.ico",
winShortcut = true,
winMenu = true,
linuxPngIconPath = "about/shortcut-icon2.png",
linuxShortcut = true,
linuxMenuGroup = "Games",
macIcnsIconPath = "about/shortcut-icon2.icns"
)
}
}
}
(notice the addModules
entry to create bundle a minimal jre with your app. An entry point to googling more about this is looking for jlink
).
JPackage.buildInstaller
is defined in the buildSrc: https://github.com/simon-void/voidchess/blob/master/buildSrc/src/main/kotlin/JPackage.kt
Notice that this doesn't support cross-platform, so you need e.g. a windows-client to build a windows-version, but you're CI-setup (e.g. GitHub Actions) should already support selecting the OS of your build-machine.Sam Garfinkel
07/05/2021, 6:57 PMStephan Schroeder
08/30/2021, 7:16 AMplugins {
kotlin("jvm") version "1.5.21"
}
group = "com.example"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_8
repositories {
mavenCentral()
}
and do a ./gradlew clean build
and check the build/libs folder.CLOVIS
08/30/2021, 11:36 AMapplication
plugin, but even then it generates a ZIP, not a uber jar. shadowJar
can generate a uber jar that contains all dependencies, and can be ran with java -jar <…>.jar
Stephan Schroeder
08/30/2021, 11:43 AMshadowJar
you'll have to add this to this plugin section
id("com.github.johnrengelman.shadow") version "7.0.0"
here's the link to that plugin's page: https://plugins.gradle.org/plugin/com.github.johnrengelman.shadow