Compare commits

..

3 Commits

Author SHA1 Message Date
Edwin Jakobs
e35d629a5a Upgrade to Gradle 8.7. Target JDK 17 2024-05-30 10:37:04 +02:00
Edwin Jakobs
577e0c2f9a Update to Kotlin 2.0.0 2024-05-28 15:47:41 +02:00
Edwin Jakobs
3350274efb Obscure configuration logic by using a buildSrc plugin 2024-03-14 10:45:51 +01:00
21 changed files with 394 additions and 385 deletions

View File

@@ -3,14 +3,13 @@ on:
push: push:
branches: branches:
- master - master
- next-version
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- uses: actions/setup-java@v4 - uses: actions/setup-java@v3
with: with:
distribution: 'temurin' distribution: 'temurin'
java-version: '17' java-version: '17'

View File

@@ -23,10 +23,10 @@ jobs:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- name: Set up JDK 17 - name: Set up JDK 17
uses: actions/setup-java@v4 uses: actions/setup-java@v3
with: with:
distribution: 'temurin' distribution: 'temurin'
java-version: '17' java-version: '17'
@@ -48,7 +48,7 @@ jobs:
run: mv ./build/distributions/openrndr-application.zip ./build/distributions/openrndr-application-${{env.OR_TARGET_NAME}}.zip run: mv ./build/distributions/openrndr-application.zip ./build/distributions/openrndr-application-${{env.OR_TARGET_NAME}}.zip
- name: Create Release - name: Create Release
uses: ncipollo/release-action@v1.14.0 uses: ncipollo/release-action@v1.12.0
id: create_release id: create_release
with: with:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}

2
.gitignore vendored
View File

@@ -3,8 +3,6 @@ build
out out
.idea .idea
.gradle .gradle
.kotlin
.lwjgl
video/ video/
screenshots/ screenshots/
gui-parameters/ gui-parameters/

View File

