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
22 changed files with 421 additions and 470 deletions

View File

@@ -3,21 +3,18 @@ on:
push:
branches:
- master
- next-version
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v3
- uses: actions/setup-java@v5
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 21
distribution: 'temurin'
java-version: '17'
#cache: 'gradle'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
- name: Build sources
run: ./gradlew build

View File

@@ -1,63 +0,0 @@
name: Build snapshot on commit
on:
push:
branches:
- snapshot
defaults:
run:
working-directory: ./template
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout OPENRNDR repository
uses: actions/checkout@v6
with:
fetch-depth: 0
repository: openrndr/openrndr
path: ./openrndr
ref: master
- name: Checkout ORX repository
uses: actions/checkout@v6
with:
fetch-depth: 0
repository: openrndr/orx
path: ./orx
ref: master
- name: Checkout current repository
uses: actions/checkout@v6
with:
fetch-depth: 0
repository: openrndr/openrndr-template
path: ./template
ref: snapshot
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 21
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
- name: Set swap space
uses: pierotofy/set-swap-space@v1.0
with:
swap-size-gb: 8
- name: Build OPENRNDR
working-directory: ./openrndr
run: ./gradlew publishToMavenLocal snapshot
- name: Build ORX
working-directory: ./orx
run: ./gradlew publishToMavenLocal snapshot
- name: Build template
working-directory: ./template
run: ./gradlew build

View File

@@ -23,10 +23,10 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v7
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.20.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

