[ 
https://issues.apache.org/jira/browse/BUILDR-524?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Hugues Malphettes updated BUILDR-524:
-------------------------------------

    Attachment: xsharpplugin.nuxeo-3.0.0-SNAPSHOT.jar

jar to reproduce the issue. It contains no proprietary information.
The workaroud to use buildr's MANIFEST parsing class is to use the helper:

# Parse the MANIFEST.MF entry of a ZIP (or JAR) file and return a new Manifest.
# we can't use the from_zip method in buildr-1.4.2 because it crashes
#when it reads the jar produced by maven.
# see BUILDR-524
def read_manifest_from_jar(jar_file)
  Zip::ZipInputStream::open(jar_file.to_s) { |io|
    while (entry = io.get_next_entry)
      if entry.name == 'META-INF/MANIFEST.MF'
        return ::Buildr::Packaging::Java::Manifest.parse io.read rescue 
::Buildr::Packaging::Java::Manifest.new
      end
    end
  }
  return ::Buildr::Packaging::Java::Manifest.new
end



> Reading the MANIFEST.MF: optimization and workaround for suspicious jars
> ------------------------------------------------------------------------
>
>                 Key: BUILDR-524
>                 URL: https://issues.apache.org/jira/browse/BUILDR-524
>             Project: Buildr
>          Issue Type: Improvement
>          Components: Core features
>    Affects Versions: 1.4.2
>            Reporter: Hugues Malphettes
>         Attachments: xsharpplugin.nuxeo-3.0.0-SNAPSHOT.jar
>
>
> When trying to read a jar's manifest with 
> ::Buildr::Packaging::Java::Manifest.from_zip
> We observed a crash "cant dup nilClass" line 1132 of zip.rb
> It turns out that the jar generated by maven-3-beta contains a suspicious 
> entry for the META-INF/maven folder.
> Opening this jar with kde's ark that entry's permissions is marked as 
> ?rwxrwxrwx
> Opening this jar with gnome's archive utility that entry has a transparent 
> blank icon and a size of 0 bytes: neither a file neither folder 
> Anyways, java is content and linux is happy unzipping this jar without 
> complains.
> A workaround to read the manifest of such jar is to use in 
> lib/buildr/java/packaging.rb around line 54:
> # :call-seq:
> #   from_zip(file) => manifest
> #
> # Parse the MANIFEST.MF entry of a ZIP (or JAR) file and return a new 
> Manifest.
> def from_zip(file)
>   Zip::ZipInputStream::open(file.to_s) { |io|
>     while (entry = io.get_next_entry)
>       if entry.name == 'META-INF/MANIFEST.MF'
>       return Manifest.parse io.read rescue Manifest.new
>       end
>     end
>   }
>   return Manifest.new
> #            Zip::ZipFile.open(file.to_s) do |zip|
> #              Manifest.parse zip.read('META-INF/MANIFEST.MF') rescue 
> Manifest.new
> #            end
> end
> This method stops as soon as it encounters the MANIFEST.MF hence avoiding all 
> possible following entries.
> It is a lot faster for a well formed jar where the MANIFEST is always the 
> first entry.
> Thanks

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to