【问题标题】:JAR is not getting embedded in the OSGi bundle when using embedded dependencies使用嵌入式依赖项时,JAR 没有嵌入到 OSGi 包中
【发布时间】:2018-10-05 13:50:21
【问题描述】:

我需要为自定义用例嵌入非 osgi 第三方依赖项 (nimbus-jose-jwt)。

我在 pom 文件的依赖项下添加了以下依赖项。

<dependency>
    <groupId>com.nimbusds</groupId>
    <artifactId>nimbus-jose-jwt</artifactId>
    <version>5.8</version>
</dependency>

我尝试使用 Embed-Dependency 指令将第三方 jar 嵌入到包中。

<Embed-Dependency>
    com.nimbusds.jose.*;scope=compile|runtime;inline=true,
    com.nimbusds.jwt.*;scope=compile|runtime;inline=true,
</Embed-Dependency>

我在 pom 文件中的 maven-bundle-plugin 如下所示。

    <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <extensions>true</extensions>
        <configuration>
            <instructions>
                <Bundle-SymbolicName>
                    ${project.artifactId}
                </Bundle-SymbolicName>

                <Private-Package>

                </Private-Package>
                <Import-Package>

                </Import-Package>
                <Export-Package>

                </Export-Package>
                <Embed-Dependency>
                    com.nimbusds.jose.*;scope=compile|runtime;inline=true,
                    com.nimbusds.jwt.*;scope=compile|runtime;inline=true,
                </Embed-Dependency>
                <Embed-Transitive>true</Embed-Transitive>
            </instructions>
        </configuration>
    </plugin>

生成的清单是正确的,但 jar 没有嵌入到 捆。我还应该做些什么才能将它嵌入到我的捆绑包中?感谢您对此的任何帮助。

谢谢!

【问题讨论】:

    标签: maven osgi osgi-bundle


    【解决方案1】:

    试试

    <Embed-Dependency>*;scope=compile|runtime;inline=true;artifactId=nimbus-jose-jwt</Embed-Dependency>
    

    <Embed-Dependency>nimbus-jose-jwt;scope=compile|runtime;inline=true</Embed-Dependency>
    

    匹配的表达式,至少是第一个,匹配工件 ID,而不是包名称。查看bundle plugin documentation,了解有关如何选择要嵌入的工件的更多信息。

    【讨论】:

      猜你喜欢
      • 2019-11-03
      • 2014-11-20
      • 2019-09-24
      • 2021-07-05
      • 1970-01-01
      • 2018-10-24
      • 2019-12-29
      • 2013-09-13
      • 2010-11-25
      相关资源
      最近更新 更多