How to add a file to a war with Maven

与世无争的帅哥 提交于 2019-11-30 07:02:55
simonlord

I think this can be done using this feature of that plugin:

Adding and Filtering External Web Resources: http://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html

Which would allow you to generate your release.txt into a separate folder (not src) and have the plugin treat it as an extra resources folder.

Hope that helps.

<plugin> 
  <groupId>org.apache.maven.plugins</groupId> 
  <artifactId>maven-war-plugin</artifactId> 
  <configuration> 
    <webResources> 
      <resource> 
        <directory>${project.build.directory}</directory> 
        <targetPath>WEB-INF</targetPath> <!-- introduced in plugin v 2.1 -->
        <includes> 
          <include>release.txt</include> 
        </includes> 
      </resource> 
    </webResources> 
  </configuration> 
</plugin> 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!