@@ -7,67 +7,62 @@ go-to starting point for writing OPENRNDR-based software.
If you are looking at this from IntelliJ IDEA you can start by expanding the _project_ tab on the left. You will find a template program in `src/main/kotlin/TemplateProgram.kt` and a live-coding example in `src/main/kotlin/TemplateLiveProgram.kt`. If you are looking at this from IntelliJ IDEA you can start by expanding the _project_ tab on the left. You will find a template program in `src/main/kotlin/TemplateProgram.kt` and a live-coding example in `src/main/kotlin/TemplateLiveProgram.kt`.
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
- `./gradlew run` runs `TemplateProgram.kt` (Use `gradlew.bat run` under Windows) - `./gradlew run` runs the TemplateProgram (Use `gradlew.bat run` under Windows)
- `./gradlew run -Popenrndr.application=MyProgramKt` runs `src/main/kotlin/myProgram.kt` - `./gradlew shadowJar` creates an executable platform specific jar file with all dependencies. Run the resulting program by typing `java -jar build/libs/openrndr-template-1.0.0-all.jar` in a terminal from the project root.
- `./gradlew run -Popenrndr.application=foo.bar.MyProgramKt` runs `src/main/kotlin/foo/bar/myProgram.kt` (assuming `package foo.bar` is used in myProgram.kt) - `./gradlew jpackageZip` creates a zip with a stand-alone executable for the current platform (works with Java 14 only)
- `./gradlew shadowJar` creates an executable platform specific jar file with all dependencies. Run the resulting program by typing `java -jar build/libs/openrndr-template-1.0.0-all.jar` in a terminal from the project root. If your project contains multiple `main` methods, specify which one to run with `java -cp build/libs/openrndr-template-1.0.0-all.jar MyProgramKt`, where `MyProgramKt` can also be `foo.bar.MyProgramKt` if it's in the package `foo.bar`.
- `./gradlew jpackageZip` creates a zip with a stand-alone executable for the current platform (requires Java 17 or newer). Run it like this: `cd build/jpackage/openrndr-application/ && bin/openrndr-application`.
- `./gradlew dependencyUpydates` checks whether any dependencies have newer versions.
## Tips and issues
See the [wiki](https://github.com/openrndr/openrndr-template/wiki)
## Cross builds ## Cross builds
See the [wiki](https://github.com/openrndr/openrndr-template/wiki) To create a runnable jar for a platform different from your current platform, use `./gradlew jar -PtargetPlatform=<platform>`, where `<platform>` is either `windows`, `macos`, `linux-x64`, or `linux-arm64`.
## Updating OPENRNDR, ORX and other dependencies ## Updating OPENRNDR, ORX and other dependencies
The openrndr-template depends on various packages including the core [openrndr](https://github.com/openrndr/openrndr/) and the [orx](https://github.com/openrndr/orx/) extensions and The openrndr-template depends on various packages including the core [openrndr](https://github.com/openrndr/openrndr/) and the [orx](https://github.com/openrndr/orx/) extensions. The version numbers of these dependencies are specified in your [libs.versions.toml](gradle/libs.versions.toml) file. If you want to learn about file format visit the [Gradle documentation](https://docs.gradle.org/current/userguide/platforms.html#sub:conventional-dependencies-toml) website.
provides the optional [orsl](https://github.com/openrndr/orsl/) shader helper modules.
The version numbers of these dependencies are specified in your [libs.versions.toml](gradle/libs.versions.toml) file.
Learn more about this file in the [Gradle documentation](https://docs.gradle.org/current/userguide/platforms.html#sub:conventional-dependencies-toml) website.
Newer versions bring useful features and bug fixes. The most recent versions are<br> Newer versions of OPENRNDR and ORX bring useful features and bug fixes. The most recent versions are
![Maven Central Version](https://img.shields.io/maven-central/v/org.openrndr/openrndr-math-jvm?label=OPENRNDR&color=%23FFC0CB) <br>![openrndr version](https://maven-badges.herokuapp.com/maven-central/org.openrndr/openrndr-application/badge.svg) for OPENRNDR.
![Maven Central Version](https://img.shields.io/maven-central/v/org.openrndr.extra/orx-noise-jvm?label=ORX&color=%23FFC0CB) <br>![orx version](https://maven-badges.herokuapp.com/maven-central/org.openrndr.extra/orx-parameters-jvm/badge.svg) for ORX.
![Maven Central Version](https://img.shields.io/maven-central/v/org.openrndr.orsl/orsl-shader-generator-jvm?label=ORSL&color=%23FFC0CB).
Switch to the [next-version branch](https://github.com/openrndr/openrndr-template/tree/next-version) or enter these versions manually in your toml file. Switch to the [next-version branch](https://github.com/openrndr/openrndr-template/tree/next-version) or enter these version numbers in your toml file. They can look like "0.4.3" or "0.4.3-alpha4". Use the complete string, as in:
They can look like "0.4.3" or "0.4.3-alpha4". Use the complete string, as in:
openrndr = "0.4.5-alpha5" openrndr = "0.4.3-alpha4"
orx = "0.4.5-alpha5" orx = "0.4.3-alpha4"
orsl = "0.4.5-alpha5"
You can add other dependencies needed by your project to your [build.gradle.kts](build.gradle.kts) file, inside the `dependencies { }` block. You can add other dependencies needed by your project to your [build.gradle.kts](build.gradle.kts) file, inside the `dependencies { }` block.
⚠️ Remember to reload the Gradle configuration after changing any dependencies. Remember to reload the Gradle configuration after changing any dependencies.
## Run other Kotlin programs from the command line
By default `./gradlew run` runs a program called `TemplateProgram.kt` but a different one can be provided as an argument:
To run `src/main/kotlin/myProgram.kt`
./gradlew run -Popenrndr.application=MyProgramKt
To run `src/main/kotlin/foo/bar/myProgram.kt` (assuming `package foo.bar` in myProgram.kt)
./gradlew run -Popenrndr.application=foo.bar.MyProgramKt
## Github Actions ## Github Actions
This repository contains various Github Actions under `./github/workflows`: This repository contains a number of Github Actions under `./github/workflows`.
- [build-on-commit.yaml](.github/workflows/build-on-commit.yaml) runs a basic build on every commit, [build-on-commit.yaml](.github/workflows/build-on-commit.yaml) runs a basic build on every commit,
which can help detect issues in the source code. which can help detect issues in the source code.
- [publish-binaries.yaml](.github/workflows/publish-binaries.yaml) publishes binaries for Linux, Mac and Windows [publish-binaries.yaml](.github/workflows/publish-binaries.yaml) publishes binaries for Linux, Mac and Windows
any time a commit is tagged with a version number like `v1.*`. For example, we can create and push a tag with these git commands: any time a commit is tagged with a version number like `v1.*`.
```
For example, we can create and push a tag with these git commands:
git tag -a v1.0.0 -m "v1.0.0" git tag -a v1.0.0 -m "v1.0.0"
git push origin v1.0.0 git push origin v1.0.0
```
You can follow the progress of the action under the Actions tab in GitHub. Once complete, the executables will appear under the Releases section. The progress of the running actions can be followed under the Actions tab in GitHub.
Once complete, the executables will be found under the Releases section.
## Building libraries
This template can be used to create a library with your classes and extensions and reuse them across projects or share them with other people.
To publish the project as a library, open [build.gradle.kts](build.gradle.kts) and replace the `conventions.distribute-application` plugin with `conventions.publish-library`.
This automatically sets up the `maven-publish` plugin, which adds the `publishToMavenLocal` task.
The plugin also adds a `demo` sourceSet with runtime dependencies set to go. Demos can be placed in `src/demo/kotlin` and started right away.

View File

@@ -1,31 +1,28 @@
group = property("project.group") ?: error("project.group not set") group = "org.openrndr.template"
version = property("project.version") ?: error("project.version not set") version = "1.0.0"
plugins { plugins {
alias(libs.plugins.kotlin.serialization) openrndr
id("conventions.kotlin-jvm") }
id("conventions.openrndr-tasks")
id("conventions.distribute-application") openrndr {
openrndrVersion = libs.versions.openrndr.get()
orxVersion = libs.versions.orx.get()
orxFeatures = setOf(
libs.orx.olive,
libs.orx.color,
libs.orx.shapes,
libs.orx.gui,
libs.orx.svg
)
openrndrFeatures = setOf(
libs.openrndr.ffmpeg,
libs.openrndr.gl3
)
mainClass = "TemplateProgramKt"
} }
dependencies { dependencies {
implementation(openrndr.application) implementation(libs.csv)
implementation(openrndr.draw) }
runtimeOnly(openrndr.gl3)
implementation(openrndr.dialogs)
implementation(openrndr.orextensions)
implementation(openrndr.ffmpeg)
implementation(orx.bundles.basic)
implementation(orx.olive)
implementation(libs.kotlinx.coroutines.core)
implementation(libs.kotlinx.serialization.core)
implementation(libs.kotlinx.serialization.json)
implementation(libs.slf4j.api)
implementation(libs.kotlin.logging)
runtimeOnly(libs.bundles.logging.simple)
testImplementation(libs.junit)
}

View File

@@ -2,11 +2,28 @@ plugins {
`kotlin-dsl` `kotlin-dsl`
} }
val libs = extensions.getByType<VersionCatalogsExtension>().named("libs") repositories {
mavenCentral()
mavenLocal()
gradlePluginPortal()
}
dependencies { dependencies {
implementation(libs.findLibrary("shadow-gradle-plugin").get()) implementation(libs.kotlin.gradle.plugin)
implementation(libs.findLibrary("runtime-gradle-plugin").get())
implementation(libs.findLibrary("kotlin-gradle-plugin").get()) implementation(libs.shadow.gradle.plugin)
implementation(libs.findLibrary("xversions-gradle-plugin").get()) implementation(libs.runtime.gradle.plugin)
}
//implementation(libs.kotlin.serialization.gradle.plugin)
// https://github.com/gradle/gradle/issues/15383#issuecomment-779893192
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
}
gradlePlugin {
plugins {
register("openrndr-plugin") {
id = "openrndr"
implementationClass = "org.openrndr.template.OpenrndrPlugin"
}
}
}

View File

@@ -1,39 +1,7 @@
rootProject.name = "buildSrc"
dependencyResolutionManagement { dependencyResolutionManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenLocal {
content {
includeGroup("org.openrndr")
includeGroup("org.openrndr.extra")
}
}
}
versionCatalogs { versionCatalogs {
create("libs") { create("libs") {
from(files("../gradle/libs.versions.toml")) from(files("../gradle/libs.versions.toml"))
} }
// We use a regex to get the openrndr/orx versions from the primary catalog as there is no public Gradle API to parse catalogs.
val orRegEx = Regex("^openrndr[ ]*=[ ]*(?:\\{[ ]*require[ ]*=[ ]*)?\"(.*)\"[ ]*(?:\\})?", RegexOption.MULTILINE)
val orxRegEx = Regex("^orx[ ]*=[ ]*(?:\\{[ ]*require[ ]*=[ ]*)?\"(.*)\"[ ]*(?:\\})?", RegexOption.MULTILINE)
val openrndrVersion = orRegEx.find(File(rootDir,"../gradle/libs.versions.toml").readText())?.groupValues?.get(1) ?: error("can't find openrndr version")
val orxVersion = orxRegEx.find(File(rootDir,"../gradle/libs.versions.toml").readText())?.groupValues?.get(1) ?: error("can't find orx version")
create("orx") {
from("org.openrndr.extra:orx-module-catalog:$orxVersion")
}
create("openrndr") {
from("org.openrndr:openrndr-module-catalog:$openrndrVersion")
}
} }
} }
pluginManagement {
repositories {
gradlePluginPortal()
}
}

View File

@@ -1,71 +0,0 @@
package conventions
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
val libs = extensions.getByType<VersionCatalogsExtension>().named("libs")
plugins {
java
kotlin("jvm")
id("com.github.ben-manes.versions")
}
repositories {
mavenCentral()
mavenLocal()
}
java {
targetCompatibility = JavaVersion.valueOf("VERSION_${libs.findVersion("jvmTarget").get().displayName}")
sourceCompatibility = JavaVersion.valueOf("VERSION_${libs.findVersion("jvmTarget").get().displayName}")
}
kotlin {
compilerOptions {
apiVersion.set(KotlinVersion.valueOf("KOTLIN_${libs.findVersion("kotlinApi").get().displayName.replace(".", "_")}"))
languageVersion.set(KotlinVersion.valueOf("KOTLIN_${libs.findVersion("kotlinLanguage").get().displayName.replace(".", "_")}"))
jvmTarget.set(JvmTarget.valueOf("JVM_${libs.findVersion("jvmTarget").get().displayName}"))
}
}
fun arch(arch: String = System.getProperty("os.arch")): String {
return when (arch) {
"x86-64", "x86_64", "amd64" -> "x86-64"
"arm64", "aarch64" -> "aarch64"
else -> error("unsupported arch $arch")
}
}
fun Project.addHostMachineAttributesToRuntimeConfigurations() {
val currentOperatingSystemName: String = DefaultNativePlatform.getCurrentOperatingSystem().toFamilyName()
val currentArchitectureName: String = arch()
configurations.matching {
it.name.endsWith("runtimeClasspath", ignoreCase = true)
}.configureEach {
attributes {
attribute(OperatingSystemFamily.OPERATING_SYSTEM_ATTRIBUTE, objects.named(currentOperatingSystemName))
attribute(MachineArchitecture.ARCHITECTURE_ATTRIBUTE, objects.named(currentArchitectureName))
}
}
}
addHostMachineAttributesToRuntimeConfigurations()
tasks {
dependencyUpdates {
gradleReleaseChannel = "current"
val nonStableKeywords = listOf("alpha", "beta", "rc")
fun isNonStable(version: String) = nonStableKeywords.any {
version.lowercase().contains(it)
}
rejectVersionIf {
isNonStable(candidate.version) && !isNonStable(currentVersion)
}
}
}

View File

@@ -1,42 +0,0 @@
package conventions
val applicationMainClass by properties
tasks.register("create executable jar for $applicationMainClass") {
group = " \uD83E\uDD8C OPENRNDR"
dependsOn("shadowJar")
}
tasks.register("run $applicationMainClass") {
group = " \uD83E\uDD8C OPENRNDR"
dependsOn("run")
}
tasks.register("create standalone executable for $applicationMainClass") {
group = " \uD83E\uDD8C OPENRNDR"
dependsOn("jpackageZip")
}
tasks.register("add IDE file scopes") {
group = " \uD83E\uDD8C OPENRNDR"
val scopesFolder = File("${project.projectDir}/.idea/scopes")
scopesFolder.mkdirs()
val files = listOf(
"Code" to "file:*.kt||file:*.frag||file:*.vert||file:*.glsl",
"Text" to "file:*.txt||file:*.md||file:*.xml||file:*.json",
"Gradle" to "file[*buildSrc*]:*/||file:*gradle.*||file:*.gradle||file:*/gradle-wrapper.properties||file:*.toml",
"Media" to "file:*.png||file:*.jpg||file:*.dds||file:*.exr||file:*.mp3||file:*.wav||file:*.mp4||file:*.mov||file:*.svg"
)
files.forEach { (name, pattern) ->
val file = File(scopesFolder, "__$name.xml")
if (!file.exists()) {
file.writeText(
"""
<component name="DependencyValidationManager">
<scope name=" ★ $name" pattern="$pattern" />
</component>
""".trimIndent()
)
}
}
}

View File

@@ -1,37 +0,0 @@
package conventions
import org.gradle.kotlin.dsl.java
import org.gradle.kotlin.dsl.kotlin
plugins {
java
kotlin("jvm")
`maven-publish`
}
val libs = extensions.getByType<VersionCatalogsExtension>().named("libs")
val openrndr = extensions.getByType<VersionCatalogsExtension>().named("openrndr")
val demo = sourceSets.create("demo")
val main = sourceSets.getByName("main")
demo.compileClasspath += main.compileClasspath
demo.runtimeClasspath += main.runtimeClasspath
demo.compileClasspath += main.output
demo.runtimeClasspath += main.output
dependencies {
"demoRuntimeOnly"(openrndr.findLibrary("gl3").get())
}
publishing {
publications {
create<MavenPublication>("maven") {
from(components["java"])
groupId = property("project.group")?.toString() ?: error("project.group not set")
artifactId = property("project.name")?.toString() ?: error("project.name not set")
description = property("project.name")?.toString() ?: error("project.name not set")
version = property("project.version")?.toString() ?: error("project.version not set")
}
}
}

View File

@@ -1,26 +1,23 @@
package conventions package org.openrndr.template.convention
import org.gradle.internal.os.OperatingSystem import org.gradle.accessors.dm.LibrariesForLibs
import kotlin.collections.set
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.internal.os.OperatingSystem
val libs = the<LibrariesForLibs>()
var applicationMainClass: String = "setme"
plugins { plugins {
id("com.gradleup.shadow") kotlin("jvm")
id("com.github.johnrengelman.shadow")
id("org.beryx.runtime") id("org.beryx.runtime")
} application
val applicationMainClass: String by properties
application {
mainClass = if (hasProperty("openrndr.application"))
"${property("openrndr.application")}"
else
applicationMainClass
} }
tasks { tasks {
named<ShadowJar>("shadowJar") { named<ShadowJar>("shadowJar") {
manifest { manifest {
attributes["Main-Class"] = applicationMainClass attributes["Main-Class"] = application.mainClass.get()
attributes["Implementation-Version"] = project.version attributes["Implementation-Version"] = project.version
} }
minimize { minimize {
@@ -30,34 +27,32 @@ tasks {
exclude(dependency("org.apache.logging.log4j:log4j-slf4j2-impl:.*")) exclude(dependency("org.apache.logging.log4j:log4j-slf4j2-impl:.*"))
exclude(dependency("com.fasterxml.jackson.core:jackson-databind:.*")) exclude(dependency("com.fasterxml.jackson.core:jackson-databind:.*"))
exclude(dependency("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:.*")) exclude(dependency("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:.*"))
exclude(dependency("org.bytedeco:.*"))
} }
} }
}
tasks {
named<org.beryx.runtime.JPackageTask>("jpackage") { named<org.beryx.runtime.JPackageTask>("jpackage") {
doLast { doLast {
val destPath = if (OperatingSystem.current().isMacOsX) val destPath = if(OperatingSystem.current().isMacOsX)
"build/jpackage/openrndr-application.app/Contents/Resources/data" "build/jpackage/openrndr-application.app/Contents/Resources/data"
else else
"build/jpackage/openrndr-application/data" "build/jpackage/openrndr-application/data"
copy { copy {
from("data") { include("**/*") } from("data") {
include("**/*")
}
into(destPath) into(destPath)
} }
} }
} }
}
register<Zip>("jpackageZip") { tasks.register<Zip>("jpackageZip") {
archiveFileName = "openrndr-application.zip" archiveFileName.set("openrndr-application.zip")
from("${layout.buildDirectory.get()}/jpackage") { from("${layout.buildDirectory.get()}/jpackage") {
include("**/*") include("**/*")
}
dependsOn("jpackage")
} }
} }
tasks.findByName("jpackageZip")?.dependsOn("jpackage")
runtime { runtime {
jpackage { jpackage {
@@ -68,6 +63,6 @@ runtime {
jvmArgs.add("-Duser.dir=${"$"}APPDIR/../Resources") jvmArgs.add("-Duser.dir=${"$"}APPDIR/../Resources")
} }
} }
options = listOf("--strip-debug", "--compress", "1", "--no-header-files", "--no-man-pages") options.set(listOf("--strip-debug", "--compress", "1", "--no-header-files", "--no-man-pages"))
modules = listOf("jdk.unsupported", "java.management", "java.desktop") modules.set(listOf("jdk.unsupported", "java.management", "java.desktop"))
} }

View File

@@ -0,0 +1,49 @@
package org.openrndr.template.convention
import org.gradle.accessors.dm.LibrariesForLibs
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
val libs = the<LibrariesForLibs>()
plugins {
kotlin("jvm")
application
}
//application {
// if (hasProperty("openrndr.application")) {
// mainClass.set("${property("openrndr.application")}")
// }
//}
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "17"
}
compilerOptions {
jvmTarget.set(JvmTarget.valueOf("JVM_${libs.versions.jvmTarget.get()}"))
freeCompilerArgs.add("-Xjdk-release=${libs.versions.jvmTarget.get()}")
}
}
java {
sourceCompatibility = JavaVersion.valueOf("VERSION_${libs.versions.jvmTarget.get()}")
targetCompatibility = JavaVersion.valueOf("VERSION_${libs.versions.jvmTarget.get()}")
}
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
implementation(libs.kotlinx.coroutines.core)
implementation(libs.slf4j.api)
implementation(libs.kotlin.logging)
implementation(libs.openrndr.application)
implementation(libs.openrndr.animatable)
implementation(libs.openrndr.dialogs)
implementation(libs.openrndr.extensions)
}

View File

@@ -0,0 +1,163 @@
package org.openrndr.template
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.ProjectEvaluationListener
import org.gradle.api.ProjectState
import org.gradle.api.artifacts.DependencyResolutionListener
import org.gradle.api.artifacts.MinimalExternalModuleDependency
import org.gradle.api.artifacts.ResolvableDependencies
import org.gradle.api.provider.Property
import org.gradle.api.provider.Provider
import org.gradle.api.provider.SetProperty
import org.gradle.internal.os.OperatingSystem
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
import java.io.File
interface OpenrndrPluginExtension {
val openrndrVersion: Property<String>
val orxVersion: Property<String>
val openrndrFeatures: SetProperty<Provider<MinimalExternalModuleDependency>>
val orxFeatures: SetProperty<Provider<MinimalExternalModuleDependency>>
val mainClass: Property<String>
}
class OpenrndrPlugin : Plugin<Project> {
override fun apply(target: Project) {
val extension = target.extensions.create("openrndr", OpenrndrPluginExtension::class.java)
// Install the convention plugins
run {
target.plugins.apply("org.openrndr.template.convention.openrndr-jvm")
target.plugins.apply("org.openrndr.template.convention.distribution-jvm")
}
// Configure the application mainClass
run {
val app =
(target as org.gradle.api.plugins.ExtensionAware).extensions.getByName("application") as org.gradle.api.plugins.JavaApplication
app.mainClass.set(extension.mainClass)
}
// Install the OPENRNDR tasks
run {
target.gradle.addListener(object : ProjectEvaluationListener {
override fun beforeEvaluate(project: Project) {
}
override fun afterEvaluate(project: Project, state: ProjectState) {
if (target.properties["openrndr.tasks"] == "true") {
target.task("create executable jar for ${extension.mainClass.get()}") {
group = " \uD83E\uDD8C OPENRNDR"
dependsOn("shadowJar")
}
target.task("run $${extension.mainClass.get()}") {
group = " \uD83E\uDD8C OPENRNDR"
dependsOn("run")
}
target.task("create standalone executable for ${extension.mainClass.get()}") {
group = " \uD83E\uDD8C OPENRNDR"
dependsOn("jpackageZip")
}
target.task("add IDE file scopes") {
group = " \uD83E\uDD8C OPENRNDR"
val scopesFolder = File("${project.projectDir}/.idea/scopes")
scopesFolder.mkdirs()
val files = listOf(
"Code" to "file:*.kt||file:*.frag||file:*.vert||file:*.glsl",
"Text" to "file:*.txt||file:*.md||file:*.xml||file:*.json",
"Gradle" to "file[*buildSrc*]:*/||file:*gradle.*||file:*.gradle||file:*/gradle-wrapper.properties||file:*.toml",
"Media" to "file:*.png||file:*.jpg||file:*.dds||file:*.exr||file:*.mp3||file:*.wav||file:*.mp4||file:*.mov||file:*.svg"
)
files.forEach { (name, pattern) ->
val file = File(scopesFolder, "__$name.xml")
if (!file.exists()) {
file.writeText(
"""
<component name="DependencyValidationManager">
<scope name=" ★ $name" pattern="$pattern" />
</component>
""".trimIndent()
)
}
}
}
}
}
})
}
// Dynamically configure dependencies from openrndrFeatures and orxFeatures
run {
val currArch = DefaultNativePlatform("current").architecture.name
val currOs = OperatingSystem.current()
val os = if (target.hasProperty("targetPlatform")) {
val supportedPlatforms = setOf("windows", "macos", "macos-arm64", "linux-x64", "linux-arm64")
val platform: String = target.property("targetPlatform") as String
if (platform !in supportedPlatforms) {
throw IllegalArgumentException("target platform not supported: $platform")
} else {
platform
}
} else when {
currOs.isWindows -> "windows"
currOs.isMacOsX -> when (currArch) {
"aarch64", "arm-v8" -> "macos-arm64"
else -> "macos"
}
currOs.isLinux -> when (currArch) {
"x86-64" -> "linux-x64"
"aarch64" -> "linux-arm64"
else -> throw IllegalArgumentException("architecture not supported: $currArch")
}
else -> throw IllegalArgumentException("os not supported: ${currOs.name}")
}
target.gradle.addListener(object : DependencyResolutionListener {
override fun beforeResolve(dependencies: ResolvableDependencies) {
for (feature in extension.orxFeatures.get()) {
target.dependencies.add("implementation", feature)
}
for (feature in extension.openrndrFeatures.get()) {
target.dependencies.add("implementation", feature)
val dep = feature.get()
when (dep.name) {
"openrndr-ffmpeg" -> target.dependencies.add(
"runtimeOnly",
"${dep.group}:${dep.name}-natives-$os:${dep.version}"
)
"openrndr-gl3" -> target.dependencies.add(
"runtimeOnly",
"${dep.group}:${dep.name}-natives-$os:${dep.version}"
)
}
}
for (feature in extension.orxFeatures.get()) {
target.dependencies.add("implementation", feature)
val dep = feature.get()
when (dep.name) {
"orx-kinect-v1" -> target.dependencies.add(
"runtimeOnly",
"${dep.group}:${dep.name}-natives-$os:${dep.version}"
)
}
}
target.gradle.removeListener(this)
}
override fun afterResolve(dependencies: ResolvableDependencies) {
}
})
}
}
}

View File

@@ -1,10 +1,4 @@
project.name=openrndr-template
project.group=org.openrndr
project.version=1.0.0
applicationMainClass=TemplateProgramKt
openrndr.tasks=true openrndr.tasks=true
kotlin.code.style=official kotlin.code.style=official
#org.gradle.configuration-cache=true #org.gradle.configuration-cache=true
#org.gradle.configuration-cache.parallel=true #org.gradle.configuration-cache.problems=warn
#org.gradle.configuration-cache.problems=warn

View File

@@ -1,29 +1,18 @@
[versions] [versions]
jvmTarget = "17" kotlin = "2.0.0"
kotlin = "2.2.10" openrndr = "0.4.5-SNAPSHOT"
kotlinApi = "2.2" orx = "0.4.5-SNAPSHOT"
kotlinLanguage = "2.2"
openrndr = "0.5.0-SNAPSHOT"
orx = "0.5.0-SNAPSHOT"
orsl = "0.4.5-alpha5"
orml = "0.4.1" orml = "0.4.1"
jvmTarget = "17"
slf4j = "2.0.17"
slf4j = "2.0.13"
log4j = "2.23.1" log4j = "2.23.1"
jackson = "2.17.2" jackson = "2.17.1"
junit = "4.13.2"
kotlinxCoroutines = "1.10.2"
kotlinxSerialization = "1.9.0"
kotlinLogging = "7.0.13"
kotlinCsvJvm = "1.9.3"
jsoup = "1.17.1"
shadow = "9.1.0"
runtime = "1.13.1"
versions = "0.52.0"
[libraries] [libraries]
kotlin-script-runtime = { group = "org.jetbrains.kotlin", name = "kotlin-script-runtime", version.ref = "kotlin" } kotlin-script-runtime = { group = "org.jetbrains.kotlin", name = "kotlin-script-runtime", version.ref = "kotlin" }
kotlin-gradle-plugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }
slf4j-api = { group = "org.slf4j", name = "slf4j-api", version.ref = "slf4j" } slf4j-api = { group = "org.slf4j", name = "slf4j-api", version.ref = "slf4j" }
slf4j-nop = { group = "org.slf4j", name = "slf4j-nop", version.ref = "slf4j" } slf4j-nop = { group = "org.slf4j", name = "slf4j-nop", version.ref = "slf4j" }
@@ -33,27 +22,53 @@ log4j-core = { group = "org.apache.logging.log4j", name = "log4j-core", version.
jackson-databind = { group = "com.fasterxml.jackson.core", name = "jackson-databind", version.ref = "jackson" } jackson-databind = { group = "com.fasterxml.jackson.core", name = "jackson-databind", version.ref = "jackson" }
jackson-json = { group = "com.fasterxml.jackson.dataformat", name = "jackson-dataformat-yaml", version.ref = "jackson" } jackson-json = { group = "com.fasterxml.jackson.dataformat", name = "jackson-dataformat-yaml", version.ref = "jackson" }
shadow-gradle-plugin = { group = "com.gradleup.shadow", name = "com.gradleup.shadow.gradle.plugin", version.ref = "shadow" } kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version = "1.8.1" }
runtime-gradle-plugin = { group = "org.beryx.runtime", name = "org.beryx.runtime.gradle.plugin", version.ref = "runtime" } kotlin-logging = { group = "io.github.oshai", name = "kotlin-logging", version = "6.0.9" }
kotlin-gradle-plugin = { group = "org.jetbrains.kotlin.jvm", name = "org.jetbrains.kotlin.jvm.gradle.plugin", version.ref = "kotlin" } junit = { group = "junit", name = "junit", version = "4.13.2" }
xversions-gradle-plugin = { group = "com.github.ben-manes.versions", name = "com.github.ben-manes.versions.gradle.plugin", version.ref = "versions" } jsoup = { group = "org.jsoup", name = "jsoup", version = "1.17.2" }
kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "kotlinxCoroutines" } gson = { group = "com.google.code.gson", name = "gson", version = "2.11.1" }
kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinxSerialization" } csv = { group = "com.github.doyaaaaaken", name = "kotlin-csv-jvm", version = "1.9.3" }
kotlinx-serialization-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-core", version.ref = "kotlinxSerialization" }
kotlin-logging = { group = "io.github.oshai", name = "kotlin-logging", version.ref = "kotlinLogging" } openrndr-animatable = { group = "org.openrndr", name = "openrndr-animatable", version.ref = "openrndr" }
junit = { group = "junit", name = "junit", version.ref = "junit" } openrndr-application = { group = "org.openrndr", name = "openrndr-application", version.ref = "openrndr" }
jsoup = { group = "org.jsoup", name = "jsoup", version.ref = "jsoup" } openrndr-binpack = { group = "org.openrndr", name = "openrndr-binpack", version.ref = "openrndr" }
csv = { group = "com.github.doyaaaaaken", name = "kotlin-csv-jvm", version.ref = "kotlinCsvJvm" } openrndr-dialogs = { group = "org.openrndr", name = "openrndr-dialogs", version.ref = "openrndr" }
openrndr-event = { group = "org.openrndr", name = "openrndr-event", version.ref = "openrndr" }
openrndr-extensions = { group = "org.openrndr", name = "openrndr-extensions", version.ref = "openrndr" }
openrndr-filter = { group = "org.openrndr", name = "openrndr-filter", version.ref = "openrndr" }
openrndr-gl3 = { group = "org.openrndr", name = "openrndr-gl3", version.ref = "openrndr" }
openrndr-math = { group = "org.openrndr", name = "openrndr-math", version.ref = "openrndr" }
openrndr-ffmpeg = { group = "org.openrndr", name = "openrndr-ffmpeg", version.ref = "openrndr" }
openrndr-nullgl = { group = "org.openrndr", name = "openrndr-nullgl", version.ref = "openrndr" }
orx-camera = { group = "org.openrndr.extra", name = "orx-camera", version.ref = "orx" }
orx-color = { group = "org.openrndr.extra", name = "orx-color", version.ref = "orx" }
orx-compositor = { group = "org.openrndr.extra", name = "orx-compositor", version.ref = "orx" }
orx-delegate-magic = { group = "org.openrndr.extra", name = " orx-delegate-magic", version.ref = "orx" }
orx-envelopes = { group = "org.openrndr.extra", name = "orx-envelopes", version.ref = "orx" }
orx-fx = { group = "org.openrndr.extra", name = "orx-fx", version.ref = "orx" }
orx-gui = { group = "org.openrndr.extra", name = "orx-gui", version.ref = "orx" }
orx-image-fit = { group = "org.openrndr.extra", name = "orx-image-fit", version.ref = "orx" }
orx-no-clear = { group = "org.openrndr.extra", name = "orx-no-clear", version.ref = "orx" }
orx-noise = { group = "org.openrndr.extra", name = "orx-noise", version.ref = "orx" }
orx-olive = { group = "org.openrndr.extra", name = "orx-olive", version.ref = "orx" }
orx-panel = { group = "org.openrndr.extra", name = "orx-panel", version.ref = "orx" }
orx-shade-styles = { group = "org.openrndr.extra", name = "orx-shade-styles", version.ref = "orx" }
orx-shapes = { group = "org.openrndr.extra", name = "orx-shapes", version.ref = "orx" }
orx-svg = { group = "org.openrndr.extra", name = "orx-svg", version.ref = "orx" }
orx-video-profiles = { group = "org.openrndr.extra", name = "orx-video-profiles", version.ref = "orx" }
orx-view-box = { group = "org.openrndr.extra", name = "orx-view-box", version.ref = "orx" }
shadow-gradle-plugin = { group = "com.github.johnrengelman", name = "shadow", version = "8.1.1" }
runtime-gradle-plugin = { group = "org.beryx", name = "badass-runtime-plugin", version = "1.13.0" }
[plugins] [plugins]
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
shadow = { id = "com.gradleup.shadow", version.ref = "shadow" }
runtime = { id = "org.beryx.runtime", version.ref = "runtime" }
gitarchive-tomarkdown = { id = "org.openrndr.extra.gitarchiver.tomarkdown", version.ref = "orx" }
versions = { id = "com.github.ben-manes.versions", version.ref = "versions" }
[bundles] shadow = { id = "com.github.johnrengelman.shadow", version = "8.1.1" }
logging-none = ["slf4j-nop"] runtime = { id = "org.beryx.runtime", version = "1.13.1" }
logging-simple = ["slf4j-simple"] gitarchive-tomarkdown = { id = "org.openrndr.extra.gitarchiver.tomarkdown", version.ref = "orx" }
loggin-full = ["log4j-slf4j2", "log4j-core", "jackson-databind", "jackson-json"] versions = { id = "com.github.ben-manes.versions", version = "0.50.0" }

Binary file not shown.

View File

@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000 networkTimeout=10000
validateDistributionUrl=true validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME

12
gradlew vendored
View File

@@ -15,8 +15,6 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# #
# SPDX-License-Identifier: Apache-2.0
#
############################################################################## ##############################################################################
# #
@@ -57,7 +55,7 @@
# Darwin, MinGW, and NonStop. # Darwin, MinGW, and NonStop.
# #
# (3) This script is generated from the Groovy template # (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project. # within the Gradle project.
# #
# You can find Gradle at https://github.com/gradle/gradle/. # You can find Gradle at https://github.com/gradle/gradle/.
@@ -86,7 +84,7 @@ done
# shellcheck disable=SC2034 # shellcheck disable=SC2034
APP_BASE_NAME=${0##*/} APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum MAX_FD=maximum
@@ -114,7 +112,7 @@ case "$( uname )" in #(
NONSTOP* ) nonstop=true ;; NONSTOP* ) nonstop=true ;;
esac esac
CLASSPATH="\\\"\\\"" CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM. # Determine the Java command to use to start the JVM.
@@ -205,7 +203,7 @@ fi
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command: # Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped. # and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line. # treated as '${Hostname}' itself on the command line.
@@ -213,7 +211,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
set -- \ set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \ "-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \ -classpath "$CLASSPATH" \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ org.gradle.wrapper.GradleWrapperMain \
"$@" "$@"
# Stop when "xargs" is not available. # Stop when "xargs" is not available.

