2016-11-03 4 views
1

OSGi固有のメタデータをflying-saucer-pdf MavenアーティファクトのMANIFESTに追加することに成功しました。ただし、作成したJARファイルに、そのアーティファクトの依存関係と推移的な依存関係を埋め込むことはできません。maven-bundle-pluginが動作していないJARへの依存関係の埋め込み

I [1]のGitHubから採取したフライング円盤-PDFから元のソースを使用してpom.xmlファイルに次の文を加え

<plugin> 
    <artifactId>maven-jar-plugin</artifactId> 
    <configuration> 
     <archive> 
     <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile> 
     </archive> 
    </configuration> 
    </plugin> 
    <plugin> 
    <groupId>org.apache.felix</groupId> 
    <artifactId>maven-bundle-plugin</artifactId> 
    <executions> 
     <execution> 
     <id>bundle-manifest</id> 
     <phase>process-classes</phase> 
     <goals> 
      <goal>manifest</goal> 
     </goals> 
     <configuration> 
      <instructions> 
      <Embed-Dependency>itext</Embed-Dependency> 
      <Embed-Transitive>true</Embed-Transitive> 
      </instructions> 
     </configuration> 
     </execution> 
    </executions> 
    </plugin> 

アーティファクトがiTextのバージョンに宣言依存性を有しています私が触れなかった元のpom.xmlの2.1.7。私はまた、瓶であるアーティファクトの元のパッケージングタイプを混乱させませんでした。

残念ながら、これは作業の一部に過ぎません。 MANIFEST.MFは正しいようだと予想されるOSGiのタグが含まれています

Manifest-Version: 1.0 
Bundle-Description: Flying Saucer is a CSS 2.1 renderer written in Jav 
a. This artifact supports PDF output. 
Bundle-License: http://www.gnu.org/licenses/lgpl.html 
Bundle-SymbolicName: org.xhtmlrenderer.flying-saucer-pdf 
Archiver-Version: Plexus Archiver 
Built-By: u0400072 
Bnd-LastModified: 1478168053263 
Bundle-ManifestVersion: 2 
Embed-Dependency: itext 
Import-Package: com.apple.mrj,com.lowagie.toolbox,javax.crypto,javax.i 
mageio,javax.imageio.metadata,javax.imageio.plugins.jpeg,javax.imagei 
o.stream,javax.swing,javax.xml.parsers,javax.xml.transform,javax.xml. 
transform.dom,javax.xml.transform.sax,javax.xml.transform.stream,org. 
bouncycastle.asn1,org.bouncycastle.asn1.cmp,org.bouncycastle.asn1.cms 
,org.bouncycastle.asn1.ocsp,org.bouncycastle.asn1.pkcs,org.bouncycast 
le.asn1.tsp,org.bouncycastle.asn1.x509,org.bouncycastle.cms,org.bounc 
ycastle.crypto,org.bouncycastle.crypto.engines,org.bouncycastle.crypt 
o.modes,org.bouncycastle.crypto.paddings,org.bouncycastle.crypto.para 
ms,org.bouncycastle.jce.provider,org.bouncycastle.ocsp,org.bouncycast 
le.tsp,org.w3c.dom,org.xhtmlrenderer.context,org.xhtmlrenderer.css.co 
nstants,org.xhtmlrenderer.css.extend,org.xhtmlrenderer.css.parser,org 
.xhtmlrenderer.css.sheet,org.xhtmlrenderer.css.style,org.xhtmlrendere 
r.css.style.derived,org.xhtmlrenderer.css.value,org.xhtmlrenderer.ext 
end,org.xhtmlrenderer.layout,org.xhtmlrenderer.render,org.xhtmlrender 
er.resource,org.xhtmlrenderer.simple.extend,org.xhtmlrenderer.swing,o 
rg.xhtmlrenderer.util,org.xml.sax,org.xml.sax.helpers 
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.6))" 
Tool: Bnd-3.2.0.201605172007 
Embedded-Artifacts: itext-2.1.7.jar;g="com.lowagie";a="itext";v="2.1.7 
" 
Export-Package: org.xhtmlrenderer.pdf;uses:="org.w3c.dom,org.xhtmlrend 
erer.css.constants,org.xhtmlrenderer.css.parser,org.xhtmlrenderer.css 
.style,org.xhtmlrenderer.css.value,org.xhtmlrenderer.extend,org.xhtml 
renderer.layout,org.xhtmlrenderer.render,org.xhtmlrenderer.resource,o 
rg.xhtmlrenderer.simple.extend,org.xhtmlrenderer.swing,org.xml.sax";v 
ersion="9.0.10",org.xhtmlrenderer.pdf.util;uses:="org.w3c.dom,org.xht 
mlrenderer.pdf";version="9.0.10",org.xhtmlrenderer.simple;uses:="java 
x.swing,org.w3c.dom,org.xhtmlrenderer.css.extend,org.xhtmlrenderer.cs 
s.sheet,org.xhtmlrenderer.extend,org.xhtmlrenderer.layout,org.xhtmlre 
nderer.swing,org.xhtmlrenderer.util";version="9.0.10" 
Bundle-Name: Flying Saucer PDF Rendering 
Bundle-Version: 9.0.10.SNAPSHOT 
Bundle-ClassPath: .,itext-2.1.7.jar 
Embed-Transitive: true 
Created-By: Apache Maven Bundle Plugin 
Build-Jdk: 1.8.0_102 

しかし、iTextのライブラリーは、結果として得られるJAR、欠けているコンテンツへのMANIFESTポイントの、すなわちバンドル・クラスパスエントリに入れていません。

さらに、元のフライングソーサーpdfアーティファクトへの依存性を宣言し、これをStackOverflowでこの回答を流すOSGiバンドルとして再バンドルする全く新しいアーティファクトを作成しようとしました。

私が見ることのできる唯一の違いは、パッケージタイプ 'bundle'と 'jar'です。しかし、その変更をプッシュリクエストとして受け入れるためには、OSGi以外の用途ではすべてをそのままにしておく必要があるため、オリジナルのフライングソーサー/ pdfアーティファクトでそのパッケージングタイプを変更することはできません。

maven-bundle-pluginにこのような埋め込み依存関係が実際にパッケージタイプ 'jar'で動作することができるかどうかは知っていますか?または、パッケージングタイプの「バンドル」が必要ですか?

元のアーティファクト内で直接再バンドルすることを試みることができると私は何か応答とヒントを感謝します。

ありがとうございました。

よろしく ティモRohrberg

答えて

2

のMavenバンドルプラグインを使用するには、2つの方法があります。

最初の方法は、この場合のMavenバンドルプラグインは、手順を構築し、jarファイルの内容に影響を与えることができるすべてを担当している

<extensions>true</extensions> and <packaging>bundle</packaging> 

を使用することです。

第2の方法は、マニフェスト目標を使用し、jarプラグインにマニフェストを追加することです。この場合、mavenバンドルプラグインはjarにのみ影響します。他のライブラリを埋め込むことも、外部プライベートクラスにコピーすることもできません。

埋め込みが必要な場合は、唯一の方法はパッケージを変更することです。

私は元の瓶にあまり影響を与えない2つの解決策があると思います。

  1. バンドル
  2. はさらに、元のjar
に利用可能であるバンドルを作成するには、ビルドにspearateモジュールを作成して依存関係を埋め込み、インストールしないでください
関連する問題