Compare commits

..

37 Commits

Author SHA1 Message Date
Edwin Jakobs
e79d83c017 Merge branch 'next-version' into feature-variants 2025-09-17 01:35:44 -07:00
Abe Pazos
2623633588 README.md: tweak Building Libraries section
s/convention/conventions/
2025-09-16 22:38:56 +02:00
Edwin Jakobs
46fb734771 Fixed mavenLocal configuration 2025-09-16 22:25:49 +02:00
Edwin Jakobs
0bdb818026 Fixed missing logger providers in demo 2025-09-16 22:12:54 +02:00
Edwin Jakobs
d334c11b6a Add main.output to demo.runtimeClasspath 2025-09-16 21:43:32 +02:00
Edwin Jakobs
7f8af578e6 Add main.output to demo.compileClasspath 2025-09-16 19:10:52 +02:00
Edwin Jakobs
6e328f3871 Clean up publish-library.gradle.kts 2025-09-15 20:51:01 +02:00
Edwin Jakobs
15ab357c05 Restore plugin setup 2025-09-15 20:49:52 +02:00
Edwin Jakobs
f8cc9b713e Add publish-library convention plugin 2025-09-15 20:49:05 +02:00
Edwin Jakobs
a0b7df5585 Configure group/name/version through gradle.properties 2025-09-15 12:16:25 +02:00
Edwin Jakobs
3144067340 Remove lingering import and ext.set() 2025-09-15 11:49:58 +02:00
Edwin Jakobs
a4525f9b16 Use jvmTarget, kotlinLanguage and kotlinApi from libs.versions.toml 2025-09-15 07:19:20 +02:00
Edwin Jakobs
84f00fa827 Make use of version catalogs and variants 2025-09-14 21:27:30 +02:00
Abe Pazos
e97ef57b78 Update README.md: change Java requirement 14 -> 17 2025-09-13 19:46:41 +02:00
Abe Pazos
2e760f9c53 Add link to wiki 2025-09-11 13:11:13 +02:00
Abe Pazos
3d6774275a Add link to wiki 2025-09-11 13:10:29 +02:00
Abe Pazos
b4242bc892 Upgrade to Kotlin 2.2.20 2025-09-11 11:49:41 +02:00
Abe Pazos
d38df2eed7 Enable orx-composition, orx-svg, orx-text-writer
They were part of openrndr and enabled by default in the past
2025-09-11 11:35:00 +02:00
Abe Pazos
622bfc5077 Merge branch 'next-version' ignoring changes in master
Includes openrndr and orx 0.4.5
2025-09-06 13:54:37 +02:00
Abe Pazos
c2756d2b9d Upgrade to openrndr/orx 0.4.5 2025-09-06 13:36:34 +02:00
Abe Pazos
3ed7c18932 build.gradle.kts: add orx-axidraw, reformatting 2025-09-03 11:11:35 +02:00
Abe Pazos
86c36a0f35 Update to openrndr and orx 0.4.5-alpha11 2025-09-03 11:04:20 +02:00
Abe Pazos
e6a9e319d9 Update to gradleup.shadow 9.1.0 2025-08-29 22:58:55 +02:00
Abe Pazos
a385ebb216 Update badges in README.md
Previous ones stopped working
2025-08-26 15:11:52 +02:00
Abe Pazos
e1d44de9a1 Update badges in README.md
Previous ones stopped working
2025-08-26 15:07:50 +02:00
Abe Pazos
8191515779 Update to openrndr and orx 0.4.5-alpha10 2025-08-22 14:05:10 +02:00
Abe Pazos
7597ac35e2 Update README.md
Simplify README by merging two sections
2025-08-22 12:03:35 +00:00
Abe Pazos
69f698df1f Update to kotlin 2.2.10, kotlinLogging 7.0.13, shadow 9.0.2
Replace com.github.johnrengelman.shadow with com.gradleup.shadow
2025-08-21 00:00:04 +02:00
Abe Pazos
f93a523115 Dependencies: update kotlinLogging to 7.0.11 2025-08-06 11:57:54 +02:00
Abe Pazos
aa3e5e15ac Ignore .lwjgl in .gitignore
For new users, it's confusing that IDEA suggests adding five extra files to git when they only edited one.
2025-07-30 08:40:39 +02:00
Abe Pazos
ef7cee01c7 Fix #53 - ffmpeg warnings after shadowJar 2024-11-21 11:19:30 +01:00
Abe Pazos
de35f064d8 Update README.md
Mention how to specify a main method to run after using shadowJar

