【问题标题】:Is there a way to just copy resources when using a Maven archetype (no Velocity)?使用 Maven 原型(无 Velocity)时,有没有办法只复制资源?
【发布时间】:2009-11-11 07:48:34
【问题描述】:

我们使用 Maven 原型为使用我们的框架的项目创建初始设置,该框架严重依赖于 Freemarker。因此,当原型用于生成新项目时,我们需要复制一些 Freemarker 模板。

我们遇到的问题是 Maven 似乎在所有列为资源的文件上运行 Velocity。 Velocity 试图解释我们的 Freemarker 代码但失败了,所以我们需要在很多地方使用转义。

有没有办法告诉 Maven 只复制文件?我们根本不希望 Velocity 引擎为我们的文件运行。

【问题讨论】:

    标签: java maven-2 velocity freemarker maven-archetype


    【解决方案1】:

    使用 src/main/resources/META-INF/maven/archetype-metadata.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <archetype-descriptor name="foo-archetype">
      <fileSets>
        <fileSet filtered="false" encoding="UTF-8">
          <directory>src/foo</directory>
          <includes>
            <include>**/*.ftl</include>
          </includes>
        </fileSet>
      </fileSets>
    </archetype-descriptor>
    

    来源:http://maven.apache.org/plugins/maven-archetype-plugin/specification/archetype-metadata.html

    【讨论】:

    • 这里的重点是,如果您不希望 Velocity 处理给定文件集的文件,则需要将过滤设置为 false。
    猜你喜欢
    • 1970-01-01
    • 2011-04-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-13
    • 1970-01-01
    相关资源
    最近更新 更多