pkl-gradle: cannot use pkldoc generator on package URIs #246

Closed
opened 2025-12-30 01:22:39 +01:00 by adam · 0 comments
Owner

Originally created by @bioball on GitHub (Nov 8, 2024).

This is a regression:

In the following:

pkl {
  pkldocGenerators {
    register("pkldoc") {
      sourceModules = listOf(uri("package://pkg.pkl-lang.org/pkl-pantry/pkl.toml@1.0.0"))
    }
  }
}

The implicit <taskName>GetImports task will attempt to analyze the imports of a package, which fails with:

* What went wrong:
Execution failed for task ':pkldocGatherImports'.
> –– Pkl Error ––
  Module URI `package://pkg.pkl-lang.org/pkl-pantry/pkl.toml@1.0.0` has invalid syntax.

The workaround for now is to set transitiveModules explicitly to something, which disables the GetImports task dependency.

pkl {
  pkldocGenerators {
    register("pkldoc") {
      sourceModules = listOf(uri("package://pkg.pkl-lang.org/pkl-pantry/pkl.toml@1.0.0"))
      transitiveModules = files("some_file.txt")
    }
  }
}

To fix this: we only need to analyze the imports of file: URIs. There is little chance that non-file URIs can import file URIs, because Pkl's default security manager disallows this.

Originally created by @bioball on GitHub (Nov 8, 2024). This is a regression: In the following: ```kt pkl { pkldocGenerators { register("pkldoc") { sourceModules = listOf(uri("package://pkg.pkl-lang.org/pkl-pantry/pkl.toml@1.0.0")) } } } ``` The implicit `<taskName>GetImports` task will attempt to analyze the imports of a package, which fails with: ``` * What went wrong: Execution failed for task ':pkldocGatherImports'. > –– Pkl Error –– Module URI `package://pkg.pkl-lang.org/pkl-pantry/pkl.toml@1.0.0` has invalid syntax. ``` The workaround for now is to set `transitiveModules` explicitly to something, which disables the `GetImports` task dependency. ```kt pkl { pkldocGenerators { register("pkldoc") { sourceModules = listOf(uri("package://pkg.pkl-lang.org/pkl-pantry/pkl.toml@1.0.0")) transitiveModules = files("some_file.txt") } } } ``` To fix this: we only need to analyze the imports of `file:` URIs. There is little chance that non-file URIs can import file URIs, because Pkl's default security manager disallows this.
adam added the bug label 2025-12-30 01:22:39 +01:00
adam closed this issue 2025-12-30 01:22:40 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#246