Make `DokkaBaseConfiguration.customAssets` lazy
BraisGabin opened this issue · comments
In my documentation I generate files automatically (I use https://github.com/cashapp/paparazzi). So my dokka task depend son the paparazzi task.
To avoid to list manually all the files that are there created I use customAssets = file("path/to/where/the/images/are").listFiles().asList()
. The problem is that file("path/to/where/the/images/are")
is not created until the paparazzi task is executed so listFiles()
return a null
and everything blows up.
It would be nice if DokkaBaseConfiguration.customAssets
would be a Property<List<String>>
. This way it could be evaluated in a lazy fashion when the task is going to be executed.
I don't see alternative in this case. For now I workaround it running paparazzi first and then execute the dokka one. But that breaks how gradle is meant to be used. And it is really easy to mess it up.
Also this change would be good for performance because there is not reason to evaluate things like file("path/to/where/the/images/are").listFiles().asList()
ahead of time. That will only makes the configuration of gradle slower. So, maybe the other values should be lazy too, but I don't have an use case for those other cases.
I found a better workaround. Don't use DokkaBaseConfiguration.customAssets
at all:
val renameFiles = tasks.register<Copy>("renameFiles") {
from("src/test/snapshots/DocumentationCreation/images/")
into(layout.buildDirectory.dir("dokka/html/images")) // This is ugly. I shouldn't hardcode this path
}
tasks.withType<DokkaTask>().configureEach {
dependsOn(renameFiles)
}
It is not perfect but at least it works good with gradle.