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 a resolution:=conditional directive for a more flexible and automated way of handling of package-imports based on the classpath #6465

Open
laeubi opened this issue Feb 13, 2025 · 1 comment

Comments

@laeubi
Copy link
Contributor

laeubi commented Feb 13, 2025

Currently one can use for Import-Package a resolution:=dynamic so an import becomes an DynamicImport-Package, beside that one can add resolution:=optional to make it an optional import.
And then there is also conditionalpackage to embed packages (and not import them at all).

What I'm sometimes missing when wrapping third party code (but it can be useful in other cases as well) is something I will call here resolution:=conditional (while maybe computed would also be suitable as a name) that can be used like this:

Import-Package: *;resolution:=conditional

and then behaves in the following way:

  1. Assume we have a package to be imported p
  2. If p is found on the classpath and the jar is an OSGi bundle then p should be imported as usual possibly with a version range
  3. If p is found on the classpath but the jar is not an OSGI bundle then p is considered an conditional package and embedded into the jar
  4. If p is not found on the classpath it is imported with resolution:=optional (e.g. might be some com.sun.* class from the jdk or whatever e.g. a prebuild jar is analyzed and some dependencies are not available at that time)

This would be especially useful for cases where one needs to wrap an existing jar but can't add metadata in the first place, or if metadata should be added but the authors of that jar do not care much about OSGi and are afraid of having to know/manage that stuff individually.

@chrisrueger
Copy link
Contributor

chrisrueger commented Feb 13, 2025

I tried googling and found this, which maybe sounds a bit related. There they use resolution:=dynamic.

resolution:=dynamic and resolution:=conditional (or resolution:= computed) all sound somehow "dynamic" :)

How do you think it compares to your suggestion?

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

No branches or pull requests

2 participants