-
Notifications
You must be signed in to change notification settings - Fork 11
Support Optional Dependencies #2
Description
There are many situations where dependencies may be optional. For example, users may want to only download 1 database driver based on what's in the config.
Currently, this is not possible. If a dependency isn't in the libraries directory, it is downloaded again.
My proposition is to add another field to dependencies.json (and as such Artifact) - "optional": true/false.
The default value should be false. If a dependency is optional, it will only be downloaded on initial loading(or if required transitively).
How should this be implemented?
This idea raises a few complications as to the semantics of implementation:
- How do we ensure that optional dependencies are only downloaded once?
- If the dependency graph changes, how should this be handled?
- How should dependencies be specified as optional in the Gradle plugin?
- Hypothetically, if
Projectdepends optionally onsomeLibrary, how should dependency "ownership" be managed, if at all? - Should PDM be in charge of automatically deleting unused dependencies?
The obvious solution is some sort of storage in the PluginLibraries directory. This might look something like this:
"optionals": {
"someLibrary-version": {
"downloaded:" "timestamp-12349875187"
} //etc
}If an optional dependency is present in this file, PDM can assume that it has been downloaded, and will not redownload it if not present.
A method should likely be added to PluginDependencyManager to force download all dependencies, optional ones included.