[GRADLE-223] preserver order of custom manifest entries Created: 12/Sep/08  Updated: 04/Jan/13  Resolved: 24/Nov/10

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: 0.9-rc-1

Type: New Feature
Reporter: Johannes Zillmann Assignee: Hans Dockter
Resolution: Fixed Votes: 0


 Description   

a custom manifest specification:

  manifest.mainAttributes([ 
    'Implementation-Title': 'Katta', 
    'Implementation-Version': version, 
    'Compile-Time': new java.util.Date().toString(),
    'Compiled-By': System.getProperty("user.name"),
    'SVN-Revision': svnInfo.getRevision()+"",
    'SVN-URL': svnInfo.getUrl() +" -r "+svnInfo.getRevision()
    ]) 

got transformed into the following manfest:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.0
Created-By: 1.5.0_13-119 (Apple Inc.)
Compiled-By: jz
SVN-Revision: 199
Implementation-Title: Katta
Compile-Time: Fri Sep 12 16:42:51 CEST 2008
Implementation-Version: 1.0-SNAPSHOT
SVN-URL: https://katta.svn.sourceforge.net/svnroot/katta/trunk -r 199

Would be cool if the order could be preserved!



 Comments   
Comment by Jon Cox [ 23/Jan/09 ]

A nice touch.

For completeness sake, when I read this bug report I had to double-check
what the actual rule was for manifest files with respect to ordering.
While it's usually just cosmetic (not to denigrate 'just cosmetic'),
there's one case where it actually matters programatically.

According to http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html

  • Versions:
    Manifest-Version and Signature-Version must be first, and in exactly that case
    (so that they can be recognized easily as magic strings). Other than that, the order
    of attributes within a main section is not significant.
  • Ordering:
    The order of individual manifest entries is not significant.
    The order of individual signature entries is not significant, except that the digests that get signed are in that order.
Comment by Hans Dockter [ 26/Jan/09 ]

We use the java.util.jar.Manifest class. It is disappointing that they don't use a LinkedHashMap. That's all what would be needed. So to solve this, we have to write our own implementation of a Manifest class.

Generated at Wed Jun 30 11:24:44 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.