I am trying to enable configuration cache in our p...
# apollo-kotlin
s
I am trying to enable configuration cache in our project, and through one of our discussions in here some time ago, I have this code https://github.com/HedvigInsurance/android/blob/e37734cb47bf26aa9e172a99adad5b7817[…]uild-logic/convention/src/main/kotlin/ApolloConventionPlugin.kt in a convention plugin we have to download both of our 2 schemas. Thing is, trying to run it now with configuration cache on, I get an error and I am trying to understand if it’s me who’s doing something wrong, or if there’s something that’s on apollo-kotlin side
Oh actually just running
./gradlew :apollo:giraffe:downloadGiraffeApolloSchemaFromIntrospection
which is the automatically generated task, I also get the error
Copy code
Configuration cache problems found in this build.

1 problem was found storing the configuration cache.
- Task `:apollo:giraffe:downloadGiraffeApolloSchemaFromIntrospection` of type `com.apollographql.apollo3.gradle.internal.ApolloDownloadSchemaTask`: 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/8.0.2/userguide/configuration_cache.html#config_cache:requirements:disallowed_types>
m
That's a bug. Can you open an issue?
s
Yes, I’ll make one asap. For now, I can make it run with --no-configuration-cache actually, so that’s good. Do you know if I can somehow embed that in the task itself too, or if it’s just gonna be on me to run it by passing the right flag, and also change how we call it from CI?
m
I think there's an API to mark a task as "not ready for CC"
let me check
Maybe this?
Copy code
tasks.named("downloadGiraffeApolloSchemaFromIntrospection") {
  notCompatibleWithConfigurationCache("<https://issue.link.here>")
}
?
s
Filed this for now, https://github.com/apollographql/apollo-kotlin/issues/4925 Now let me test your suggestion ^_^
Alright, yes this works! And for my specific case, since I was referencing more than one task, I had to do this basically
Copy code
tasks.register("downloadApolloSchemasFromIntrospection") {
  notCompatibleWithConfigurationCache("<https://github.com/apollographql/apollo-kotlin/issues/4925>")
  tasks.findByName("downloadGiraffeApolloSchemaFromIntrospection")?.let { downloadTask ->
    downloadTask.notCompatibleWithConfigurationCache("<https://github.com/apollographql/apollo-kotlin/issues/4925>")
    dependsOn(downloadTask)
  }
  tasks.findByName("downloadOctopusApolloSchemaFromIntrospection")?.let { downloadTask ->
    downloadTask.notCompatibleWithConfigurationCache("<https://github.com/apollographql/apollo-kotlin/issues/4925>")
    dependsOn(downloadTask)
  }
}
And it now runs without passing in the flag. Thanks a lot!
m
Sure thing, thanks for filing this!
s
Works even by just putting it directly in the download task itself, since my custom task doesn’t do anything to break this, since all it does is hook two download tasks together.
Copy code
tasks.withType<com.apollographql.apollo3.gradle.internal.ApolloDownloadSchemaTask>().configureEach {
  notCompatibleWithConfigurationCache("<https://github.com/apollographql/apollo-kotlin/issues/4925>")
}
Added that option in the issue too, in case someone else has the same issue hopefully it can help 😊
Closed down #4925 since your suggestion worked, turned out it was just me messing up myself, not your task 😅