Simplify the text.
2024-11-16 17:24:36 +00:00
Abe Pazos
524635e1ad Revert accidentally pushed code
This reverts commit 3ef46bcc4e.
2024-10-31 08:02:36 +01:00
Abe Pazos
db5ea1cdd2 Update to Gradle 8.10.2 2024-10-30 21:43:46 +01:00
Abe Pazos
3ef46bcc4e Add kinect test 2024-09-13 18:12:52 +02:00
Abe Pazos
1384143d6f Update to Gradle 8.10 2024-09-13 18:11:46 +02:00
Abe Pazos
10ccb692c7 Update to Gradle 8.9 2024-08-12 19:29:46 +02:00
12 changed files with 365 additions and 428 deletions

View File

@@ -7,17 +7,24 @@ 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 the TemplateProgram (Use `gradlew.bat run` under Windows) - `./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 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 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
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`. See the [wiki](https://github.com/openrndr/openrndr-template/wiki)
## Updating OPENRNDR, ORX and other dependencies ## Updating OPENRNDR, ORX and other dependencies
@@ -26,10 +33,10 @@ provides the optional [orsl](https://github.com/openrndr/orsl/) shader helper mo
The version numbers of these dependencies are specified in your [libs.versions.toml](gradle/libs.versions.toml) file. 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. 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 Newer versions bring useful features and bug fixes. The most recent versions are<br>
<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/openrndr-math-jvm?label=OPENRNDR&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.extra/orx-noise-jvm?label=ORX&color=%23FFC0CB)
<br>![orsl version](https://maven-badges.herokuapp.com/maven-central/org.openrndr.orsl/orsl-shader-generator-jvm/badge.svg) for ORSL. ![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 versions manually 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:
@@ -42,18 +49,6 @@ You can add other dependencies needed by your project to your [build.gradle.kts]
⚠️ 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 various Github Actions under `./github/workflows`:
@@ -69,3 +64,10 @@ any time a commit is tagged with a version number like `v1.*`. For example, we c
``` ```
You can follow the progress of the action under the Actions tab in GitHub. Once complete, the executables will appear under the Releases section. You can follow the progress of the action under the Actions tab in GitHub. Once complete, the executables will appear 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,406 +1,31 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar group = property("project.group") ?: error("project.group not set")
import org.gradle.internal.os.OperatingSystem version = property("project.version") ?: error("project.version not set")
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 { 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) alias(libs.plugins.kotlin.serialization)
} id("conventions.kotlin-jvm")
id("conventions.openrndr-tasks")
repositories { id("conventions.distribute-application")
mavenCentral()
mavenLocal()
} }
dependencies { dependencies {
implementation(openrndr.application)
implementation(openrndr.draw)
runtimeOnly(openrndr.gl3)
// implementation(libs.jsoup) implementation(openrndr.dialogs)
// implementation(libs.csv) implementation(openrndr.orextensions)
/* 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(openrndr.ffmpeg)
implementation(orx.bundles.basic)
implementation(orx.olive)
implementation(libs.kotlinx.coroutines.core) implementation(libs.kotlinx.coroutines.core)
implementation(libs.kotlinx.serialization.core) implementation(libs.kotlinx.serialization.core)
implementation(libs.kotlinx.serialization.json) implementation(libs.kotlinx.serialization.json)
implementation(libs.slf4j.api) implementation(libs.slf4j.api)
implementation(libs.kotlin.logging) implementation(libs.kotlin.logging)
when (applicationLogging) { runtimeOnly(libs.bundles.logging.simple)
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) testImplementation(libs.junit)
} }
// ------------------------------------------------------------------------------------------------------------------ //
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()
)
}
}
}
}

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

@@ -0,0 +1,12 @@
plugins {
`kotlin-dsl`
}
val libs = extensions.getByType<VersionCatalogsExtension>().named("libs")
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())
}

View File

@@ -0,0 +1,39 @@
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

@@ -0,0 +1,73 @@
package conventions
import org.gradle.internal.os.OperatingSystem
import kotlin.collections.set
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
plugins {
id("com.gradleup.shadow")
id("org.beryx.runtime")
}
val applicationMainClass: String by properties
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<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)
}
}
}
register<Zip>("jpackageZip") {
archiveFileName = "openrndr-application.zip"
from("${layout.buildDirectory.get()}/jpackage") {
include("**/*")
}
dependsOn("jpackage")
}
}
runtime {
jpackage {
imageName = "openrndr-application"
skipInstaller = true
if (OperatingSystem.current().isMacOsX) {
jvmArgs.add("-XstartOnFirstThread")
jvmArgs.add("-Duser.dir=${"$"}APPDIR/../Resources")
}
}
options = listOf("--strip-debug", "--compress", "1", "--no-header-files", "--no-man-pages")
modules = listOf("jdk.unsupported", "java.management", "java.desktop")
}

