【问题标题】:Generate Maven resources at build time在构建时生成 Maven 资源
【发布时间】:2015-04-10 03:08:18
【问题描述】:

我正在编写一个 Confluence 插件,它是一个 Maven 项目。我想在构建过程中将一些资源复制/聚合/下载/生成到 src/main/resources 目录中。如何配置 Maven 让我在构建过程中运行一些代码来创建这些资源?

【问题讨论】:

  • src/main/resources 应该用于静态资源,为什么要在其中添加动态生成的资源而不是添加到项目构建目录中?

标签: maven maven-plugin


【解决方案1】:

一种解决方案是在构建过程中使用 ant。 示例:

<plugin>
  <artifactId>maven-antrun-plugin</artifactId>
  <version>1.7</version>
  <executions>
    <execution>
      <id>taskId</id>
      <phase>generate-resources</phase>
      <configuration>
        <target name="targetName">
         <!-- put some ant code here -->
        </target>
      </configuration>
     <goals>
       <goal>run</goal>
     </goals>
   </execution>
 </executions>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-11-16
    • 2020-08-19
    • 2022-01-17
    • 1970-01-01
    • 2011-11-04
    • 2017-08-02
    • 1970-01-01
    相关资源
    最近更新 更多