Мне удалось добавить специальные метаданные OSGi в MANIFEST артефакта Maven-saucer-pdf Maven. Однако мне не удается внедрить зависимости и транзитивные зависимости этого артефакта в созданный файл JAR.Вложение Зависимость в JAR с maven-bundle-plugin не работает
Я использовал первоисточники от летящего-блюдца-PDF взят из GitHub [1] и добавлены следующие операторы в файл 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 версии 2.1.7 в исходном pom.xml, который я не касался. Я также не возился с оригинальным типом упаковки артефакта, который является банкой.
К сожалению, это делает только часть работы. 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, то есть вступления Bundle-пути к классам манифеста указывает на недостающий контент.
Кроме того, я попытался создать совершенно новый артефакт, который объявляет зависимость от оригинального артефакта летающего тарелки-pdf и переустанавливает его как пакет OSGi, текущий этот ответ [2] здесь, на StackOverflow, и это сработало.
Единственное реальное отличие, которое я вижу, это тип упаковки «bundle» vs. «jar». Но я не могу изменить этот тип упаковки в оригинальном артефакте летающего блюдца-pdf, так как все должно оставаться таким же, как и для не-OSGi-обычаев, чтобы получить это изменение, принятое в качестве Push-запроса.
Вы, ребята, знаете, могут ли эти зависимости встраивания с плагином maven-bundle работать с типом упаковки «jar»? Или ему нужен тип упаковки «пучок»?
Я ценю любой ответ и намек на то, что я мог бы попытаться получить, что переупаковка выполняется непосредственно в оригинальном артефакте.
спасибо.
С уважением Тимо Rohrberg