https://kotlinlang.org logo
#gradle
Title
c

Carter

07/18/2023, 9:25 PM
I noticed what might be a potential Kotlin bug. I’m building a list of file paths for a Gradle task, and it blows up when configuration cache is enabled while using
buildList
with this error.
Copy code
Could not load the value of field `collection` of `kotlin.collections.builders.SerializedCollection` bean found in input property `$1` of task
Using
mutableList<String>().apply {...}
or
buildList{...}.toList()
is a workaround. Based on the error message, it sounds like
buildList
yields a non-serializable list while
mutableList
yields a serializable list. I’m reproduced using Gradle 8.2.1 and Kotlin 1.9.0 with config cache enabled. (I know Gradle 8.2.1 is using Kotlin 1.8.20 for build scripts, but Kotlin 1.9.0 enabled me to turn config cache on.)
e

ephemient

07/18/2023, 9:37 PM
oh I see you mentioned Gradle 8.2.1 and Kotlin 1.9.0. you're not using Kotlin 1.9.0 inside of a Gradle plugin, right? the embedded Kotlin version is 1.8.20 and anything else in buildscript classpath can cause issues
c

Carter

07/18/2023, 10:27 PM
The Kotlin 1.9.0 gradle plugin is just visible so I can write convention plugins against it.
e

ephemient

07/18/2023, 10:39 PM
ok, then a binary convention plugin or a script plugin?
I'm not seeing an issue myself though
c

Carter

07/18/2023, 10:41 PM
My reproduction case is in a private project, however this open source project is set up almost identically https://github.com/zcash/kotlin-bip39/tree/main/build-conventions-bip39 except for using an older version of Gradle and Kotlin.
e

ephemient

07/18/2023, 10:42 PM
ah, writing script plugins that apply KGP is problematic
6 Views