Skip to content

Commit

Permalink
Improve task api and update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
chippmann committed Nov 3, 2024
1 parent b5d2f6a commit 3b3a2b2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
20 changes: 20 additions & 0 deletions docs/src/doc/user-guide/exporting.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,26 @@ by using `jlink` with rosetta and an amd64 JDK on an arm64 MacOS.
For desktop exports you need to make exports based on the platform you're on, as exporting will copy the generated jre folder to
your export. An MacOS JRE will not work on Windows, so you'll need a Windows host to export for Windows.
Alternatively we provide a configurable gradle task which generates the JRE for your current host OS:
`./gradlew generateEmbeddedJre`
The task can be configured like so:
```kotlin
tasks.withType<GenerateEmbeddedJreTask> {
// the values in this example are the default values of the task
this.javaHome = System.getProperty("java.home") // path to your java home dir
this.arguments = arrayOf(
"--strip-debug",
"--no-header-files",
"--no-man-pages",
) // arguments to pass to the jlink command
this.modules = arrayOf(
"java.base",
"java.logging",
) // java module to include in the jre
}
```
## Specifics
`godot-bootstrap.jar` and `main.jar` are copied into `pck` during the export process.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import java.util.*
open class GenerateEmbeddedJreTask : DefaultTask() {

@Input
var modules: String = "java.base,java.logging"
var modules: Array<String> = arrayOf(
"java.base",
"java.logging",
)

@Input
var outputDir: String = "jvm/jre-${getArch()}-${getOs()}"
Expand All @@ -30,13 +33,13 @@ open class GenerateEmbeddedJreTask : DefaultTask() {
project.exec {
it.commandLine(
"$javaHome/bin/jlink",
"--add-modules", modules,
"--add-modules", modules.joinToString(","),
"--output", outputDir,
*arguments,
)
}

logger.lifecycle("Custom JRE created in $outputDir using modules: '$modules', arguments: '${arguments.joinToString(" ")}' and java home: $javaHome")
logger.lifecycle("Custom JRE created in $outputDir using modules: '${modules.joinToString(",")}', arguments: '${arguments.joinToString(" ")}' and java home: $javaHome")
}

private fun getArch(): String {
Expand Down

0 comments on commit 3b3a2b2

Please sign in to comment.