Support Gradle Configuration cache
Configuration cache is a new feature in Gradle that speeds up running repetitive tasks (during daily development) by storing the task graph on disk and loading it back. This requires certain actions from plugin authors to be compatible. For example not using specific types.
Describe the solution you'd like With dokka, the problem is
- Task `:checkstyle:dokkaJavadoc` of type `org.jetbrains.dokka.gradle.DokkaTask`: cannot serialize object of type 'org.gradle.api.internal.artifacts.configurations.DefaultConfiguration', a subtype of 'org.gradle.api.artifacts.Configuration', as these are not supported with the configuration cache.
See https://docs.gradle.org/7.3/userguide/configuration_cache.html#config_cache:requirements:disallowed_types
The solution to this is a bit of refactoring the task to use cacheable types. The first example in the docs might help.
Describe alternatives you've considered
@3flex tried https://github.com/Kotlin/dokka/pull/1800, but that probably needs more work.
Right now if developers / CI ever wants to execute Dokka, they have to disable configuration caching, e.g. with --no-configuration-cache.
Additional context Repro:
- Project with dokka configured on it
- Run dokka with
--configuration-cacheon gradlew command line
Are you willing to provide a PR? I don't have enough experience with this yet.
Is this a duplicate of #1217?
Looks like it, except the "consider" part ☺️.
For reference, here's what I had in Gradle 8.3, dokka 1.9.0
FAILURE: Build failed with an exception.
* What went wrong:
Configuration cache problems found in this build.
3 problems were found storing the configuration cache, 2 of which seem unique.
- Task `:components:dokkaHtml` of type `org.jetbrains.dokka.gradle.DokkaTask`: cannot serialize object of type 'org.gradle.api.internal.artifacts.configurations.DefaultConfiguration', a subtype of 'org.gradle.api.artifacts.Configuration', as these are not supported with the configuration cache.
See https://docs.gradle.org/8.3/userguide/configuration_cache.html#config_cache:requirements:disallowed_types
- Task `:components:dokkaHtml` of type `org.jetbrains.dokka.gradle.DokkaTask`: invocation of 'Task.project' at execution time is unsupported.
See https://docs.gradle.org/8.3/userguide/configuration_cache.html#config_cache:requirements:use_project_during_execution
See the complete report at file:///Users/brice.dutheil/opensource/intellij-platform-swing-components/build/reports/configuration-cache/oc9jqhodauovc9773iurqvxf/9fa5s0orualeswvhyudajg6d8/configuration-cache-report.html
> Invocation of 'Task.project' by task ':components:dokkaHtml' at execution time is unsupported.
As a workaround one can do the following :
tasks
+ withType<DokkaTask>().configureEach {
+ notCompatibleWithConfigurationCache("https://github.com/Kotlin/dokka/issues/2231")
+ }
}
This workaround won't be necessary on the next version as it will be automatically flagged as not compatible with CC (until it is fully supported):
- https://github.com/Kotlin/dokka/pull/3070
Is this not included in the latest release? I still get the error and have to use the workaround:
tasks.withType<DokkaTask>().configureEach {
notCompatibleWithConfigurationCache("https://github.com/Kotlin/dokka/issues/2231")
}
My config is essentially:
val dokkaHtml by tasks.getting(org.jetbrains.dokka.gradle.DokkaTask::class)
val javadocJar: TaskProvider<Jar> by tasks.registering(Jar::class) {
dependsOn(dokkaHtml)
archiveClassifier.set("javadoc")
from(dokkaHtml.outputDirectory)
}
Is this not included in the latest release? I still get the error and have to use the workaround:
tasks.withType<DokkaTask>().configureEach { notCompatibleWithConfigurationCache("https://github.com/Kotlin/dokka/issues/2231") }My config is essentially:
val dokkaHtml by tasks.getting(org.jetbrains.dokka.gradle.DokkaTask::class) val javadocJar: TaskProvider<Jar> by tasks.registering(Jar::class) { dependsOn(dokkaHtml) archiveClassifier.set("javadoc") from(dokkaHtml.outputDirectory) }
@CharlieTap Maybe ./gradlew --no-configuration-cache in command line?
Hi all, thanks for the feedback. Supporting Configuration Cache (and all other upcoming Gradle features) is important, so Dokka Gradle Plugin will support it in Dokka's 2.0 release.
We'll use #1217 to keep track of the request for CC support (simply because since it was made first).
Duplicate of #1217