【问题标题】:How to copy individual files with Maven Resource Plugin如何使用 Maven 资源插件复制单个文件
【发布时间】:2016-07-15 07:06:17
【问题描述】:

我知道可以复制目录的内容并应用过滤器,但是是否可以指定要使用 Maven 资源插件复制的单个文件在任意目录中,或者我应该使用 antrun 之类的插件?

编辑:问题已解决,请阅读我的答案

【问题讨论】:

  • 您可能需要详细说明您正在尝试做什么。如果您不想复制文件,请不要将它们放在 src/main/resources 目录中。

标签: javascript java maven build resources


【解决方案1】:

这个配置帮我搞定了

<execution>
    <id>copy-html-and-images-to-dist</id>
    <phase>generate-resources</phase>
    <goals>
        <goal>copy-resources</goal>
    </goals>
    <configuration>
        <outputDirectory>${basedir}/src/main/frontend/dist</outputDirectory>
        <overwrite>true</overwrite>
        <resources>
            <resource>
                <directory>${basedir}/src/main/frontend/src</directory>
                <includes>
                    <include>index.html</include>
                    <include>images</include>
                    <include>favicon.ico</include>
                </includes>
            </resource>
        </resources>
    </configuration>
</execution>

【讨论】:

  • 解决方案看起来不对,因为我假设您有一个战争项目?此外,src/main/frontend/src 是什么?
  • 这是一个耳朵项目。 frontend/src 包含 React UI 源代码,webpack 将其捆绑到 dist 文件夹中。由于 webpack 配置不当,我必须在那里手动复制 index.html 和图像,但它可以解决问题。这个 dist 文件夹稍后会在构建 ear 之前由另一个插件执行复制到 webapp 文件夹。我测试了它,它工作正常
  • 你应该将反应代码移动到战争模块......所以你不需要做这种黑客......
  • 我们喜欢将关注点分开。无论如何,需要一些技巧来仅包含捆绑的 JavaScript 到耳朵
  • 在 EAR 中?我对此表示怀疑。这些东西属于 WAR 模块,您可以使用叠加层处理...
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-07-04
  • 2019-09-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-04-16
  • 2017-04-27
相关资源
最近更新 更多