View File

@@ -0,0 +1,71 @@
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

@@ -0,0 +1,42 @@
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

@@ -0,0 +1,37 @@
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,3 +1,7 @@
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

View File

@@ -1,20 +1,25 @@
[versions] [versions]
kotlin = "2.2.0" jvmTarget = "17"
openrndr = "0.4.5-alpha9" kotlin = "2.2.10"
orx = "0.4.5-alpha9" kotlinApi = "2.2"
kotlinLanguage = "2.2"
openrndr = "0.5.0-SNAPSHOT"
orx = "0.5.0-SNAPSHOT"
orsl = "0.4.5-alpha5" orsl = "0.4.5-alpha5"
orml = "0.4.1" orml = "0.4.1"
slf4j = "2.0.17" slf4j = "2.0.17"
log4j = "2.23.1" log4j = "2.23.1"
jackson = "2.17.2" jackson = "2.17.2"
junit = "4.13.2" junit = "4.13.2"
kotlinxCoroutines = "1.10.2" kotlinxCoroutines = "1.10.2"
kotlinxSerialization = "1.9.0" kotlinxSerialization = "1.9.0"
kotlinLogging = "7.0.10" kotlinLogging = "7.0.13"
kotlinCsvJvm = "1.9.3" kotlinCsvJvm = "1.9.3"
jsoup = "1.17.1" jsoup = "1.17.1"
shadow = "8.3.8" shadow = "9.1.0"
jpackage = "1.7.3" runtime = "1.13.1"
versions = "0.52.0" versions = "0.52.0"
[libraries] [libraries]
@@ -28,15 +33,10 @@ 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" }
orsl-shader-generator = { group = "org.openrndr.extra", name = "orsl-shader-generator", version.ref = "orsl" } shadow-gradle-plugin = { group = "com.gradleup.shadow", name = "com.gradleup.shadow.gradle.plugin", version.ref = "shadow" }
orsl-extension-color = { group = "org.openrndr.extra", name = "orsl-extension-color", version.ref = "orsl" } runtime-gradle-plugin = { group = "org.beryx.runtime", name = "org.beryx.runtime.gradle.plugin", version.ref = "runtime" }
orsl-extension-easing = { group = "org.openrndr.extra", name = "orsl-extension-easing", version.ref = "orsl" } kotlin-gradle-plugin = { group = "org.jetbrains.kotlin.jvm", name = "org.jetbrains.kotlin.jvm.gradle.plugin", version.ref = "kotlin" }
orsl-extension-gradient = { group = "org.openrndr.extra", name = "orsl-extension-gradient", version.ref = "orsl" } xversions-gradle-plugin = { group = "com.github.ben-manes.versions", name = "com.github.ben-manes.versions.gradle.plugin", version.ref = "versions" }
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.ref = "kotlinxCoroutines" } 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-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" } kotlinx-serialization-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-core", version.ref = "kotlinxSerialization" }
@@ -49,6 +49,11 @@ csv = { group = "com.github.doyaaaaaken", name = "kotlin-csv-jvm", version.ref =
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" } kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
shadow = { id = "com.gradleup.shadow", version.ref = "shadow" } shadow = { id = "com.gradleup.shadow", version.ref = "shadow" }
jpackage = { id = "org.panteleyev.jpackageplugin", version.ref = "jpackage"} runtime = { id = "org.beryx.runtime", version.ref = "runtime" }
gitarchive-tomarkdown = { id = "org.openrndr.extra.gitarchiver.tomarkdown", version.ref = "orx" } 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.ref = "versions" }
[bundles]
logging-none = ["slf4j-nop"]
logging-simple = ["slf4j-simple"]
loggin-full = ["log4j-slf4j2", "log4j-core", "jackson-databind", "jackson-json"]

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-9.0.0-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
networkTimeout=10000 networkTimeout=10000
validateDistributionUrl=true validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME

View File

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