简体   繁体   English

Maven War插件和自定义清单文件

[英]maven war plugin and custom Manifest file

I'd need Maven war plugin to use a custom MANIFEST.MF. 我需要Maven war插件才能使用自定义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: 正如我从文档中看到的那样,您可以将MANIFEST.MF文件放在src / main / resources / META-INF /中,并将以下配置添加到pom.xml文件中:

<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. 但是我看到WebRoot / META-INF中添加的MANIFEST.MF是默认的。 I can't find what is going wrong. 我找不到问题所在。 Any suggestion or link to github projects where it does work ? 任何建议或链接到github项目在哪里起作用? Thanks 谢谢

First in your configuration you missed the <groupid> ! 首先,在配置中您错过了<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. 您自己的清单文件的内容将与Maven Archiver创建的条目合并。 If you specify an entry in your own manifest file it will override the value created by Maven Archiver. 如果您在自己的清单文件中指定一个条目,它将覆盖Maven Archiver创建的值。

See the apache maven plugin page for entries of the default manifest, and configurable entries. 有关默认清单的条目和可配置的条目,请参见apache maven插件页面 Then you can add further own entries by providing a manifest using <manifestFile> 然后,您可以使用<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. 编辑:如果要使用1:1副本,则可以尝试使用maven程序集插件完成此操作,但是我认为您可以使用普通的mavne插件来完成此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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