Revisit Gradle Workers usage in Dokka Gradle Plugin
After the changes from #4182, it becomes unclear what the real benefits of using Gradle Workers are if we still need to do a lot of additional configuration and might even improve performance by using something similar to the KGP approach with ClassLoadersCachingBuildService.
More discussions on pros/cons: https://github.com/Kotlin/dokka/pull/4182#discussion_r2262973620
I discussed ClassLoadersCachingBuildService more with @abdulowork and he suggested Dokka avoids it, because re-using classloaders could interfere with Coroutines mechanisms (please correct me if I'm wrong @abdulowork!)
That aside, we should still look at whether DGP could not use the Worker API and instead always use a custom classloader.
Hopefully the memory leak in Gradle is fixed by https://github.com/gradle/gradle/pull/34963 and DGP can use classloader isolated workers as the default mode, and we don't have to manually implement workarounds.
@adam-enko, correct me if I'm wrong, but this will be fixed only for Gradle 9.3+, while DGP supports Gradle 7.6+. So I don't think that it will be enough for us to switch to ClassLoader isolation by default.
Additionally, as I recall, we will also need a fix for https://github.com/gradle/gradle/issues/34442 to use our own stdlib version.
correct me if I'm wrong, but this will be fixed only for Gradle 9.3+, while DGP supports Gradle 7.6+. So I don't think that it will be enough for us to switch to ClassLoader isolation by default.
Correct. But we could consider a conditional default. E.g. use process-isolated workers by default for older Gradle versions, and classpath-isolated for newer Gradles.
Additionally, as I recall, we will also need a fix for gradle/gradle#34442 to use our own stdlib version.
We'd need to workaround the kotlin-stdlib substitution for both process and classpath isolated workers.