26
gradlew.bat vendored
View File

@@ -13,8 +13,6 @@
@rem See the License for the specific language governing permissions and @rem See the License for the specific language governing permissions and
@rem limitations under the License. @rem limitations under the License.
@rem @rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off @if "%DEBUG%"=="" @echo off
@rem ########################################################################## @rem ##########################################################################
@@ -45,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute if %ERRORLEVEL% equ 0 goto execute
echo. 1>&2 echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo. 1>&2 echo.
echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation. 1>&2 echo location of your Java installation.
goto fail goto fail
@@ -59,22 +57,22 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute if exist "%JAVA_EXE%" goto execute
echo. 1>&2 echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo. 1>&2 echo.
echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation. 1>&2 echo location of your Java installation.
goto fail goto fail
:execute :execute
@rem Setup the command line @rem Setup the command line
set CLASSPATH= set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle @rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end :end
@rem End local scope for the variables with windows NT shell @rem End local scope for the variables with windows NT shell

View File

@@ -1,4 +1,4 @@
rootProject.name = extra["project.name"]?.toString() ?: error("project.name not set") rootProject.name = "openrndr-template"
pluginManagement { pluginManagement {
repositories { repositories {
@@ -6,30 +6,3 @@ pluginManagement {
mavenLocal() mavenLocal()
} }
} }
dependencyResolutionManagement {
repositories {
mavenCentral()
mavenLocal {
content {
includeGroup("org.openrndr")
includeGroup("org.openrndr.extra")
}
}
}
versionCatalogs {
// We use a regex to get the openrndr/orx versions from the primary catalog as there is no public Gradle API to parse catalogs.
val orRegEx = Regex("^openrndr[ ]*=[ ]*(?:\\{[ ]*require[ ]*=[ ]*)?\"(.*)\"[ ]*(?:\\})?", RegexOption.MULTILINE)
val orxRegEx = Regex("^orx[ ]*=[ ]*(?:\\{[ ]*require[ ]*=[ ]*)?\"(.*)\"[ ]*(?:\\})?", RegexOption.MULTILINE)
val openrndrVersion = orRegEx.find(File(rootDir,"gradle/libs.versions.toml").readText())?.groupValues?.get(1) ?: error("can't find openrndr version")
val orxVersion = orxRegEx.find(File(rootDir,"gradle/libs.versions.toml").readText())?.groupValues?.get(1) ?: error("can't find orx version")
create("orx") {
from("org.openrndr.extra:orx-module-catalog:$orxVersion")
}
create("openrndr") {
from("org.openrndr:openrndr-module-catalog:$openrndrVersion")
}
}
}

View File

@@ -2,7 +2,7 @@ import org.openrndr.application
import org.openrndr.color.ColorRGBa import org.openrndr.color.ColorRGBa
import org.openrndr.draw.loadFont import org.openrndr.draw.loadFont
import org.openrndr.draw.loadImage import org.openrndr.draw.loadImage
import org.openrndr.extra.color.colormatrix.tint import org.openrndr.draw.tint
import kotlin.math.cos import kotlin.math.cos
import kotlin.math.sin import kotlin.math.sin