Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to turn off fetching the packageListUrl from network #1764

Closed
harri35 opened this issue Mar 4, 2021 · 5 comments
Closed

Unable to turn off fetching the packageListUrl from network #1764

harri35 opened this issue Mar 4, 2021 · 5 comments
Labels
Milestone

Comments

@harri35
Copy link

harri35 commented Mar 4, 2021

Describe the bug
I have an Android library project with dokka plugin "org.jetbrains.dokka:dokka-gradle-plugin:1.4.20" and two separate tasks - one for library source and one for library source + tests.

I have a requirement that the project must be able to compile offline. For this we have a setup of a local maven repository that contains all the build script and compile dependencies. Also the ones that are needed for Dokka.

Everything else runs offline. But the dokka task every time fails with

* What went wrong:
Execution failed for task ':splitkey-service:dokkaHtml'.
> java.net.UnknownHostException: developer.android.com

I understand that this is because it tries to fetch the packageListUrl from online.
In order to avoid it I downloaded the package-list and added it locally:

externalDocumentationLink {
    url.set(URL("https://developer.android.com/reference/"))
    packageListUrl.set(URL("file:///${rootDir}/config/dokka-package-list/package-list"))
}

But this does not solve my issue, the build continues to fail.

What am I doing wrong?

Expected behaviour
Dokka is able to generate documentation without connecting to developer.android.com

To Reproduce

  1. Use dokka plugin "org.jetbrains.dokka:dokka-gradle-plugin:1.4.20" for a Java/Kotlin mixed Android library project
  2. Configure the dokka task as below
  3. Turn your system offline
  4. Run the task

Dokka configuration

// Main dokka task for Service
dokkaHtml.configure {
    dokkaSourceSets {
        named("main") {
            // Main source set conf
            outputDirectory.set(file(dokkaDocFilePath))
            includes.from(files("dokka_modules_main.md"))

            noJdkLink.set(true)
            noStdlibLink.set(true)
            noAndroidSdkLink.set(true)

            includeNonPublic.set(false)
            skipEmptyPackages.set(true)
            reportUndocumented.set(true)
            skipDeprecated.set(false)
            externalDocumentationLink {
                url.set(URL("https://developer.android.com/reference/"))
                packageListUrl.set(URL("file:///${rootDir}/config/dokka-package-list/package-list"))
            }
        }
    }
}

// Dokka task for Service tests
task dokkaHtmlTests(type: org.jetbrains.dokka.gradle.DokkaTask) {
    dokkaSourceSets {
        named("main") {
            outputDirectory.set(file(dokkaDocTestsFilePath))
            includes.from(files("dokka_modules_main.md", "dokka_modules_test.md"))
            sourceRoots.setFrom(file("src/main/java"))
            sourceRoots.from(file("src/androidTest/java"))

            noJdkLink.set(true)
            noStdlibLink.set(true)
            noAndroidSdkLink.set(true)

            includeNonPublic.set(true)
            skipEmptyPackages.set(true)
            reportUndocumented.set(true)
            skipDeprecated.set(false)

            externalDocumentationLink {
                url.set(URL("https://developer.android.com/reference/"))
                packageListUrl.set(URL("file:///${rootDir}/config/dokka-package-list/package-list"))
            }
        }
    }
}
}

Installation

  • Operating system: Windows
  • Build tool: Gradle 6.7.1
  • Dokka version: 1.4.20
@harri35 harri35 added the bug label Mar 4, 2021
@harri35
Copy link
Author

harri35 commented Mar 4, 2021

Followup:

I can't find this from anywhere in the documentation, but if I add

...
offlineMode.set(true)
...

then Dokka works offline perfectly.

So the full task in reference to the one in the initial post:

// Main dokka task for Service
dokkaHtml.configure {
    dokkaSourceSets {
        named("main") {
            // Main source set conf
            outputDirectory.set(file(dokkaDocFilePath))
            includes.from(files("dokka_modules_main.md"))

            // We need to run this in offline mode. We can't go fetching things from developer.android.com
            offlineMode.set(true)
            noJdkLink.set(false)
            noStdlibLink.set(false)
            noAndroidSdkLink.set(false)

            includeNonPublic.set(false)
            skipEmptyPackages.set(true)
            reportUndocumented.set(true)
            skipDeprecated.set(false)
            externalDocumentationLink {
                url.set(URL("https://developer.android.com/reference/"))
                // We need to run this in offline mode. We can't go fetching things from developer.android.com
                packageListUrl.set(URL("file:///${rootDir}/config/dokka-package-list/package-list"))
            }
        }
    }
}

@harri35
Copy link
Author

harri35 commented Mar 4, 2021

If this is the expected behaviour then could you please document this somewhere in the Gradle plugin documentation? Currently, the offline mode is only mentioned on the CLI config.

@kamildoleglo
Copy link
Contributor

That's strange actually. Are you sure this configuration is executed and you have no other source sets that Dokka might document? Turning off those links and adding a local one should be enough, offlineMode is more like a kill switch. Documented that in the Gradle plugin configuration nevertheless, thanks!

@MarcinAman MarcinAman added this to the Stable milestone Apr 26, 2021
@tprochazka
Copy link

This is a related (not the same) issue
#1706

@vmishenev
Copy link
Member

Currently, this is documented.

    // Used to prevent resolving package-lists online. When this option is set to true, only local files are resolved  
    offlineMode.set(false)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants