简体   繁体   中英

maven war plugin and custom Manifest file

I'd need Maven war plugin to use a custom MANIFEST.MF. As I read from the documentation you can put your MANIFEST.MF file in src/main/resources/META-INF/ and add the following configuration to your pom.xml file:

<plugin>
      <artifactId>maven-war-plugin</artifactId>
      <configuration>
        <archive>
          <manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>  
        </archive>
      </configuration>
</plugin>

However I see the MANIFEST.MF added in the WebRoot/META-INF is the default one. I can't find what is going wrong. Any suggestion or link to github projects where it does work ? Thanks

First in your configuration you missed the <groupid> !

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    ...
    <configuration>
      <archive>
        <manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
      </archive>
    </configuration>

 </plugin>

And then be aware that only those entries of your own manifest are used which are not in the generated by the plugin!

The content of your own manifest file will be merged with the entries created by Maven Archiver. If you specify an entry in your own manifest file it will override the value created by Maven Archiver.

See the apache maven plugin page for entries of the default manifest, and configurable entries. Then you can add further own entries by providing a manifest using <manifestFile>

edit: If you want to use a 1:1 copy you could try to get this done my using the maven assembly plugin , but I think you can you do this with the normal mavne plugins.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM