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

OSGi version range for Guava is too strict #1160

Closed
guw opened this issue Aug 31, 2023 · 4 comments
Closed

OSGi version range for Guava is too strict #1160

guw opened this issue Aug 31, 2023 · 4 comments

Comments

@guw
Copy link

guw commented Aug 31, 2023

In Eclipse we are moving away from having too strict version on package imports for Guava. It caused a quite a few issues over the years. It would be great if the OSGi metadata can be relaxed to only have a lower bound on the Guava package imports.

See eclipse-equinox/equinox#304 (comment) for more details.

@ben-manes
Copy link
Owner

I'm not really sure what to do here because this is automatically done by the bnd plugin.

There is common configuration like descriptions,

bundle {
properties = projectDescription.map {
mapOf("project.description" to it)
}
bnd(mapOf(
"Bundle-License" to "https://www.apache.org/licenses/LICENSE-2.0",
"Build-Jdk-Spec" to java.toolchain.languageVersion.get(),
"Implementation-Title" to project.description,
"Bundle-Description" to project.description,
"Implementation-Version" to version,
"-noextraheaders" to true,
"-reproducible" to true,
"-snapshot" to "SNAPSHOT"))
}

and project-specific like package exports,

tasks.jar {
bundle.bnd(mapOf(
"Bundle-SymbolicName" to "com.github.ben-manes.caffeine.guava",
"Import-Package" to listOf(
"com.google.common.cache",
"com.google.common.util.concurrent",
"com.github.benmanes.caffeine.cache",
"com.github.benmanes.caffeine.cache.stats").joinToString(","),
"Export-Package" to "com.github.benmanes.caffeine.guava",
"Automatic-Module-Name" to "com.github.benmanes.caffeine.guava"))
}

The plugin is the one setting the version based on the dependencies, e.g.

Export-Package: com.github.benmanes.caffeine.guava;uses:="com.github.b
 enmanes.caffeine.cache,com.google.common.cache";version="3.1.9"
Import-Package: com.google.common.cache;version="[32.1,33)",com.google
 .common.util.concurrent;version="[32.1,33)",com.github.benmanes.caffe
 ine.cache;version="[3.1,4)",com.github.benmanes.caffeine.cache.stats;
 version="[3.1,4)"

The closest I see their instruction -nodefaultversion to "not add a default version to exported packages when no version is present." I don't know if that's desired or if it would cause more pains?

This package could use a very old version of Guava, but I also think keeping the dependency up to date is worthwhile. I guess if we add the version tag ourselves then it won't be computed and we could use an old version as a minimum, like ;version=20.0. wdyt?

I am not very familiar with osgi and rely on bnd + pax-exam tests to be compliant. Therefore any changes here relies on experts as I'll be ignorant to whether a suggested change is good or bad, which makes me hesitant to muck around too much.

@HannesWell
Copy link

HannesWell commented Aug 31, 2023

I guess if we add the version tag ourselves then it won't be computed and we could use an old version as a minimum, like ;version=20.0. wdyt?

Yes that should work. Furthermore you don't have to list all packages you need explicitly. You could do something like:
com.google.common.*;version="20.0"
and the bnd-lib will compute the actually used bundles for you automatically.
To be sure I suggest you inspect the generated manifest from a local/CI build (at least that's what I'm usually doing in such cases).

ben-manes added a commit that referenced this issue Sep 5, 2023
The minimum version is the first Guava release with JPMS support by
including Automatic-Module-Name in the manifest.

Also removed workaround for ops4j/org.ops4j.pax.exam#1043
@guw
Copy link
Author

guw commented Apr 9, 2024

@ben-manes Any chance you can push a new release with the updated jars? We are being hit by the issue again (salesforce/bazel-vscode-java#109)

@ben-manes
Copy link
Owner

Released in 3.2.0 (sorry for the delay)

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

3 participants