【问题标题】:How can one prevent certain attributes from being added to the bundle's manifest with the Maven Bundle Plugin?如何使用 Maven Bundle Plugin 防止某些属性被添加到 bundle 的清单中?
【发布时间】:2013-03-09 17:29:45
【问题描述】:

我想从我的发布 jar 中删除某些标头(例如“Built-by”)。

我已经读过将标题设置为空内容应该可以解决问题,但这对我不起作用。例如,我正在使用:

<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <version>2.3.7</version>
    <extensions>true</extensions>
    <configuration>
        <instructions>
            <Built-By>a</Built-By>
            <Build-Jdk></Build-Jdk>
            <Created-By></Created-By>
            <Somethng-else>Hello</Somethng-else>
        </instructions>
    </configuration>
</plugin>

在添加Something-else 时,所有其他标题(例如Built-By)仍然存在。有什么见解吗?谢谢!

【问题讨论】:

    标签: java maven osgi maven-bundle-plugin


    【解决方案1】:

    我使用 maven-jar-plugin,这是我的 pom:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>2.2</version>
        <executions>
            <execution>
                <goals>
                    <goal>test-jar</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <archive>
                <manifest>
                   <addClasspath>true</addClasspath>
                   <mainClass>...MyClass</mainClass>
                   <classpathPrefix>libs/</classpathPrefix>
                   <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                </manifest>
                <manifestEntries>
                    <Built-By>a</Built-By>
                    <Build-Jdk></Build-Jdk>
                    <Created-By></Created-By>
                    <Somethng-else>Hello</Somethng-else>
                </manifestEntries>
            </archive>
        </configuration>
    </plugin>
    

    【讨论】:

    • 谢谢!麻烦的是,maven-bundle-plugin 可能很烦人,我绝对需要它来生成导入/导出包:)
    【解决方案2】:
    <_removeheaders>Build-*</_removeheaders>
    

    很高兴听到您发现插件很烦人(似乎没有寻找manual)。

    【讨论】:

    • 嗯,这可能很烦人,但我也说过没有它我就活不下去;)关于手册,我不知道我应该如何摆脱我认为的 @987654322 @到BND's。相信我,我已经用谷歌搜索过这个;)
    • 关于&lt;_removeheaders&gt;Build-*&lt;/_removeheaders&gt; 我可以看到它是一个 BND 选项,但我不确定它是否被 maven-bundle-plugin 公开。至少,如果我在我原来的问题上把它放在&lt;instructions&gt; 的位置上并没有帮助。有什么见解吗?非常感谢您在 BND 上所做的工作!!!
    • 尽管 maven bundle 插件(很烦人)为“用户友好”添加了一些额外的“功能”,但它提供了对所有 bnd 功能的访问。它们在这里被描述aqute.biz/Bnd/Format :-)
    • 请记住,以“-”(连字符)开头的 bnd 指令必须转换为“_”下划线,因为 XML 元素名称不能以“-”开头。谢谢你,W3C....
    • 这个答案不完整。我不知道如何修改 pom 文件以获得请求的结果。您能否更新文本以提供完整的答案?
    猜你喜欢
    • 2012-09-18
    • 2016-07-11
    • 2011-06-18
    • 2015-02-20
    • 1970-01-01
    • 2013-08-19
    • 1970-01-01
    • 2012-09-08
    • 1970-01-01
    相关资源
    最近更新 更多