Chris Overcash
04/24/2023, 2:15 PMdokkaPlugin
. here’s a stripped down version of my project `build.gradle.kts`:
buildscript {
repositories { maven(url = "<https://internalrepo.com>") }
dependencies {
classpath("org.jetbrains.dokka:dokka-base:1.8.10")
classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.8.10")
classpath("org.jetbrains.dokka:android-documentation-plugin:1.8.10")
}
}
allprojects {
repositories { maven(url = "<https://internalrepo.com>") }
apply(plugin = "org.jetbrains.dokka")
dependencies {
// unresolved reference
dokkaPlugin("org.jetbrains.dokka:android-documentation-plugin:1.8.10")
}
}
Chris Overcash
04/24/2023, 2:19 PMChris Overcash
04/24/2023, 2:22 PMJoffrey
04/25/2023, 12:03 PMapply
syntax, which probably is only necessary when using an allprojects
or subprojects
block. And those should be avoided in favor of convention pluginsJoffrey
04/25/2023, 12:04 PMChris Overcash
04/25/2023, 2:04 PMIgnat Beresnev
04/26/2023, 1:45 PMNow I have to say the examples have a lot of non-idiomatic Gradle in the first placeYeah, true... Problem is, Gradle has many ways to achieve the same thing, and asking people to migrate to convention plugins before they can add Dokka sounds a bit unfriendly to me... If you know how to work with Gradle and you have convention plugins already, you probably don't even need these examples and already know what to do These example projects and the documentation are primarily for small user projects and libraries that don't have complicated build logic and thus don't even use
buildSrc
or any other convoluted Gradle features - that's the majority, judging by my experience of looking at projects in which Dokka is used
But it's open source, so I'd be happy to discuss it if you could make the examples more idiomatic, while at the same time not complicating them too much 🙂
Or maybe we could retain these basic Gradle examples and state explicitly that they are for small and basic projects only, and also publish the most idiomatic Gradle example you could have - with convention plugins and so on, and link to it - for those who are willing to go the extra mile.Chris Overcash
04/26/2023, 2:06 PMallprojects
and subprojects
if that is a factor. if there’s something about my approach that is unidiomatic i’d be happy to learn!Ignat Beresnev
04/26/2023, 2:28 PMJoffrey
04/26/2023, 2:38 PMProblem is, Gradle has many ways to achieve the same thingI totally agree. I'm really not blaming the Dokka maintainers here, the Gradle docs are very unclear as to what is idiomatic or not, and they keep showing seemingly "deprecated" ways in their examples.
asking people to migrate to convention plugins before they can add Dokka sounds a bit unfriendly to meI disagree here. AFAIR, the examples using
allprojects
or subprojects
are about using Dokka in multi-project builds, and multi-project builds are already more complex. I guess I might just be placing the bar at a different position. I would consider using `allprojets`/`subprojects` a no-go (misleading towards bad practice), but suggesting to place a tiny convention plugin in buildSrc
would be acceptable for a simple multi-project setup. So I think it would not be unfriendly but rather helpful to show how people can simply add a little file like buildSrc/src/main/kotlin/dokka-config.gradle.kts
and show how to use it.
For example, here is what I did for the gradle-kotlin-publish-plugin
, which shows how to use a convention plugin to combine it with other plugins:
https://github.com/joffrey-bion/gradle-kotlin-publish-plugin#example-usage-for-maven-central-publicationJoffrey
04/26/2023, 2:57 PMIt's truly difficult to write beginner-friendly documentation for a Gradle plugin without having to explain Gradle concepts or sending the user to research a bunch of things on their own before they can use the productRight. As a Gradle plugin developer, you should just be expected to document the features of the plugin, not Gradle itself (and there's a fine line here I agree). But we're talking about an example project, in which you can just write something idiomatic if it's not unreasonably complex. Using non-idiomatic things for simplicity is exactly the mistake Gradle makes in their own doc
Adam S
04/26/2023, 3:19 PM@Deprecated
? A few sentences scattered around the Gradle docs doesn’t really cut it. It feels like a problem with the foundations.Joffrey
04/26/2023, 3:20 PMAdam S
04/26/2023, 3:21 PMIgnat Beresnev
04/26/2023, 3:46 PMI guess I might just be placing the bar at a different position.I think you are, yeah 😅 The most recently reported problem is the reporter trying to use Kotlin DSL in Groovy scripts, and there were a couple of issues where people didn't even understand to which files they should paste examples from the docs - that's the bar Dokka (as a fundamental tool) has to think about, unfortunately. I don't know if trying to explain idiomatic Gradle will do them any good 😄 The most frequent complaint about Dokka was the old documentation - it was a recurring topic of many UX researches. And if you look at the old docs, I don't think there was anything non-idiomatic. It explained the bare minimum and left the rest to the users, and if you know Gradle - you will certainly manage, no questions. But yeah, documentation was the biggest user problem... I also did a little experiment when writing the current docs, it was quite eye opening. I had an amazing Kotlin technical writer help me with proofreading the docs, and after staring at the same text for too long you kinda start losing track of things. So I asked her to take this simple multimodule project, take the documentation I wrote, and to do 3 things: 1. Add Dokka to that project and generate documentation 2. Configure Dokka and set
suppressObviousFunctions
to true
for all subprojects.
3. Set documentedVisibilities
configuration option to PUBLIC
and INTERNAL
for one of the subprojects only.
She got stuck and confused after doing the first thing 🙂 I think if you take an average junior/middle developer who doesn't care much for Gradle, you'll see the same result
After that, we added a much of (non-idiomatic) examples and details, and had to explain the difference between single project and multi project builds, and clarify where exactly people should apply what and how
I think the story is a bit different for plugins like detekt - there's no expectation for them to be beginner friendly. And if you need detekt, you are most likely skilled enough to figure it outIgnat Beresnev
04/26/2023, 3:49 PMdokkaHtml
vs dokkaHtmlMultiModule
and DokkaTask
vs DokkaTaskPartial
confusion like nowAdam S
04/26/2023, 3:50 PMAdam S
04/26/2023, 3:54 PMChris Overcash
04/26/2023, 3:57 PMIgnat Beresnev
04/26/2023, 4:02 PMit’s really interesting to read about that research, thanks Ignat(we're actually planning on doing another UX research for Dokka some time soon. People will be recruited and asked to complete a set of tasks, and then report on it. In our case, we'll pretty much ask them what I asked my colleague to do - add Dokka to a project and configure some things. Of course, it'd be ideal if we could do it with Dokkatoo after spending some time on designing the configuration DSL and addressing known configuration issues/confusions, but we'll see how it goes, maybe we'll do it twice. I'll try not to forget to share the findings)
Adam S
04/26/2023, 4:05 PMi’ve been using Gradle long enough that “idiomatic Gradle” seems like a paradox lol. i personally didn’t have much issue with the structure of it, and i am using@Chris Overcash In a nutshell, problem with `allprojects`/`subprojects` is that they make Gradle work like Maven. And that’s not to say that Maven is a problem, after all it’s a strong build tool too, but it’s not really the way Gradle is supposed to work. Eventually it makes the build config more complicated, and you’ll be missing out on features that make the build faster. The alternative toandallprojects
if that is a factor. if there’s something about my approach that is unidiomatic i’d be happy to learn!subprojects
allprojects
is convention plugins - try taking a look through my answer here. They are an investment, and Gradle is a complete nightmare 50% of the time, but it is really powerful.Chris Overcash
04/26/2023, 4:09 PM