I have a problem with source sets when upgrading t...
# gradle
e
I have a problem with source sets when upgrading to kotlin 1.8.0. My problem shows up here: https://github.com/openrndr/openrndr/blob/master/openrndr-filter/build.gradle.kts . There is a gradle (buildSrc) task
embedShaders
that generates .kt files in
$buildDir/generated/shaderKotlin
m
That's the "compileKotlinMetadata" stuff, you can most likely ignore the error as it's only needed if you publish this as a library (I think?)
Do you have any HMPP flags active?
Copy code
kotlin.mpp.enableGranularSourceSetsMetadata=true
kotlin.native.enableDependencyPropagation=false
(not sure if there are relevant TBH but I've seen issues there in the past)
e
I publish this as a library, so that can't really be ignored I guess
what is HMPP? I can have a look at those settings
e
note that this has worked for at least 1.7.0, 1.7.10, 1.7.20. If I can find what has changed in 1.8.0 I may understand what is going on a bit better
m
Yea, I was looking at your repo, this might very well be a bug in 1.8.0. This is very weird
e
kotlin.mpp.enableCompatibilityMetadataVariant=true
was already the case for this project, adding the two other flags didn't change the outcome.
I couldn't find anything in the Kotlin 1.8.0 release notes that would affect this, so I may chalk this up to a bug too 🙂
m
Even without calling
srcDir()
looks like the issue is still there (ie putting generated shaders in
src/shaderKotlin/kotlin
)
Copy code
dependencies {
                implementation(project(":openrndr-draw"))
                api(shaderKotlin.kotlin)
            }
            dependsOn(shaderKotlin)
Why do you need
api(shaderKotlin.kotlin)
above?
Looks like this is redundant with
dependsOn(shaderKotlin)
?
e
honestly I am not sure. In my idea of this
dependsOn
controls task dependencies while the
api()
sets up the dependencies for the classpath.
m
In all cases, removing it doesn't seem to change anything...
e
may be that the dependsOn is redundant because
api()
depends on the output of a task?
t
Kotlin 1.8.0 has updated sourceSets and configuration names in MPP. Let me find the issue
ah, sorry, it was in 1.7.20. So no idea
please open a new YT issue
m
Note that a workaround seems to be to source your generated shaders from
commonMain
directly:
Copy code
diff --git a/openrndr-filter/build.gradle.kts b/openrndr-filter/build.gradle.kts
index 5f4c28e6..224c4c9c 100644
--- a/openrndr-filter/build.gradle.kts
+++ b/openrndr-filter/build.gradle.kts
@@ -13,17 +13,12 @@ val embedShaders = tasks.register<EmbedShadersTask>("embedShaders") {
 
 kotlin {
     sourceSets {
-        val shaderKotlin by creating {
-            this.kotlin.srcDir(embedShaders.outputDir)
-        }
-
         @Suppress("UNUSED_VARIABLE")
         val commonMain by getting {
             dependencies {
                 implementation(project(":openrndr-draw"))
-                api(shaderKotlin.kotlin)
             }
-            dependsOn(shaderKotlin)
+            kotlin.srcDir(embedShaders.outputDir)
         }
     }
 }
(still doesn't explain why it fails with different source sets so an issue would be nice still)
e
thank you! I don't mind creating a YT issue but I am a bit lost in describing the issue. I'd like to have some advice or tips there.
m
Put a link to your repo (use a permalink so that it stays valid a long time) and add reproducing steps: • change
kotlin = "1.7.21"
to
kotlin = "1.8.0"
in
gradle/libs.version.toml
• run
./gradlew openrndr-filter:compileKotlinMetadata
Copy paste the stacktrace
That should be enough
e
thank you @mbonnin!
m
Sure thing!
m
Can you add the stacktrace/error? It helps the casual viewer who is not going to checkout the reproducer repo
e
I edited the issue description to include the errors
m
Thanks!!!