3

I would like to remove certain headers from my release jars (e.g. "Built-by").

I have read that setting the headers to an empty content should do the trick, but it's not working for me. For example, I'm using:

<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>

While Something-else is being added, all the other headers (e.g. Built-By) remain. Any insights? Thanks!

Miquel
  • 15,405
  • 8
  • 54
  • 87

2 Answers2

2
<_removeheaders>Build-*</_removeheaders>

Nice to hear you find the plugin annoying (without seeming to have looked for the manual).

Peter Kriens
  • 15,196
  • 1
  • 37
  • 55
  • Well, it can be quite annoying, but I also said I can't live without it ;) Regarding the manual, I have no idea how I should have gone from what I thought was the [maven-bundle plugin manual](http://svn.apache.org/repos/asf/felix/releases/maven-bundle-plugin-2.3.7/doc/site/index.html) to [BND's](http://www.aqute.biz/Bnd/Format). Trust me, I have googled for this ;) – Miquel Mar 20 '13 at 16:10
  • 1
    Regarding `<_removeheaders>Build-*` I can see it's a BND option, but I'm not sure it's exposed by the maven-bundle-plugin. At the very least, it does not help if I put it in place of `` on my original question. Any insights? And thanks a lot for your work on BND!!! – Miquel Mar 20 '13 at 16:11
  • Ok, so, this `<_removeheaders>` goes inside . Working. Thanks! – Miquel Mar 20 '13 at 16:37
  • 1
    Though the maven bundle plugin (annoyingly) adds some extra 'features' for 'user friendliness' it provides access to ALL bnd's features. They are described here http://www.aqute.biz/Bnd/Format :-) – Peter Kriens Mar 20 '13 at 17:14
  • 1
    Just remember that bnd instructions starting with "-" (hyphen) have to be translated to "_" underscore, because XML element names cannot begin with "-". Thanks for that, W3C.... – Neil Bartlett Mar 21 '13 at 09:12
  • 1
    This answer is not complete. I have no idea how to modify the pom file in order to get the requested result. Can you please update the text to gie a complete answer? – Roel Spilker Sep 15 '14 at 16:22
  • Since the documentation links in the comments above are now broken, I'll mention this other SO answer that demonstrates how to remove multiple headers: https://stackoverflow.com/a/18505535/171452 (in case anyone, like myself, needs to do that). – ksclarke Jun 17 '17 at 22:17
0

I use maven-jar-plugin and thi is my pice of 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>
Alepac
  • 1,833
  • 13
  • 24
  • Thanks! Trouble is, annoying as the maven-bundle-plugin can be, I absolutely need it for things like import/export package generation :) – Miquel Mar 20 '13 at 15:06