Uploaded image for project: 'Maven JAR Plugin'
  1. Maven JAR Plugin
  2. MJAR-50

"Invalid Header" in jar's Manifest (Specification-Title attribute) when tab char in pom Description

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • 2.0
    • 2.2
    • None
    • None

    Description

      I typed a <description> element into my pom; the description spanned 2 lines, and my text editor put a tab char at the beginning of the 2nd line.
      The project built correctly, but another project depended on the resulting jar.
      The compilation of the depending project failed with "invalid header" on the jar I'd just compiled.

      When I looked at the jar's manifest, I saw the Specification-Title attribute had the tab character still in it from the <description> element.
      Replacing the tab with spaces in the pom solved the problem.
      However, this was valid xml that caused a compilation problem, so I think it's a minor bug with the jar production code.
      Note that the full description is trimmed before going into the manifest, so any

      Easy to work around, but it would be nice if whitespace in the <description> element were consolidated into spaces before copying to the manifest.
      Doesn't need any fancy layout stuff - just any multiple instances of tabs, spaces, lf or cr should be replaced by a single space.
      Try (I haven't tried to compile this!):

          public String consolidateWhitespace(String input){
              StringTokenizer st = new StringTokenizer(input);
              StringBuffer rv = new StringBuffer();
              while (st.hasMoreTokens()){
                  rv.append(st.nextToken() + (st.hasMoreTokens()?" ":""));
              }
              return rv.toString();
          }
      

      Attachments

        Activity

          People

            olamy Olivier Lamy
            mikelaurie Mike Laurie
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: