Is kotlin multiplatform gradle plugin compatible w...
# gradle
a
Is kotlin multiplatform gradle plugin compatible with gradle's configuration cache?? See thread of logs after I enable CC
👀 1
Copy code
10 problems were found storing the configuration cache, 3 of which seem unique.
- Task `:commonizeNativeDistribution` of type `org.jetbrains.kotlin.gradle.targets.native.internal.NativeDistributionCommonizerTask`: cannot serialize object of type 'org.gradle.api.internal.project.DefaultProject', a subtype of 'org.gradle.api.Project', as these are not supported with the configuration cache.
  See <https://docs.gradle.org/7.5.1/userguide/configuration_cache.html#config_cache:requirements:disallowed_types>
- Task `:commonizeNativeDistribution` of type `org.jetbrains.kotlin.gradle.targets.native.internal.NativeDistributionCommonizerTask`: invocation of 'Task.project' at execution time is unsupported.
  See <https://docs.gradle.org/7.5.1/userguide/configuration_cache.html#config_cache:requirements:use_project_during_execution>
- Task `:koncurrent-later-core:linuxX64Test` of type `org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeHostTest`: invocation of 'Task.project' at execution time is unsupported.
  See <https://docs.gradle.org/7.5.1/userguide/configuration_cache.html#config_cache:requirements:use_project_during_execution>
c
Those tasks are not CC compatible.
a
and is there a way to skip caching just these tasks and cache those that can be cached??
c
i think the way the config cache works you have to cache everything or nothing, because you cache the whole config and every plugin contributes to it and uses it
that should lead to no errors but causes the configuration cache to be discarded if any such tasks are executed
a
I have noticed that it leads to no errors only if all the tasks in the task graph are CC compatible. But if an incompatible task is in the execution graph (i.e.
:commonizeNativeDistribution
), it does fail. gradle doesn't even just invalidate the cache. The builds end with a 'BUILD FAILED'
Is this not expected behavior @ephemient?
e
if the tasks are marked with
notCompatibleWithConfigurationCache
then it should not fail. if the tasks are not marked then it is expected that the build will fail.
a
I see, then I should assume that these tasks from the KGP are not marked with
notCompatibleWithConfigurationCache
c
Likely not, but you can set that on those tasks.
a
can I set them in my build script?
c
Yes
a
Can I get a help of its syntax please? even a link/snippet would do
e
you just have to configure the tasks
but as it discards the configuration cache, you're also not getting any benefits to enabling it anyway
it's most useful when used on uncommon tasks so that you can enable configuration caching by default without breaking rare workflows, but if it's on common tasks you might as well leave configuration cache off until they're fixed
a
I am mostly iterating on JVM tasks, I am already getting the benefits of CC (Huge Benefits by the way), so I think after configuration (haven't done them yet) I bet I will merit alot. The incompatible tasks seem to be heavily kotlin native related
e
well then just configure the tasks like
Copy code
tasks.withType<NativeDistributionCommonizerTask>().configureEach {
    notCompatibleWithConfigurationCache("<https://youtrack.jetbrains.com/issue/KT-49933>")
}
or whatever they are
a
gracious
m
Since no one mentioned it yet, I'm pasting the youtrack here for K/N https://youtrack.jetbrains.com/issue/KT-43293/Support-Gradle-configuration-caching-with-KotlinNative
Looks like it's getting some love in 1.8
e
the reason string in my code block above contains the active youtrack issue
m
Ah yes! sorry I missed that!
a
either way, these two issues are different but they do relate. thank you all for sharing. I have subscribe for both of them
185 Views