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
17 changed files with 430 additions and 484 deletions

View File

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

View File

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

2
.gitignore vendored
View File

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

View File

@@ -12,8 +12,8 @@ You will find some [basic instructions](https://guide.openrndr.org/setUpYourFirs
## Gradle tasks
- `./gradlew run` runs the TemplateProgram (Use `gradlew.bat run` under Windows)
- `./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 (works with Java 14 only). Run it like this: `cd build/jpackage/openrndr-application/ && bin/openrndr-application`.
- `./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 jpackageZip` creates a zip with a stand-alone executable for the current platform (works with Java 14 only)
## Cross builds
@@ -21,26 +21,20 @@ To create a runnable jar for a platform different from your current platform, us
## 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
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.
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.
Newer versions bring useful features and bug fixes. The most recent versions are
Newer versions of OPENRNDR and ORX bring useful features and bug fixes. The most recent versions are
<br>![openrndr version](https://maven-badges.herokuapp.com/maven-central/org.openrndr/openrndr-application/badge.svg) for OPENRNDR.
<br>![orx version](https://maven-badges.herokuapp.com/maven-central/org.openrndr.extra/orx-parameters-jvm/badge.svg) for ORX.
<br>![orsl version](https://maven-badges.herokuapp.com/maven-central/org.openrndr.orsl/orsl-shader-generator-jvm/badge.svg) for ORSL.
Switch to the [next-version branch](https://github.com/openrndr/openrndr-template/tree/next-version) or enter these versions manually in your toml file.
They can look like "0.4.3" or "0.4.3-alpha4". Use the complete string, as in:
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:
openrndr = "0.4.5-alpha5"
orx = "0.4.5-alpha5"
orsl = "0.4.5-alpha5"
openrndr = "0.4.3-alpha4"
orx = "0.4.3-alpha4"
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
@@ -56,16 +50,19 @@ To run `src/main/kotlin/foo/bar/myProgram.kt` (assuming `package foo.bar` in myP
## 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.
- [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:
```
[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:
git tag -a v1.0.0 -m "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.

View File

@@ -1,406 +1,28 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.internal.os.OperatingSystem
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.panteleyev.jpackage.ImageType
group = "org.openrndr.template"
version = "1.0.0"
val applicationMainClass = "TemplateProgramKt"
/** ## additional ORX features to be added to this project */
val orxFeatures = setOf<String>(
// "orx-boofcv",
"orx-camera",
// "orx-chataigne",
"orx-color",
// "orx-composition",
"orx-compositor",
// "orx-compute-graph",
// "orx-compute-graph-nodes",
"orx-delegate-magic",
// "orx-dnk3",
// "orx-easing",
"orx-envelopes",
// "orx-expression-evaluator",
// "orx-fcurve",
// "orx-fft",
// "orx-file-watcher",
"orx-fx",
// "orx-git-archiver",
// "orx-gradient-descent",
"orx-gui",
// "orx-hash-grid",
"orx-image-fit",
// "orx-integral-image",
// "orx-interval-tree",
// "orx-jumpflood",
// "orx-kdtree",
// "orx-keyframer",
// "orx-kinect-v1",
// "orx-kotlin-parser",
// "orx-marching-squares",
// "orx-math",
// "orx-mesh-generators",
// "orx-midi",
// "orx-minim",
"orx-no-clear",
"orx-noise",
// "orx-obj-loader",
"orx-olive",
// "orx-osc",
// "orx-palette",
"orx-panel",
// "orx-parameters",
// "orx-poisson-fill",
// "orx-property-watchers",
// "orx-quadtree",
// "orx-rabbit-control",
// "orx-realsense2",
// "orx-runway",
"orx-shade-styles",
// "orx-shader-phrases",
"orx-shapes",
// "orx-svg",
// "orx-syphon",
// "orx-temporal-blur",
// "orx-tensorflow",
// "orx-text-writer",
// "orx-time-operators",
// "orx-timer",
// "orx-triangulation",
// "orx-turtle",
"orx-video-profiles",
"orx-view-box",
)
/** ## additional ORML features to be added to this project */
val ormlFeatures = setOf<String>(
// "orml-blazepose",
// "orml-dbface",
// "orml-facemesh",
// "orml-image-classifier",
// "orml-psenet",
// "orml-ssd",
// "orml-style-transfer",
// "orml-super-resolution",
// "orml-u2net",
)
/** ## additional OPENRNDR features to be added to this project */
val openrndrFeatures = setOfNotNull(
if (DefaultNativePlatform("current").architecture.name != "arm-v8") "video" else null
)
/** ## configure the type of logging this project uses */
enum class Logging { NONE, SIMPLE, FULL }
val applicationLogging = Logging.FULL
// ------------------------------------------------------------------------------------------------------------------ //
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
java
application
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.shadow)
alias(libs.plugins.jpackage)
alias(libs.plugins.gitarchive.tomarkdown).apply(false)
alias(libs.plugins.versions)
alias(libs.plugins.kotlin.serialization)
openrndr
}
repositories {
mavenCentral()
mavenLocal()
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 {
// implementation(libs.jsoup)
// implementation(libs.csv)
/* ORSL dependencies */
// implementation(libs.orsl.shader.generator)
// implementation(libs.orsl.extension.color)
// implementation(libs.orsl.extension.easing)
// implementation(libs.orsl.extension.gradient)
// implementation(libs.orsl.extension.noise)
// implementation(libs.orsl.extension.pbr)
// implementation(libs.orsl.extension.raymarching)
// implementation(libs.orsl.extension.sdf)
implementation(libs.kotlinx.coroutines.core)
implementation(libs.kotlinx.serialization.core)
implementation(libs.kotlinx.serialization.json)
implementation(libs.slf4j.api)
implementation(libs.kotlin.logging)
when (applicationLogging) {
Logging.NONE -> {
runtimeOnly(libs.slf4j.nop)
}
Logging.SIMPLE -> {
runtimeOnly(libs.slf4j.simple)
}
Logging.FULL -> {
runtimeOnly(libs.log4j.slf4j2)
runtimeOnly(libs.log4j.core)
runtimeOnly(libs.jackson.databind)
runtimeOnly(libs.jackson.json)
}
}
implementation(kotlin("stdlib-jdk8"))
testImplementation(libs.junit)
implementation(libs.csv)
}
// ------------------------------------------------------------------------------------------------------------------ //
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlin {
compilerOptions {
languageVersion = KotlinVersion.KOTLIN_2_0
apiVersion = KotlinVersion.KOTLIN_2_0
jvmTarget = JvmTarget.JVM_17
}
}
// ------------------------------------------------------------------------------------------------------------------ //
application {
mainClass = if (hasProperty("openrndr.application"))
"${property("openrndr.application")}"
else
applicationMainClass
}
tasks {
named<ShadowJar>("shadowJar") {
manifest {
attributes["Main-Class"] = applicationMainClass
attributes["Implementation-Version"] = project.version
}
minimize {
exclude(dependency("org.openrndr:openrndr-gl3:.*"))
exclude(dependency("org.jetbrains.kotlin:kotlin-reflect:.*"))
exclude(dependency("org.slf4j:slf4j-simple:.*"))
exclude(dependency("org.apache.logging.log4j:log4j-slf4j2-impl:.*"))
exclude(dependency("com.fasterxml.jackson.core:jackson-databind:.*"))
exclude(dependency("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:.*"))
exclude(dependency("org.bytedeco:.*"))
}
}
}
// ------------------------------------------------------------------------------------------------------------------ //
tasks {
named("jpackage") {
doLast {
val destPath = "build/jpackage/" + if (OperatingSystem.current().isMacOsX)
"openrndr-application.app/Contents/Resources/data"
else
"openrndr-application/data"
copy {
from("data") { include("**/*") }
into(destPath)
}
}
}
register<Zip>("jpackageZip") {
archiveFileName = "openrndr-application.zip"
from("${layout.buildDirectory.get()}/jpackage") {
include("**/*")
}
isPreserveFileTimestamps = true
isReproducibleFileOrder = true
useFileSystemPermissions()
dependsOn("jpackage")
}
}
// ------------------------------------------------------------------------------------------------------------------ //
tasks.register("copyDependencies", Copy::class) {
from(configurations.runtimeClasspath).into(layout.buildDirectory.dir("jars"))
}
tasks.register("copyJar", Copy::class) {
from(tasks.jar).into(layout.buildDirectory.dir("jars"))
}
tasks.jpackage {
dependsOn("build", "copyDependencies", "copyJar")
appName = "openrndr-application"
mac {
javaOptions = listOf(
"-XstartOnFirstThread",
$$"-Duser.dir=$APPDIR/../Resources"
)
}
windows {
}
linux {
type = ImageType.APP_IMAGE
}
input = layout.buildDirectory.dir("jars")
destination = layout.buildDirectory.dir("jpackage")
mainJar = tasks.jar.get().archiveFileName.get()
mainClass = applicationMainClass
addModules = listOf("jdk.unsupported", "java.management", "java.desktop")
jLinkOptions = listOf("--strip-debug", "--compress", "1", "--no-header-files", "--no-man-pages")
}
// ------------------------------------------------------------------------------------------------------------------ //
tasks.register<org.openrndr.extra.gitarchiver.GitArchiveToMarkdown>("gitArchiveToMarkDown") {
historySize = 20
}
// ------------------------------------------------------------------------------------------------------------------ //
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)
}
}
}
// ------------------------------------------------------------------------------------------------------------------ //
class Openrndr {
val openrndrVersion = libs.versions.openrndr.get()
val orxVersion = libs.versions.orx.get()
val ormlVersion = libs.versions.orml.get()
// choices are "orx-tensorflow-gpu", "orx-tensorflow"
val orxTensorflowBackend = "orx-tensorflow"
val currArch = DefaultNativePlatform("current").architecture.name
val currOs = OperatingSystem.current()
val os = if (project.hasProperty("targetPlatform")) {
val supportedPlatforms = setOf("windows", "macos", "linux-x64", "linux-arm64")
val platform: String = project.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}")
}
fun orx(module: String) = "org.openrndr.extra:$module:$orxVersion"
fun orml(module: String) = "org.openrndr.orml:$module:$ormlVersion"
fun openrndr(module: String) = "org.openrndr:openrndr-$module:$openrndrVersion"
fun openrndrNatives(module: String) = "org.openrndr:openrndr-$module-natives-$os:$openrndrVersion"
fun orxNatives(module: String) = "org.openrndr.extra:$module-natives-$os:$orxVersion"
init {
dependencies {
runtimeOnly(openrndr("gl3"))
runtimeOnly(openrndrNatives("gl3"))
implementation(openrndr("openal"))
runtimeOnly(openrndrNatives("openal"))
implementation(openrndr("application"))
implementation(openrndr("animatable"))
implementation(openrndr("extensions"))
implementation(openrndr("filter"))
implementation(openrndr("dialogs"))
if ("video" in openrndrFeatures) {
implementation(openrndr("ffmpeg"))
runtimeOnly(openrndrNatives("ffmpeg"))
}
for (feature in orxFeatures) {
implementation(orx(feature))
}
for (feature in ormlFeatures) {
implementation(orml(feature))
}
if ("orx-tensorflow" in orxFeatures) runtimeOnly("org.openrndr.extra:$orxTensorflowBackend-natives-$os:$orxVersion")
if ("orx-kinect-v1" in orxFeatures) runtimeOnly(orxNatives("orx-kinect-v1"))
if ("orx-olive" in orxFeatures) implementation(libs.kotlin.script.runtime)
}
}
}
val openrndr = Openrndr()
if (properties["openrndr.tasks"] == "true") {
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()
)
}
}
}
}

