Skip to content

Commit

Permalink
Upgrade to Gradle 8.10, Kotlin 2.0.20, reduce warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
edwinRNDR committed Aug 25, 2024
1 parent 5b6f2ec commit 8a4a85d
Show file tree
Hide file tree
Showing 37 changed files with 133 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import org.gradle.accessors.dm.LibrariesForLibs
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

val libs = the<LibrariesForLibs>()

Expand All @@ -22,8 +24,6 @@ if (shouldPublish) {
apply(plugin = "maven-publish")
}

//apply(plugin = "nebula.release")

repositories {
mavenCentral()
mavenLocal()
Expand Down Expand Up @@ -57,8 +57,6 @@ dependencies {
"demoRuntimeOnly"(libs.slf4j.simple)
}



tasks {
@Suppress("UNUSED_VARIABLE")
val test by getting(Test::class) {
Expand All @@ -76,12 +74,14 @@ tasks {
addBooleanOption("Xdoclint:none", true)
}
}
withType<KotlinCompile>() {
kotlinOptions.jvmTarget = libs.versions.jvmTarget.get()
kotlinOptions.apiVersion = libs.versions.kotlinApi.get()
kotlinOptions.languageVersion = libs.versions.kotlinLanguage.get()
kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes"
kotlinOptions.freeCompilerArgs += "-Xjdk-release=${libs.versions.jvmTarget.get()}"
withType<KotlinCompile> {
compilerOptions {
jvmTarget.set(JvmTarget.valueOf("JVM_${libs.versions.jvmTarget.get()}"))
freeCompilerArgs.add("-Xexpect-actual-classes")
freeCompilerArgs.add("-Xjdk-release=${libs.versions.jvmTarget.get()}")
apiVersion.set(KotlinVersion.valueOf("KOTLIN_${libs.versions.kotlinApi.get().replace(".", "_")}"))
languageVersion.set(KotlinVersion.valueOf("KOTLIN_${libs.versions.kotlinApi.get().replace(".", "_")}"))
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import CollectScreenshotsTask
import org.gradle.accessors.dm.LibrariesForLibs
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile


val libs = the<LibrariesForLibs>()

val shouldPublish = project.name !in setOf("openrndr-demos")
Expand All @@ -31,22 +32,26 @@ repositories {

group = "org.openrndr.extra"

tasks.withType<KotlinCompile<*>> {
kotlinOptions.apiVersion = libs.versions.kotlinApi.get()
kotlinOptions.languageVersion = libs.versions.kotlinLanguage.get()
kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes"
kotlinOptions.freeCompilerArgs += "-Xjdk-release=${libs.versions.jvmTarget.get()}"
tasks.withType<KotlinCompilationTask<*>> {
compilerOptions {
apiVersion.set(KotlinVersion.valueOf("KOTLIN_${libs.versions.kotlinApi.get().replace(".", "_")}"))
languageVersion.set(KotlinVersion.valueOf("KOTLIN_${libs.versions.kotlinApi.get().replace(".", "_")}"))
freeCompilerArgs.add("-Xexpect-actual-classes")
}
}

tasks.withType<KotlinJvmCompile>().configureEach {
compilerOptions.jvmTarget.set(JvmTarget.fromTarget(libs.versions.jvmTarget.get()))
compilerOptions {
jvmTarget.set(JvmTarget.fromTarget(libs.versions.jvmTarget.get()))
freeCompilerArgs.add("-Xjdk-release=${libs.versions.jvmTarget.get()}")
}
}

kotlin {
jvm {
compilations {
val main by getting

@Suppress("UNUSED_VARIABLE")
val demo by creating {
associateWith(main)
tasks.register<CollectScreenshotsTask>("collectScreenshots") {
Expand Down Expand Up @@ -74,30 +79,26 @@ kotlin {
}

sourceSets {
@Suppress("UNUSED_VARIABLE")
val commonMain by getting {
dependencies {
implementation(libs.kotlin.stdlib)
implementation(libs.kotlin.logging)
}
}

@Suppress("UNUSED_VARIABLE")
val commonTest by getting {
dependencies {
implementation(libs.kotlin.test)
}
}

@Suppress("UNUSED_VARIABLE")
val jvmTest by getting {
dependencies {
runtimeOnly(libs.bundles.jupiter)
runtimeOnly(libs.slf4j.simple)
}
}

@Suppress("UNUSED_VARIABLE")
val jvmDemo by getting {
dependencies {
implementation(libs.openrndr.application)
Expand Down Expand Up @@ -181,6 +182,7 @@ if (shouldPublish) {
}

kotlin {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
jvm().mainRun {
classpath(kotlin.jvm().compilations.getByName("demo").output.allOutputs)
classpath(kotlin.jvm().compilations.getByName("demo").configurations.runtimeDependencyConfiguration!!)
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]
kotlinApi = "2.0"
kotlinLanguage = "2.0"
kotlin = "2.0.10"
kotlin = "2.0.20"
jvmTarget = "17"
openrndr = { require = "[0.4.2, 0.5.0)" }
kotlinxCoroutines = "1.8.1"
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down
10 changes: 4 additions & 6 deletions openrndr-demos/src/demo/kotlin/DemoImageLoadStore01.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ fun main() = application {
program {

val shader = Shader.createFromCode(vsCode =
"""
#version 430
"""${Driver.instance.shaderConfiguration()}
in vec3 a_position;
in vec2 a_texCoord0;
in vec3 a_normal;
Expand All @@ -22,16 +21,15 @@ void main() {
gl_Position = projMatrix * vec4(a_position, 1.0);
}
""",
fsCode = """
#version 430
fsCode = """${Driver.instance.shaderConfiguration()}
out vec4 o_color;
layout(rgba8) uniform image2D bla;
layout(rgba8) uniform writeonly image2D bla;
void main() {
imageStore(bla, ivec2(30,30), vec4(1.0, 0.0, 0.0, 1.0));
o_color = vec4(1.0);
}
""", name = "ils")
val cb = colorBuffer(128, 128)
val cb = colorBuffer(128, 128, type = ColorType.UINT8)
val mesh = planeMesh(Vector3.ZERO, Vector3.UNIT_X, Vector3.UNIT_Y, -Vector3.UNIT_Z, 100.0, 100.0)

extend {
Expand Down
22 changes: 11 additions & 11 deletions openrndr-demos/src/demo/kotlin/DemoImageLoadStore02.kt
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.ImageAccess
import org.openrndr.draw.colorBuffer
import org.openrndr.draw.imageBinding
import org.openrndr.draw.shadeStyle
import org.openrndr.draw.*


fun main() = application {
program {
val cb = colorBuffer(128, 128)
extend {
val ss = shadeStyle {
fragmentTransform = """
imageStore(p_image, ivec2(30.0, 30.0), vec4(1.0, 0.0, 0.0, 1.0));
val cb = colorBuffer(128, 128, type = ColorType.UINT8)
cb.fill(ColorRGBa.BLACK)
val ss = shadeStyle {
fragmentTransform = """
imageStore(p_image, ivec2(30, 30), vec4(1.0, 0.0, 0.0, 1.0));
""".trimIndent()

parameter("image", cb.imageBinding(0, ImageAccess.READ_WRITE))
}
image("image", cb.imageBinding(0, ImageAccess.WRITE))
}
extend {

drawer.shadeStyle = ss
drawer.clear(ColorRGBa.PINK)
drawer.rectangle(0.0, 0.0, 100.0, 100.0)
drawer.shadeStyle = null
drawer.image(cb, 0.0, 200.0)
}
}
Expand Down
7 changes: 2 additions & 5 deletions openrndr-demos/src/demo/kotlin/DemoVolumeTexture01.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.VolumeTexture
import org.openrndr.draw.colorBuffer
import org.openrndr.draw.isolatedWithTarget
import org.openrndr.draw.renderTarget
import org.openrndr.draw.*

fun main() = application {
program {
val volumeTexture = VolumeTexture.create(128,128,32)
val volumeTexture = VolumeTexture.create(128,128,32, type = ColorType.UINT8)
val rt = renderTarget(128, 128) {
volumeTexture(volumeTexture, 0)
}
Expand Down
2 changes: 2 additions & 0 deletions orx-camera/src/commonMain/kotlin/ParametricOrbital.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("RUNTIME_ANNOTATION_NOT_SUPPORTED")

package org.openrndr.extra.camera

import org.openrndr.Extension
Expand Down
2 changes: 2 additions & 0 deletions orx-compositor/src/commonMain/kotlin/Compositor.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("RUNTIME_ANNOTATION_NOT_SUPPORTED")

package org.openrndr.extra.compositor

import org.openrndr.Extension
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ internal fun vec2(x: Any): Vector2 {
is List<*> -> {
when (x.size) {
2 -> {
@Suppress("UNCHECKED_CAST")
x as List<Double>; Vector2(x[0], x[1])
}

Expand Down Expand Up @@ -172,6 +173,7 @@ internal fun translate(translation: Any): Matrix44 {
internal fun mat4(x: Any): Matrix44 {
return when (x) {
is List<*> -> {
@Suppress("UNCHECKED_CAST")
when (x.size) {
16 -> Matrix44.fromDoubleArray((x as List<Double>).toDoubleArray())
4 -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,44 @@ internal fun List<*>.memberFunctions(n: String): ((Array<Any>) -> Any)? {
"drop" -> { n -> this.drop((n[0] as Number).toInt()) }
"takeLast" -> { n -> this.takeLast((n[0] as Number).toInt()) }
"dropLast" -> { n -> this.takeLast((n[0] as Number).toInt()) }
"map" -> { n -> val lambda = (n[0] as (Any) -> Any); this.map { lambda(it!!) } }
"map" -> { n -> @Suppress("UNCHECKED_CAST") val lambda = (n[0] as (Any) -> Any); this.map { lambda(it!!) } }
"filter" -> { n ->
val lambda = (n[0] as (Any) -> Any); this.filter { (lambda(it!!) as Double).roundToInt() != 0 }
}

"max" -> { n -> (this as List<Comparable<Any>>).max() }
"min" -> { n -> (this as List<Comparable<Any>>).min() }
"max" -> { n ->
@Suppress("UNCHECKED_CAST")
(this as List<Comparable<Any>>).max()
}
"min" -> { n ->
@Suppress("UNCHECKED_CAST")
(this as List<Comparable<Any>>).min()
}
"maxBy" -> { n ->
val lambda = (n[0] as (Any) -> Any); this.maxByOrNull { lambda(it!!) as Comparable<Any> } ?: error("no max")
@Suppress("UNCHECKED_CAST") val lambda = (n[0] as (Any) -> Any); this.maxByOrNull { lambda(it!!) as Comparable<Any> } ?: error("no max")
}

"minBy" -> { n ->
val lambda = (n[0] as (Any) -> Any); this.minByOrNull { lambda(it!!) as Comparable<Any> } ?: error("no max")
@Suppress("UNCHECKED_CAST") val lambda = (n[0] as (Any) -> Any); this.minByOrNull { lambda(it!!) as Comparable<Any> } ?: error("no max")
}

"sorted" -> { n -> (this as List<Comparable<Any>>).sorted() }
"sorted" -> { n ->
@Suppress("UNCHECKED_CAST")
(this as List<Comparable<Any>>).sorted()
}
"sortedBy" -> { n ->
val lambda = (n[0] as (Any) -> Any); this.sortedBy { lambda(it!!) as Comparable<Any> }
@Suppress("UNCHECKED_CAST") val lambda = (n[0] as (Any) -> Any); this.sortedBy { lambda(it!!) as Comparable<Any> }
}

"sortedByDescending" -> { n ->
val lambda = (n[0] as (Any) -> Any); this.sortedByDescending { lambda(it!!) as Comparable<Any> }
@Suppress("UNCHECKED_CAST") val lambda = (n[0] as (Any) -> Any); this.sortedByDescending { lambda(it!!) as Comparable<Any> }
}

"reversed" -> { n -> this.reversed() }
"zip" -> { n -> this.zip(n[0] as List<Any>).map { listOf(it.first, it.second) } }
"zip" -> { n ->
@Suppress("UNCHECKED_CAST")
this.zip(n[0] as List<Any>).map { listOf(it.first, it.second) }
}

else -> null
}
Expand Down
Loading

0 comments on commit 8a4a85d

Please sign in to comment.