-
-
Notifications
You must be signed in to change notification settings - Fork 305
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
Add multi-release processing support #5350
Conversation
1b203a5
to
00f2d33
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Putting release state in the Jar object is not a good idea. The -release
option seems also not proper since it causes a single manifest to be calculated based upon the value when you really need a supplement manifest for each release version and also the base manifest.
I think we need to think about the proper overall approach to building multi-release jars with Bnd before we add new code which may not be helpful.
Why not? it is a property of the jar
This is a different use-case, and it ist still possible to do so using multiple invocation of BND.
This code is helpful as it enables BND to correctly process a multi-release jar. Currently BND simply fails and/or produces wrong results. |
Would it not make sense to start by teaching bnd to read a multi-release bundle? At the moment there's no way to get the "effective manifest" for a given Java version, or to know which versions have custom code. This is important for indexing/resolving and baselining, and will lay some basic API that can be applied to bundle creation. We can also use the learning from this step to help guide the user usage pattern e.g.
It's not totally clear what the use case for the |
This PR actually do this, it "teaches" BND how to read resources for a given release, as I can "teach" javac to compile and process classpath entries for a given target release.
All this can be implemented on top of this change as it provides everything one needs (I even implemented parts of this but jsut dropped this to get a minimal change that could be accepted by bnd ...)
Sure why not, at the moment, this change at least allows:
Then maybe it would help to explain whats specifically unclear as I added some documentation it should be easy to ask more specific questions than "seems also not proper", for anyone compiling for different targets with the
Why should I'm not be able to use that? I can use that to:
See ClickHouse/clickhouse-java#1016 but that's just one example as other libs are using Multi-Release as well. |
Again - I think that we're starting too big with this change. I think we should start by making the Analyzer able to correctly read a multi-release bundle, finding the correct resources and returning the correct manifest information (specifically handling
Why is bnd looking at the content of your dependencies? Are you repackaging the Multi-Release dependency? If so your bundle is Multi-Release and the generated manifest would most likely be wrong. If you aren't repackaging the dependency then bnd should not need to read that jar file.
This is pre-judging the outcome of the discussions I outlined above. Is having multiple bnd files the right approach here? I'm not sure that it is. Is it necessary to add the
I'm all for a flag to enable the behaviour, I guess I'm not sure why the flag isn't Sorry if this sounds negative, as it absolutely isn't intended to be. I'm really excited that someone finally has the time and resource to get the ball rolling with Multi-Release. I've wanted to do it for quite a while. The main point that I'm trying to make is that Multi-Release has been a Java tooling disaster for quite a long time. I want what bnd does to be easy to use, and to make sense. That includes discussing and deciding stuff like:
It's a big important change and we need to make sure that we get the right result for users. That's why I'm keen for the non-contentious stuff (namely correctly reading a bundle that's already Multi-Release) to start first. If we can get the ball rolling in the right direction then I think the next steps will be a lot easier. |
This adds about 50 LOC (not counting documentation and test) so how "small" do you think such a change you describe here (with a much broader context) could become?
Because it analyzes the classpath ... bnd/biz.aQute.bndlib/src/aQute/bnd/osgi/Analyzer.java Lines 439 to 476 in 60392b5
.. and BND Analyzer plugins do this as well (e.g. JPMS)
BND seem to reads lot of context, e.g. packages, annotations present and so on from the classpath.
BND support this already, so what should be "judged" here? If later on one comes up with an approach that allows to use a single one, why not? That do not limit us here in any way.... for sure we can "think" and "discuss" another five years it just seems no one really cares enough to do so...
Why? I really would appreciate to discuss on real issues than on "feelings" as I have successfully be able to produce a result that looks correct. It produces a manifest that contains more than necessary, but I think we do not need to optimize for size at this stage ...
in contrast to what? How should BND know my desired target release otherwise?
This is done here and BND simply fails to understand this and instead complains that classes are on the wrong folder ;-)
The doc states that
So I can but any header in I want and it is still valid to do so, but OSGi will ignore them
Because for the moment I wanted to make it as simple / small as possible, if anyone thinks to turn it on/of by this header I'm happy to enhance the PR ...
Its fine as long as there is some path forward, but at the moment it feels a bit like we are searching reasons not to do it, in contrast to what do we need to make this happen ...
Yes that's for sure an issue, but it seems there are quite a few (and with Java faster evolving even becoming more) projects that mastering this and its a shame to tell them they can't use BND because MR is not supported. That's why I tried to take the opportunity of a real world example (that is clickhouse) that is open source (so everyone can take a look that this not just a theoretical use-case) to actually try if this can work. Of course this is not the solution that solves everything but at laest there is a way that could be used as a basis to improve MR support in BND that is:
Still I prefer smaller steps that can happen and do not solve *everything in contrast to something that solves *all but never happens...
So important for me would then who decides when so it does not end like #2227 where many things are discussed but then nothing happens at all (or at laest: someone from the outside can not see any progress for a long time).
Well since there is no tool to create one its unlikely one will build one and because there is no such artifact build we not start to develop the tool for creating one ;-)
This PR is the ball to get this rolling ... |
There's a difference between code size and the impact of the change. A 500 LOC change that did the "reading" part would be a much "smaller" change to the usage of bnd.
For this code to apply the jar is no longer a dependency, it's part of your bundle. This is why we need to teach bnd to read multi-release items first, then work out how users should generate multi-release manifests.
This is true, annotations/classes referenced inside the bundle are searched for so that version ranges (and other metadata) can be found. Bnd doesn't need to fully process (i.e. generate anything for) those jars though, just load any existing bundle manifests.
I really do want this to happen. I'm trying to tell you that I think the best way to get started is to get the read case working. It doesn't require any bnd instructions and is much more likely to get past the maintainers who are naturally wary of new user facing API (there have been plenty of screw-ups in the past). Once bnd can successfully read a MR bundle and tell you what the correct manifest is for a given Java version (and probably also the Java versions that have MR data) then we'll have a base to design the processing side in an issue, which is how this is normally done.
The reason that these issues stalled is simply that nobody has had the resource to make them happen. As a team the bnd maintainers are pretty good at responding to comments in issues, and suggesting improvements to things. What they normally lack is the time to implement stuff (unfortunately nobody is paid to maintain bnd). I'm really happy that you're here to pick up the ball, and I'll be doing my best to make sure this stuff gets merged, but the design matters, and right now there's been no consensus on the design.
There are some, but not many. The test jars will need to be hand-created, but this has always been the case for this sort of new feature in bnd. |
00f2d33
to
bfe1e83
Compare
@bjhargrave I have now moved the release flag processing entirely into the
My last approach was not introducing an instructions in the BND file, but then it was argued there must be one so it could be used out-of-the-box in all context, so this is rather confusing to me...
I'll add reading support as well ... but adding reading support without having a chance to use that information to create a correct jar seems a bit useless... That's why I came up with a |
The reading support is actually quite an important first step. For example reading support (but not generation support) is necessary for indexing and resolving to work properly with MR jars. For example Aries JAX-RS Whiteboard currently resolves incorrectly on Java 9+ as it has a different set of imported packages in This probably means enhancing the following enum members to know the appropriate version folder which applies to them.
I think my main concern with the proposed |
Can you give a link to the exact problematic dependency version?
It correctly processes the jar and produces one manifest for a particular release so I can pack it into a jar that then is recognized as a multi-release jar :-) |
The change was added in apache/aries-jax-rs-whiteboard@ce3e7bc and is present in org.apache.aries.jax.rs:org.apache.aries.jax.rs.whiteboard:2.0.1
Ok, so my understanding of this is that your start point is:
And that your desired end goal is that you have a working multi-release OSGi bundle, with the relevant manifests in the relevant places. If this interpretation is correct then my view is that the best user experience would be to set
in the project's bnd configuration and have bnd work out the rest in a single processing pass. It is possible for bnd to automatically identify the target versions based on the |
Yes this is correct, but ...
I'm also aiming at this case to be supported.
Yes I already outlined that in another thread, but was not sure if it is appropriate to always do that thus I though it might be better to only enable this in demand, but If you think it is fine, I can add support for automatic retrieval as well... |
I added read support for this but it seems the Analyzer actually don't care much about that as it only want to examine exports of its classpath items but the supplemental manifest only allows overriding |
bfe1e83
to
a1d6dce
Compare
The Aries JAX-RS case is unfortunately non trivial and is one that will require some sort of new instruction or attribute on an existing instruction. This is because the I would suggest that we start with the simpler (and more common) cases, where the Import-Package doesn’t need customising, or is customised the same way for all versions of the manifest. Once those are working we can work out the best way to configure “version specific” manifest generation instructions and also how to control pulling resources into version folders. |
This makes sense, most things shouldn’t care about multi-release. Those that do may want to ask for manifests and resources at specific versions. |
I think I can split the read-support in a separate PR, so if you think that is something that could be merged as a prerequisite, let me know and I'll open a PR for that.
That's something I have also thought about, but I fear this is not covered by the spec or do I miss that? I think this would require a change in the spec. |
I think that read support would be a good way to get this work started. Recognising a
It might. The core spec talks about the classpath in It may be as simple as saying that your DS components can’t be MR classes, at least until DS 1.next. |
a1d6dce
to
2f8635f
Compare
Currently bnd is not a capable of processing multi-release jars, this adds support of multi-release processing by a new directive -release where one can select what release version should be processed by bnd. Fixes bndtools#5346 Signed-off-by: Christoph Läubrich <laeubi@laeubi-soft.de>
2f8635f
to
e9e1618
Compare
Alright, I'll prepare a PR for this, so I think this one can be closed for now as low level release support seems not (yet) desired. |
Currently bnd is not a capable of processing multi-release jars, this
adds support of multi-release processing by a new directive -release
where one can select what release version should be processed by bnd.
Fixes #5346