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

Generated OSGi Metadata contains invalid Import-Package header #2941

Closed
ptziegler opened this issue Oct 20, 2023 · 8 comments
Closed

Generated OSGi Metadata contains invalid Import-Package header #2941

ptziegler opened this issue Oct 20, 2023 · 8 comments

Comments

@ptziegler
Copy link
Contributor

ptziegler commented Oct 20, 2023

I'm not sure if there is anything that can be done on the Tycho side or if this is a pure BND problem, but here it goes:

Our target platform definition contains following Maven dependency:

<dependency>
    <groupId>net.sf.jazzy</groupId>
    <artifactId>jazzy-core</artifactId>
    <version>0.5.2</version>
</dependency>

Given its age, this artifact doesn't contain any OSGi headers and is therefore rebundled by Tycho as part of the target resolution.
If I try to build our project with Tycho 4.0.3 (and also the nigthly build), it fails with the following error:

The default package '.' is not permitted by the Import-Package syntax.

Looking at the original jar, it seems like the maintainers have been very naughty and put classes inside the root folder, which seems to be confusing the BND tool.

image

I assume that in the generated Manfest, all exported packages are also added to the Import-Package header, regardless of whether those are valid or not.
Note that this problem also shows up in m2e, but only starting with 2.3.0

@laeubi
Copy link
Member

laeubi commented Oct 20, 2023

@ptziegler can you please open an issue here: https://github.com/bndtools/bnd/issues that BND is not trying to generate invalid Import-Package headers?

In the meanwhile I think you can fix this by providing custom BND instructions that don't export everything but only Export-Package: com.*

@laeubi
Copy link
Member

laeubi commented Oct 20, 2023

@ptziegler by they way you probably also want to create an issue for them to

  1. not use the default package
  2. add OSGi headers by default using bnd-process maven goal.

@ptziegler
Copy link
Contributor Author

@ptziegler can you please open an issue here: https://github.com/bndtools/bnd/issues that BND is not trying to generate invalid Import-Package headers?

bndtools/bnd#5830

In the meanwhile I think you can fix this by providing custom BND instructions that don't export everything but only Export-Package: com.*

Sadly not. Even if I manually set the imported/exported packages, the error still shows up. Which, from my perspective, doesn't make sense at all. :(

by they way you probably also want to create an issue for them to
not use the default package
add OSGi headers by default using bnd-process maven goal.

The first one sounds similar to the problem I'm facing right now. I also don't want to suddenly flood their issue tracker with problems, so let's wait and see what happens regarding the first one...

@laeubi
Copy link
Member

laeubi commented Oct 20, 2023

Sadly not. Even if I manually set the imported/exported packages, the error still shows up. Which, from my perspective, doesn't make sense at all.

If I must guess I think they are must have an import to their default package classes, so probably can you try using

Export-Package: com.*
Import-Package: !*
DynamicImport-Package: *

if that at least pass without an error?

@ptziegler
Copy link
Contributor Author

If I must guess I think they are must have an import to their default package classes, so probably can you try using

Export-Package: com.*
Import-Package: !*
DynamicImport-Package: *

if that at least pass without an error?

No, even with the following instructions, the error is still the same:

Bundle-Name: Bundle derived from maven artifact ${mvnGroupId}:${mvnArtifactId}:${mvnVersion}
version: ${version_cleanup;${mvnVersion}}
Bundle-SymbolicName: wrapped.${mvnGroupId}.${mvnArtifactId}
Bundle-Version: ${version}
Export-Package: com.*
Import-Package: !*
DynamicImport-Package: *

My guess is that there really is something going wrong inside BND, when it runs into such a weird jar.

@laeubi
Copy link
Member

laeubi commented Oct 20, 2023

Then I fear there is not much at Tycho/m2e side to workaround :-\

@ptziegler
Copy link
Contributor Author

No worries. I already appreciate the help you've offered.
As a workaround, we've taken the wrapped bundle and host it in our own repository. Meaning it's not an immediate issue, just something I'd like to resolve at some point in the future.

@ptziegler
Copy link
Contributor Author

@laeubi

The BND issue was closed as "not planned", but the suggested alternative worked like a charm:

-fixupmessages: The default package '.' is not permitted by the Import-Package syntax.

I think that this is such a minor edge case that adding this extra instruction is appropriate, meaning I don't think there is anything for Tycho to do.

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