bnd icon indicating copy to clipboard operation
bnd copied to clipboard

[bndlib] Provide a `-nice` option

Open laeubi opened this issue 1 year ago • 9 comments

Felix Bundle plugin has a niceManifest option that formats Manifest

Output a nicely formatted manifest that still respects the 72 character line limit.

It would be good if bnd offers a -nice option as well, as manifest are sometimes inspected on raw text editors as well, used in debug outputs and so on. If bndlib offer the code, felix can even migrate to that code to reduce duplication of such efforts.

laeubi avatar Oct 10 '24 07:10 laeubi

-prettyprint

stbischof avatar Oct 10 '24 08:10 stbischof

bnd cli already has print command (via JarPrinter.java which is also used in the print view of the JarViewer), but after reading your sentence again, I don't think it respects the 72 character limit.

But we could try to integrate it. I think in bnd the manifest writing part is in https://github.com/bndtools/bnd/blob/master/aQute.libg/src/aQute/lib/manifest/ManifestUtil.java

chrisrueger avatar Oct 10 '24 08:10 chrisrueger

@chrisrueger the Jar printer prints something completely different that is not usable as a Manifest file as far as I see.

The option in maven-bunlde plugin produces something that is used as the manifest actually located inside the jar itself.

laeubi avatar Oct 10 '24 08:10 laeubi

I updated my comment.

we could try to integrate it. I think in bnd the manifest writing part is in https://github.com/bndtools/bnd/blob/master/aQute.libg/src/aQute/lib/manifest/ManifestUtil.java

and hook in https://github.com/bndtools/bnd/blob/master/biz.aQute.bndlib/src/aQute/bnd/osgi/Builder.java#L366 to read a new "-nice" / "prettyprintManifest" instruction

String nice = getProperty(NICE);

and pass it along. Should be doable.

Could you contribute the addition to ManifestUtil so that it can do what Felix ManifestWriter does?

I can help out with the rest. I just added a new instruction in another PR so I have touched some relevant places.

chrisrueger avatar Oct 10 '24 09:10 chrisrueger

@pkriens if you don't have any objections in general, you can assign this to me.

chrisrueger avatar Oct 10 '24 15:10 chrisrueger

Why not make it the standard? No option? They are functionally the same manifests and it only adds a few more characters.

pkriens avatar Oct 10 '24 15:10 pkriens

Why not make it the standard? No option? They are functionally the same manifests and it only adds a few more characters.

Can I then have an "ugly" option? sorry couldn't resist 🤣

chrisrueger avatar Oct 10 '24 16:10 chrisrueger

Yeah, that would work :-)

The only problem might be test case ... We are actually looking at the manifest in some places I think.

pkriens avatar Oct 11 '24 08:10 pkriens

The only problem might be test case ... We are actually looking at the manifest in some places I think.

There were indeed two testcases in bnd which failed after I added the nice-writer from felix. I fixed them in commit https://github.com/bndtools/bnd/pull/6323/commits/0503ff76aefc63a909e6e47847acc16e374a727b of PR https://github.com/bndtools/bnd/pull/6323/files

chrisrueger avatar Oct 11 '24 12:10 chrisrueger

@chrisrueger can this be closed?

pkriens avatar Nov 04 '24 13:11 pkriens

@chrisrueger can this be closed?

I won't have the time right now to work on it. There is still your suggestion in closed PR https://github.com/bndtools/bnd/pull/6323#issuecomment-2407597883 So maybe somebody can take this over in the future. Yes, so let's close it (for now, if you want to keep the issue list small)

chrisrueger avatar Nov 04 '24 13:11 chrisrueger