はじめに
アプリケーションサーバーにインストールされているすべてのアプリケーションをループするスクリプトを作成し、アプリケーションごとに WEB-INF/lib-folder を見つけます。次に、lib-folder 内のすべてのサード パーティの jar ファイルについて、マニフェスト ファイルを抽出して、Implementation - Version pr. マニフェスト.mf。これまでのところは問題ありませんが、一部のアプリケーションは何らかの形で XML に依存しているため、lib フォルダーに次のような jar が含まれています。
- xalan.jar
- xml-apis.jar
- xerxesImpl.jar
質問
それでは、Jar ファイルの仕様を読んでもはっきりとはわかりません。manifest.mf ファイルの 1 つのエントリを読むだけで、jar ファイルのバージョンを見つけることができるのでしょうか?
manifest.mf の例
これは、アプリケーションの 1 つで見つかった xalan.jar ファイルの MANIFEST.MF のコンテンツの一部です。これは、すべての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/
後付け
しかし、XML関連のすべてのjarファイルなど、無視するjarファイルの「ブラックリスト」を作成する必要があるかもしれません。このリンクXerces と Xalan の場所とバージョンを見つけました。これは、manifest.mf ファイルを見て xalan.jar のバージョンを見つけることができないことを示しています。代わりに、Version クラスの出力を取得する必要があります。