29
buildSrc/build.gradle.kts Normal file
View File

@@ -0,0 +1,29 @@
plugins {
`kotlin-dsl`
}
repositories {
mavenCentral()
mavenLocal()
gradlePluginPortal()
}
dependencies {
implementation(libs.kotlin.gradle.plugin)
implementation(libs.shadow.gradle.plugin)
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

@@ -0,0 +1,7 @@
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}

View File

@@ -0,0 +1,68 @@
package org.openrndr.template.convention
import org.gradle.accessors.dm.LibrariesForLibs
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.internal.os.OperatingSystem
val libs = the<LibrariesForLibs>()
var applicationMainClass: String = "setme"
plugins {
kotlin("jvm")
id("com.github.johnrengelman.shadow")
id("org.beryx.runtime")
application
}
tasks {
named<ShadowJar>("shadowJar") {
manifest {
attributes["Main-Class"] = application.mainClass.get()
attributes["Implementation-Version"] = project.version
}
minimize {
exclude(dependency("org.openrndr:openrndr-gl3:.*"))
exclude(dependency("org.jetbrains.kotlin:kotlin-reflect:.*"))
exclude(dependency("org.slf4j:slf4j-simple:.*"))
exclude(dependency("org.apache.logging.log4j:log4j-slf4j2-impl:.*"))
exclude(dependency("com.fasterxml.jackson.core:jackson-databind:.*"))
exclude(dependency("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:.*"))
}
}
named<org.beryx.runtime.JPackageTask>("jpackage") {
doLast {
val destPath = if(OperatingSystem.current().isMacOsX)
"build/jpackage/openrndr-application.app/Contents/Resources/data"
else
"build/jpackage/openrndr-application/data"
copy {
from("data") {
include("**/*")
}
into(destPath)
}
}
}
}
tasks.register<Zip>("jpackageZip") {
archiveFileName.set("openrndr-application.zip")
from("${layout.buildDirectory.get()}/jpackage") {
include("**/*")
}
}
tasks.findByName("jpackageZip")?.dependsOn("jpackage")
runtime {
jpackage {
imageName = "openrndr-application"
skipInstaller = true
if (OperatingSystem.current().isMacOsX) {
jvmArgs.add("-XstartOnFirstThread")
jvmArgs.add("-Duser.dir=${"$"}APPDIR/../Resources")
}
}
options.set(listOf("--strip-debug", "--compress", "1", "--no-header-files", "--no-man-pages"))
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,6 +1,4 @@
openrndr.tasks=true
kotlin.code.style=official
#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,24 +1,18 @@
[versions]
kotlin = "2.2.0"
openrndr = "0.4.5-alpha9"
orx = "0.4.5-alpha9"
orsl = "0.4.5-alpha5"
kotlin = "2.0.0"
openrndr = "0.4.5-SNAPSHOT"
orx = "0.4.5-SNAPSHOT"
orml = "0.4.1"
slf4j = "2.0.17"
jvmTarget = "17"
slf4j = "2.0.13"
log4j = "2.23.1"
jackson = "2.17.2"
junit = "4.13.2"
kotlinxCoroutines = "1.10.2"
kotlinxSerialization = "1.9.0"
kotlinLogging = "7.0.10"
kotlinCsvJvm = "1.9.3"
jsoup = "1.17.1"
shadow = "8.3.8"
jpackage = "1.7.3"
versions = "0.52.0"
jackson = "2.17.1"
[libraries]
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-nop = { group = "org.slf4j", name = "slf4j-nop", version.ref = "slf4j" }
@@ -28,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-json = { group = "com.fasterxml.jackson.dataformat", name = "jackson-dataformat-yaml", version.ref = "jackson" }
orsl-shader-generator = { group = "org.openrndr.extra", name = "orsl-shader-generator", version.ref = "orsl" }
orsl-extension-color = { group = "org.openrndr.extra", name = "orsl-extension-color", version.ref = "orsl" }
orsl-extension-easing = { group = "org.openrndr.extra", name = "orsl-extension-easing", version.ref = "orsl" }
orsl-extension-gradient = { group = "org.openrndr.extra", name = "orsl-extension-gradient", version.ref = "orsl" }
orsl-extension-noise = { group = "org.openrndr.extra", name = "orsl-extension-noise", version.ref = "orsl" }
orsl-extension-pbr = { group = "org.openrndr.extra", name = "orsl-extension-pbr", version.ref = "orsl" }
orsl-extension-raymarching = { group = "org.openrndr.extra", name = "orsl-extension-raymarching", version.ref = "orsl" }
orsl-extension-sdf = { group = "org.openrndr.extra", name = "orsl-extension-sdf", version.ref = "orsl" }
kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version = "1.8.1" }
kotlin-logging = { group = "io.github.oshai", name = "kotlin-logging", version = "6.0.9" }
junit = { group = "junit", name = "junit", version = "4.13.2" }
jsoup = { group = "org.jsoup", name = "jsoup", version = "1.17.2" }
gson = { group = "com.google.code.gson", name = "gson", version = "2.11.1" }
csv = { group = "com.github.doyaaaaaken", name = "kotlin-csv-jvm", version = "1.9.3" }
openrndr-animatable = { group = "org.openrndr", name = "openrndr-animatable", version.ref = "openrndr" }
openrndr-application = { group = "org.openrndr", name = "openrndr-application", version.ref = "openrndr" }
openrndr-binpack = { group = "org.openrndr", name = "openrndr-binpack", version.ref = "openrndr" }
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" }
kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "kotlinxCoroutines" }
kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinxSerialization" }
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" }
junit = { group = "junit", name = "junit", version.ref = "junit" }
jsoup = { group = "org.jsoup", name = "jsoup", version.ref = "jsoup" }
csv = { group = "com.github.doyaaaaaken", name = "kotlin-csv-jvm", version.ref = "kotlinCsvJvm" }
[plugins]
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" }
jpackage = { id = "org.panteleyev.jpackageplugin", version.ref = "jpackage"}
shadow = { id = "com.github.johnrengelman.shadow", version = "8.1.1" }
runtime = { id = "org.beryx.runtime", version = "1.13.1" }
gitarchive-tomarkdown = { id = "org.openrndr.extra.gitarchiver.tomarkdown", version.ref = "orx" }
versions = { id = "com.github.ben-manes.versions", version.ref = "versions" }
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
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME

12
gradlew vendored
View File

@@ -15,8 +15,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
@@ -57,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (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.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -86,7 +84,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# 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.
MAX_FD=maximum
@@ -114,7 +112,7 @@ case "$( uname )" in #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH="\\\"\\\""
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
@@ -205,7 +203,7 @@ fi
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# 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.
# * 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.
@@ -213,7 +211,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# 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 limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@@ -45,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
@@ -59,22 +57,22 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@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
@rem End local scope for the variables with windows NT shell

View File

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