what do I do wrong if I get `Unresolved link to ko...
# dokka
r
what do I do wrong if I get
Unresolved link to kotlin.text.isEmpty in doc comment
how can kotlin.text not be available?
k
I’m guessing you don’t have the stdlib in dokka classpath
r
is there an extra classpath for dokka?
k
Kind of, dokka has a configuration option called
classpath
which is used as classpath when generating documentation 😉
r
so if I have a multi-project situation, should I then add all jar to classpath or use
kotlinTasks
?
k
Well, it depends on the situation you have. Both approaches should work I think. You can also join them with `externalDocumentationLink`s
r
Do you have another pointer when dokka does not find symbols of java? like Optional or Path
k
Maybe bad
jdkVersion
?
I probably should clarify this, by
jdkVersion
I meant a configuration option in dokka called so. Optional was introduced in JDK8 and Path in JDK7 IIRC, dokka uses JDK6 as a default
r
Hm... I have to check. I think I use already jdkVersion=8
Unfortunately it is set to
jdkVersion = 8
k
That’s strange. Can you send me your project or a MRE?
r
https://github.com/robstoll/atrium see also the issue I just replied concerning source root
k
I suppose it’s also a classpath problem, since dokka cannot even resolve the type correctly, although I can’t currently give you a straightforward solution. Basically you should add classpath from Kotlin plugin, something like this:
Copy code
kotlin.targets.flatMap { it.compilations.getByName("main").compileDependencyFiles.files.map { file -> file.path } }
(or equivalent for Groovy), but this probably won’t work, because Gradle will complain about the lifecycle and dependency resolution. On the upside though, I see your problem with the dokka configuration for this Gradle project structure, I’ll try to introduce some options in the next release to make this kind of stuff easier to configure Sidenote: you can probably change all the
(docProjects - (docProjects - getAndroidProjects()))
to just
getAndroidProjects()
😉
r
Was a good hint, I used the following to achieve your intention:
Copy code
rootProject.configure(docProjects) { subProject ->
        subProject.afterEvaluate {
            classpath += subProject.sourceSets.main.runtimeClasspath.filter { it.path.endsWith("jar") }
        }
    }
But still not luck as the java jar is obviously not in the classpath of the project Btw. thanks for the side note but the reduction would be wrong as not all get...Projects() are necessarily part of the docProjects - but thanks anyway
oh wait, your example deals with the new MPP plugin and compilations, I have to figure out how that works with the old MPP plugin
well, well, also the following did not do the job, BigDecimal ist still not available
Copy code
rootProject.configure(docProjects) { subProject ->
    subProject.afterEvaluate {
        classpath += kotlin.target.compilations.getByName("main").compileDependencyFiles.files.collect { file -> file }
    }
}
Might it be that the problem is due to the fact that I use jvmTarget=1.6 (the default setting) to compile the project?
k
I don’t think that jvmTarget could cause this issue. I’m pretty sure I’ve seen a problem with unresolved classes like BigDecimal some time ago, but I don’t remember where and I don’t remember the fix unfortunately. Give me a few days please, I’ll get back to your project, I just need to fix one thing before the multiplatform release
r
Sure no stress and thanks
k
Right, so I’ve checked your snippet with classpath and it works for me (at least concerning Path and BigDecimal) Both are resolved and linked correctly to the JDK documentation. Could you show me the exact location where the BigDecimal is not available?
r
hm... it does not work for me (I think not in any place, I have checked the ones you showed). I get a lot of warnings in the output and the links are only pointing to the same page with an empty
#
Would you mind creating a PR or showing the full gh-pages.gradle?
k
r
hm... running your PR does not even create a page for isNumericallyEqualTo. A link to BigDecimal in other places is there though. Can you confirm this? Maybe the problem is linux related? I also get the problem of an empty index.html as described here: https://github.com/Kotlin/dokka/issues/496
k
It would be strange if the problem was platform dependent. I’ve checked and there’s bunch of
isNumericallyEqualTo
pages, eg. this: (although I don’t know why the declaration is duplicated there)
As for the empty index.html, I’ve confirmed it but I don’t know yet why it’s happening
r
do you also see it under ch.tutteli.atrium.api.fluent.en_GB?
k
Only as an extension
Screenshot 2019-09-09 at 16.35.45.png
r
alright, I guess this is the effect of using sourceRoot. other functions defined in common are not listed as extension of Expect but as functions in package ch.tutteli.atrium.api.fluent.en_GB. A bit confusing IMO
k
Yeah, it’s confusing. That’s probably an effect of both the sourceRoots and classpath parameters. I think this will look better and will be easier to configure with the multiplatform release, which should be there soon. We’re still waiting for the test results unfortunately
r
I see, I will no longer bother you then and wait for the release as well. In the meantime I will use a mixture of your hints which seems to work fairely well. Use classpath and sourceDirs but only for JVM projects. Thanks for your help.
k
No problem, here to help 😉