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

Support downloading package list behind a proxy #3026

Open
hfhbd opened this issue Jun 1, 2023 · 3 comments
Open

Support downloading package list behind a proxy #3026

hfhbd opened this issue Jun 1, 2023 · 3 comments
Labels
configuration An issue/PR related to Dokka's configuration by the user enhancement An issue for a feature or an overall improvement

Comments

@hfhbd
Copy link
Contributor

hfhbd commented Jun 1, 2023

Is your feature request related to a problem? Please describe
I want to use dokka behind a proxy and create links to other docs, like stdlib. Currently, I get the error message:
Failed to download package-list from ..., this might suggest that the remote resource is not available, .... This message is technically correct.

Describe the solution you'd like
Best solution: Use native Gradle dependency resolution to fetch the package list file, because you already need to add the proxy settings to Gradle. This would also allow you to cache the files by default and fetch the files only once.

Describe alternatives you've considered
Keep the current code and add a proxy option. This option also downloads the file for each source set again without a cache.

Additional context

Are you willing to provide a PR?
With a start point, yes.

@hfhbd hfhbd added the enhancement An issue for a feature or an overall improvement label Jun 1, 2023
@aSemy
Copy link
Contributor

aSemy commented Jun 3, 2023

hey 👋

The package list is downloaded using java.net.URL

fun load(url: URL, jdkVersion: Int, offlineMode: Boolean = false): PackageList? {
if (offlineMode && url.protocol.toLowerCase() != "file")
return null
val packageListStream = runCatching { url.readContent() }.onFailure {
println("Failed to download package-list from $url, this might suggest that remote resource is not available," +
" module is empty or dokka output got corrupted")
return null
}.getOrThrow()

Have you tried setting -Djava.net.useSystemProxies=true, like described in this answer https://stackoverflow.com/a/18164472/4161471?

Alternatively you could use Gradle to download the package list file and pass it to packageListUrl

/**
* Specifies the exact location of a `package-list` instead of relying on Dokka
* automatically resolving it. Can also be a locally cached file to avoid network calls.
*
* Example:
*
* ```kotlin
* rootProject.projectDir.resolve("serialization.package.list").toURL()
* ```
*/
@Optional
@Input
val packageListUrl: Property<URL> = project.objects.property()

The use of URL is related to #2993

@IgnatBeresnev
Copy link
Member

Related issue: #2376

@IgnatBeresnev IgnatBeresnev added the configuration An issue/PR related to Dokka's configuration by the user label Jul 6, 2023
@hfhbd
Copy link
Contributor Author

hfhbd commented Jul 6, 2023

Another idea: Publish the package list as gradle artifact, or include it in the sources jar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
configuration An issue/PR related to Dokka's configuration by the user enhancement An issue for a feature or an overall improvement
Projects
None yet
Development

No branches or pull requests

3 participants