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

Nice manifest writer #6323

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

chrisrueger
Copy link
Contributor

Closes #6321

Felix Bundle plugin has a niceManifest option that formats Manifest

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

We adapted this and use it as the new default.

This writes the manifest file with indention which is easier to read, while still considering the 72 chars limit per line. so technically still a valid manifest.

borrowed from https://github.com/apache/felix-dev/blob/master/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestWriter.java#L108 and https://github.com/apache/felix-dev/blob/master/utils/src/main/java/org/apache/felix/utils/manifest/Parser.java#L43

Signed-off-by: Christoph Rueger <[email protected]>
CorruptManifest > testCorruptJar() FAILED
    org.opentest4j.AssertionFailedError: expected: <. . > but was: <. .>
        at app//org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
        at app//org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
        at app//org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:197)
        at app//org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:182)
        at app//org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:177)
        at app//org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:1142)
        at app//test.CorruptManifest.testCorruptJar(CorruptManifest.java:59)

MultiReleaseTest > testBuild() FAILED
    org.opentest4j.AssertionFailedError:
    expected: ""
     but was: "Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=9))""
        at [email protected]/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at [email protected]/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
        at [email protected]/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at [email protected]/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
        at app//test.MultiReleaseTest.testBuild(MultiReleaseTest.java:96)

Signed-off-by: Christoph Rueger <[email protected]>

check null

Signed-off-by: Christoph Rueger <[email protected]>
Signed-off-by: Christoph Rueger <[email protected]>
that way 'nice' could be disabled by callers.

Signed-off-by: Christoph Rueger <[email protected]>
@chrisrueger chrisrueger marked this pull request as ready for review October 11, 2024 06:03
@pkriens
Copy link
Member

pkriens commented Oct 11, 2024

hmm. I'd like to suggest to do it differently.

In Analyzer::calcManifest we have the data in Parameters. Why not add an append method that takes a nice option? This will create an attribute in the manifest with newlines. Which is as far as I know allowed ... (might have to check this).

ManifestUtil::write then needs to account for newlines in the attribute value. it should then reset the limit and output an EOL. it should not put the newline itself in the manifest output.

The advantage is that:

  • having a formatted output in Parameters is useful in other contexts.
  • The change to ManifestUtil is
    • much smaller,
    • is arguably wrong by not handling newlines today
    • does not require semantic knowledge about the headers, knowledge that Analyzer is the owner of

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

Successfully merging this pull request may close these issues.

[bndlib] Provide a -nice option
2 participants