@@ -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`.
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
- `./gradlew run` runs `TemplateProgram.kt` (Use `gradlew.bat run` under Windows)
- `./gradlew run -Popenrndr.application=MyProgramKt` runs `src/main/kotlin/myProgram.kt`
- `./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 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)
- `./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.
- `./gradlew jpackageZip` creates a zip with a stand-alone executable for the current platform (works with Java 14 only)
## 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
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<br>
![Maven Central Version](https://img.shields.io/maven-central/v/org.openrndr/openrndr-math-jvm?label=OPENRNDR&color=%23FFC0CB)
![Maven Central Version](https://img.shields.io/maven-central/v/org.openrndr.extra/orx-noise-jvm?label=ORX&color=%23FFC0CB)
![Maven Central Version](https://img.shields.io/maven-central/v/org.openrndr.orsl/orsl-shader-generator-jvm?label=ORSL&color=%23FFC0CB).
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.
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
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
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.
## 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,30 +1,28 @@
group = property("project.group") ?: error("project.group not set")
version = property("project.version") ?: error("project.version not set")
group = "org.openrndr.template"
version = "1.0.0"
plugins {
alias(libs.plugins.kotlin.serialization)
id("conventions.kotlin-jvm")
id("conventions.openrndr-tasks")
id("conventions.distribute-application")
openrndr
}
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(openrndr.bundles.basic)
implementation(openrndr.bundles.video)
runtimeOnly(openrndr.bundles.runtime.sdl)
// runtimeOnly(openrndr.bundles.runtime.glfw)
runtimeOnly(openrndr.gl3)
implementation(openrndr.dialogs)
implementation(openrndr.orextensions)
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)
implementation(libs.csv)
}

View File

@@ -2,11 +2,28 @@ plugins {
`kotlin-dsl`
}
val libs = extensions.getByType<VersionCatalogsExtension>().named("libs")
repositories {
mavenCentral()
mavenLocal()
gradlePluginPortal()
}
dependencies {
implementation(libs.findLibrary("shadow-gradle-plugin").get())
implementation(libs.findLibrary("runtime-gradle-plugin").get())
implementation(libs.findLibrary("kotlin-gradle-plugin").get())
implementation(libs.findLibrary("xversions-gradle-plugin").get())
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

@@ -1,39 +1,7 @@
rootProject.name = "buildSrc"
dependencyResolutionManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenLocal {
content {
includeGroup("org.openrndr")
includeGroup("org.openrndr.extra")
}
}
}
versionCatalogs {
create("libs") {
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,70 +1,58 @@
package conventions
import org.gradle.internal.os.OperatingSystem
import kotlin.collections.set
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 {
id("com.gradleup.shadow")
kotlin("jvm")
id("com.github.johnrengelman.shadow")
id("org.beryx.runtime")
}
val applicationMainClass: String by properties
application {
mainClass = if (hasProperty("openrndr.application"))
"${property("openrndr.application")}"
else
applicationMainClass
application
}
tasks {
named<ShadowJar>("shadowJar") {
manifest {
attributes["Main-Class"] = applicationMainClass
attributes["Main-Class"] = application.mainClass.get()
attributes["Implementation-Version"] = project.version
}
minimize {
exclude(dependency("org.openrndr:openrndr-gl3:.*"))
exclude(dependency("org.openrndr:openrndr-application-glfw"))
exclude(dependency("org.openrndr:openrndr-application-sdl"))
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<org.beryx.runtime.JPackageTask>("jpackage") {
doLast {
val destPath = if (OperatingSystem.current().isMacOsX)
val destPath = if(OperatingSystem.current().isMacOsX)
"build/jpackage/openrndr-application.app/Contents/Resources/data"
else
"build/jpackage/openrndr-application/data"
copy {
from("data") { include("**/*") }
from("data") {
include("**/*")
}
into(destPath)
}
}
}
}
register<Zip>("jpackageZip") {
archiveFileName = "openrndr-application.zip"
from("${layout.buildDirectory.get()}/jpackage") {
include("**/*")
}
filesMatching("**/bin/*") {
permissions {
unix("0755")
}
}
dependsOn("jpackage")
tasks.register<Zip>("jpackageZip") {
archiveFileName.set("openrndr-application.zip")
from("${layout.buildDirectory.get()}/jpackage") {
include("**/*")
}
}
tasks.findByName("jpackageZip")?.dependsOn("jpackage")
runtime {
jpackage {
@@ -72,9 +60,9 @@ runtime {
skipInstaller = true
if (OperatingSystem.current().isMacOsX) {
jvmArgs.add("-XstartOnFirstThread")
jvmArgs.add($$"-Duser.dir=$APPDIR/../Resources")
jvmArgs.add("-Duser.dir=${"$"}APPDIR/../Resources")
}
}
options = listOf("--strip-debug", "--compress", "zip-6", "--no-header-files", "--no-man-pages")
modules = listOf("jdk.unsupported", "java.management", "java.desktop")
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,10 +1,4 @@
project.name=openrndr-template
project.group=org.openrndr
project.version=1.0.0
applicationMainClass=TemplateProgramKt
openrndr.tasks=true
kotlin.code.style=official
#org.gradle.configuration-cache=true
#org.gradle.configuration-cache.parallel=true
#org.gradle.configuration-cache.problems=warn

View File

@@ -1,29 +1,18 @@
[versions]
jvmTarget = "17"
kotlin = "2.3.21"
kotlinApi = "2.2"
kotlinLanguage = "2.2"
openrndr = "0.5.0-alpha4"
orx = "0.5.0-alpha4"
orsl = "0.4.5-alpha5"
kotlin = "2.0.0"
openrndr = "0.4.5-SNAPSHOT"
orx = "0.4.5-SNAPSHOT"
orml = "0.4.1"
jvmTarget = "17"
slf4j = "2.0.18"
slf4j = "2.0.13"
log4j = "2.23.1"
jackson = "2.17.2"
junit = "4.13.2"
kotlinxCoroutines = "1.11.0"
kotlinxSerialization = "1.11.0"
kotlinLogging = "8.0.03"
kotlinCsvJvm = "1.9.3"
jsoup = "1.17.1"
shadow = "9.4.0"
runtime = "2.0.1"
versions = "0.54.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" }
@@ -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-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" }
runtime-gradle-plugin = { group = "org.beryx.runtime", name = "org.beryx.runtime.gradle.plugin", version.ref = "runtime" }
kotlin-gradle-plugin = { group = "org.jetbrains.kotlin.jvm", name = "org.jetbrains.kotlin.jvm.gradle.plugin", version.ref = "kotlin" }
xversions-gradle-plugin = { group = "com.github.ben-manes.versions", name = "com.github.ben-manes.versions.gradle.plugin", version.ref = "versions" }
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" }
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" }
[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" }
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]
logging-none = ["slf4j-nop"]
logging-simple = ["slf4j-simple"]
logging-full = ["log4j-slf4j2", "log4j-core", "jackson-databind", "jackson-json"]
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 = "0.50.0" }

Binary file not shown.

View File

@@ -1,9 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
retries=0
retryBackOffMs=500
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

15
gradlew vendored
View File

@@ -1,7 +1,7 @@
#!/bin/sh
#
# Copyright © 2015 the original authors.
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -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/3d91ce3b8caaf77ad09f381f43615b715b53f72c/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,6 +112,7 @@ case "$( uname )" in #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
@@ -171,6 +170,7 @@ fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
@@ -203,14 +203,15 @@ 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.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.

54
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 ##########################################################################
@@ -23,8 +21,8 @@
@rem
@rem ##########################################################################
@rem Set local scope for the variables, and ensure extensions are enabled
setlocal EnableExtensions
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@@ -45,13 +43,13 @@ 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.
"%COMSPEC%" /c exit 1
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
@@ -59,24 +57,36 @@ 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.
"%COMSPEC%" /c exit 1
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
@rem endlocal doesn't take effect until after the line is parsed and variables are expanded
@rem which allows us to clear the local environment before executing the java command
endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:exitWithErrorLevel
@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts
"%COMSPEC%" /c exit %ERRORLEVEL%
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@@ -1,4 +1,4 @@
rootProject.name = extra["project.name"]?.toString() ?: error("project.name not set")
rootProject.name = "openrndr-template"
pluginManagement {
repositories {
@@ -6,30 +6,3 @@ pluginManagement {
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.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