【问题标题】:How to add a file to a war with Maven如何将文件添加到与 Maven 的战争中
【发布时间】:2011-01-25 19:33:39
【问题描述】:

我开发了一个从 JIRA 下载发行说明的 maven 插件。 它默认绑定到“generate-sources”阶段并在构建文件夹(${project.build.directory})中创建一个“release.txt”文件。

我的问题:如何在 Maven 构建的 war 文件的 'WEB-INF' 文件夹中添加这个文件?

我知道我可以使用 'maven-war-plugin' 来包含来自 'src' 文件夹的其他外部资源,但我不希望在那里生成我的 'release.txt' 文件(=不可提交到 svn) .

感谢您的帮助。祝你有美好的一天!

最大的

【问题讨论】:

    标签: maven-2 maven-plugin


    【解决方案1】:

    我认为这可以使用该插件的此功能来完成:

    添加和过滤外部 Web 资源: http://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html

    这将允许您将 release.txt 生成到单独的文件夹(不是 src)中,并让插件将其视为额外的资源文件夹。

    希望对您有所帮助。

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

    【讨论】:

    • 好吧,它可以工作:org.apache.maven.pluginsmaven-war-plugin2.1-alpha- 2${project.build.directory}WEB-INFrelease.txt include> 备注:targetPath 设置在 2.0 版本被忽略
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-05-19
    • 2019-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-24
    • 2012-06-17
    相关资源
    最近更新 更多