首页 文章

manifest.mf文件是否显示jar的版本?

提问于
浏览
1

简介

我已经创建了一个脚本,它循环通过我们的应用程序服务器上的所有已安装的应用程序,为每个找到WEB-INF / lib文件夹的应用程序 . 然后,对于lib文件夹中的所有第三方jar文件我extract the manifest-file找到Implementation-Version-key及其值,假设只有一个Implementation-Version pr . MANIFEST.MF . 到目前为止一切都那么好,但是......然后一些应用程序以某种方式依赖于XML,因此在lib文件夹中就像是一样

  • xalan.jar

  • xml-apis.jar

  • xerxesImpl.jar

这个问题

所以,然后关闭阅读Jar-file specification,我必须承认这一点并没有让我明白:我是否能够通过读取manifest.mf文件中的单个条目来找到jar文件的版本?

manifest.mf的示例

这是MANIFEST.MF内容的一部分,用于在其中一个应用程序中找到的xalan.jar文件 . 这表明很难编写一个应该能够知道所有jar文件版本的脚本 .

Manifest-Version: 1.0
Created-By: 1.3.1 (IBM Corporation)
Main-Class: org.apache.xalan.xslt.Process
Class-Path: xercesImpl.jar xml-apis.jar serializer.jar

Name: org/apache/xalan/
Comment: Main Xalan engine implementing TrAX/JAXP
Specification-Title: Java API for XML Processing
Specification-Vendor: Sun Microsystems Inc.
Specification-Version: 1.3
Implementation-Title: org.apache.xalan
Implementation-Version: 2.7.0
Implementation-Vendor: Apache Software Foundation
Implementation-URL: http://xml.apache.org/xalan-j/

Name: org/apache/xpath/
Comment: XPath engine
Implementation-Title: org.apache.xpath
Implementation-Version: 2.7.0
Implementation-Vendor: Apache Software Foundation
Implementation-URL: http://xml.apache.org/xalan-j/

Name: org/apache/xml/
Comment: DTM implementation and utilities
Implementation-Title: org.apache.xml
Implementation-Version: 2.7.0
Implementation-Vendor: Apache Software Foundation
Implementation-URL: http://xml.apache.org/xalan-j/

事后补充

但是 - 也许我应该创建一个"blacklist",其中jar被忽略,例如所有与XML相关的jar . 我发现这个链接Xerces and Xalan locations and versions,显示我无法通过查看manifest.mf文件找到xalan.jar的版本 . 相反,我需要获得Version-class的输出 .

1 回答

  • 1

    我是否能够通过读取manifest.mf文件中的单个条目来找到jar文件的版本?

    您“可能”能够找到那种版本号,但JAR文件中的版本号是可选的 . (实际上,即使是版本的概念也是“可选的” . 在Java中没有任何东西要求你对你的代码进行版本控制......虽然它无疑是一个好主意!)

    你的“事后想法”的想法当然看起来更简单,但你需要查看相关的规范来决定它是否需要工作 .

相关问题