Construo is a gradle plugin to cross compile JVM apps.
Add the plugin to your project
Kotlin DSL
plugins {
id("io.github.fourlastor.construo") version "1.5.1"
}
Groovy DSL
plugins {
id "io.github.fourlastor.construo" version "1.5.1"
}
These are the base options to set when using construo.
construo {
// name of the executable
name.set("game")
// human-readable name, used for example in the `.app` name for macOS
humanName.set("Game")
// Optional, defaults to project version
version.set("0.0.0")
// Optional, defaults to application.mainClass or jar task main class
mainClass.set("io.github.fourlastor.gdx.Main")
// Optional, defaults to $buildDir/construo/dist
// where to put the packaged zips
outputDir.set(rootProject.file("dist"))
// Optional, an alternative jar task name to base the build upon
jarTask.set("myJarTaskName")
}
You can customize how the minimized image is generated with the jlink
block.
construo {
jlink {
// add arbitrary modules to be included when running jlink
modules.addAll("jdk.zipfs")
// guess the modules from the jar using jdeps, defaults to true
guessModulesFromJar.set(false)
// include default crypto modules, defaults to true
includeDefaultCryptoModules.set(false)
}
}
Construo uses roast to run the application, a few options can be specified and will be set in its config.json.
construo {
roast {
// use ZGC garbage collector, defaults to true
useZgc.set(false)
// use the main class as the context class loader, defaults to false, useful for compose apps
useMainAsContextClassLoader.set(true)
// vm startup options
vmArgs.addAll("-Xmx1G")
}
}
Targets define the output bundles construo will generate, each target will need to define the architecture, and a JDK url for that specific target (you cannot use a JRE for cross compilation).
Windows targets support only the X86_64 architecture.
The useGpuHint
option specifies whether the packaged app will use the discrete GPU in hybrid systems (defaults to true
).
The useConsole
option specifies whether the packaged app will print output to a terminal (defaults to false
). Note that useConsole
overrides useGpuHint
.
The identifier
option is mandatory.
An icon can be optionally specified with macOsIcon
on each target.
You can set a ProguardTask
as the jarTask
name, in that case, you will also have to set mainClass
to the main class name (see general config).
Each defined target will generate a packageXXX
task, where XXX
is the capitalized name of the target (for example: packageLinuxX64
). Running the task will produce a zip inside the outputDir
folder containing the fully packaged app.