Skip to content

Regression: linking Java sources broken in 1.7.0 #2544

@DanySK

Description

@DanySK

Describe the bug

Dokka used to be able to link Java sources, see, e.g., https://alchemistsimulator.github.io/reference/kdoc/alchemist/it.unibo.alchemist.core.implementations/-engine/add-output-monitor.html

Since 1.7.0, dokkaHtmlCollector fails with textRange must not be null.

Expected behaviour

Dokka does not fail, the generated documentation links Java sources as it used to do in 1.6.x

To Reproduce

git clone https://github.com/AlchemistSimulator/Alchemist.git
cd Alchemist
git checkout renovate/dokka
./gradlew dokkaHtmlCollector

Dokka configuration
Configuration of dokka used to reproduce the bug

    tasks.withType<org.jetbrains.dokka.gradle.DokkaTask>().configureEach {
        dokkaSourceSets.configureEach {
            jdkVersion.set(multiJvm.jvmVersionForCompilation)
            listOf("kotlin", "java") // remove "java" from this list to "fix" the bug!
                .map { "src/main/$it" }
                .map { it to File(projectDir, it) }
                .toMap()
                .filterValues { it.exists() }
                .forEach { (path, file) ->
                    sourceLink {
                        localDirectory.set(file)
                        val project = if (project == rootProject) "" else project.name
                        val url = "https://github.com/AlchemistSimulator/Alchemist/blob/master/$project/$path"
                        remoteUrl.set(uri(url).toURL())
                        remoteLineSuffix.set("#L")
                    }
                }
            configurations.implementation.get().dependencies.forEach { dep ->
                val javadocIOURLs = fetchJavadocIOForDependency(dep)
                if (javadocIOURLs != null) {
                    val (javadoc, packageList) = javadocIOURLs
                    externalDocumentationLink {
                        url.set(javadoc)
                        packageListUrl.set(packageList)
                    }
                }
            }
        }
        failOnWarning.set(true)
    }

Note: removing "java" from the list above "fixes" the issue (it just turns off the source linking for Java sources).

Installation

Additional context

Mixed Java-Kotlin projects (originally in Java, new parts written in Kotlin, slowly transitating to Kt).

Are you willing to provide a PR?

I have no idea what to fix, I need guidance at the very least.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions