Add application gradle option to allow running custom Kt files

This commit is contained in:
Abe Pazos
2023-02-07 22:57:45 +01:00
committed by Edwin Jakobs
parent ff1942d2a8
commit 01d45029e6
2 changed files with 18 additions and 1 deletions

View File

@@ -10,13 +10,23 @@ If you are looking at this from IntelliJ IDEA you can start by expanding the _pr
You will find some [basic instructions](https://guide.openrndr.org/setUpYourFirstProgram.html) in the [OPENRNDR guide](https://guide.openrndr.org) You will find some [basic instructions](https://guide.openrndr.org/setUpYourFirstProgram.html) in the [OPENRNDR guide](https://guide.openrndr.org)
## Gradle tasks ## Gradle tasks
- `run` runs the TemplateProgram - `run` runs the TemplateProgram
- `jar` creates an executable platform specific jar file with all dependencies - `jar` creates an executable platform specific jar file with all dependencies
- `jpackageZip` creates a zip with a stand-alone executable for the current platform (works with Java 14 only) - `jpackageZip` creates a zip with a stand-alone executable for the current platform (works with Java 14 only)
## Cross builds ## Cross builds
To create runnable jars for a platform different from the platform you use to build one uses `./gradlew jar --PtargetPlatform=<platform>`. The supported platforms are `windows`, `macos`, `linux-x64` and `linux-arm64`. To create runnable jars for a platform different from the platform you use to build one uses `./gradlew jar --PtargetPlatform=<platform>`. The supported platforms are `windows`, `macos`, `linux-x64` and `linux-arm64`.
## Run other Kotlin programs from the command line
By default the `run` task runs the program called `TemplateProgram.kt`.
If you have other programs under your src/ folder and want
to run them from the command line use
`./gradlew -Papplication=MyProgram` to run `MyProgram.kt`.
A full package name can be specified like this: `-Papplication=foo.bar.MyProgram`.
## Github Actions ## Github Actions
This repository contains a number of Github Actions in `./github/workflows`. This repository contains a number of Github Actions in `./github/workflows`.

View File

@@ -139,6 +139,13 @@ tasks.withType<KotlinCompile> {
// ------------------------------------------------------------------------------------------------------------------ // // ------------------------------------------------------------------------------------------------------------------ //
project.setProperty("mainClassName", applicationMainClass) project.setProperty("mainClassName", applicationMainClass)
application {
if (hasProperty("application")) {
mainClass.set("${property("application")}Kt")
}
}
tasks { tasks {
named<ShadowJar>("shadowJar") { named<ShadowJar>("shadowJar") {
manifest { manifest {