使用maven将多个资源目录复制到独立目标目录

编程入门 行业动态 更新时间:2024-10-26 04:25:12
本文介绍了使用maven将多个资源目录复制到独立目标目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

Maven资源插件:

此目标要求您配置要复制的资源,并指定outputDirectory。

This goal requires that you configure the resources to be copied, and specify the outputDirectory.

复制使用maven将 basedir 中的两个(或更多)外部资源目录添加到构建输出目录中(参见 blah 和 uggh )。

Copy two (or more) external resource directories within the basedir to the build output directory using maven (see blah and uggh).

${basedir}/ - pom.xml - blah/ - uggh/ - src/ - main/.. - test/.. - target/ - classes/.. - blah/ - uggh/

例如,给定上面的目录结构使用maven将 blah 和 uggh 复制到目标目录。复制一个或另一个很容易,但插件只接受一个outputDirectory。如果指定目标目录和两个目录作为资源,则每个目录的内容将复制到 target 但不会目录本身。

For example, given the directory structure above copy blah and uggh to the target directory using maven. It is easy to copy one or the other, however, the plugin only accepts a single outputDirectory. If you specify the target directory and both directories as resources, then the contents of each directory gets copied to target but not the directories themselves.

插件的额外使用会覆盖初始。另外,我已经尝试指定整个 basedir 并且只包含所需的目录。这不会复制任何内容。

Additional use of the plugin overwrites the initial. Also, I've tried specifying the entire basedir and only including the desired directories. This does not copy anything.

以下是复制单个目录的示例:

Here is an example of copying a single directory:

<plugin> <artifactId>maven-resources-plugin</artifactId> <version>2.6</version> <executions> <execution> <id>copy-resources</id> <phase>validate</phase> <goals> <goal>copy-resources</goal> </goals> <configuration> <outputDirectory>${basedir}/target/blah</outputDirectory> <resources> <resource> <directory>blah</directory> <filtering>true</filtering> </resource> </resources> </configuration> </execution> </executions> </plugin>

推荐答案

这是文件的最终位置:

<outputDirectory>${basedir}/target/blah</outputDirectory>

这是从以下地方复制的地方:

This is where it is copied from:

<directory>src/main/otherresources</directory>

会有< include> 或< includes> 标记以告知文件名

There would be an <include> or <includes> tag to tell the file name(s)

倍数

您需要多个< execution> ,其中包含不同的< id> s:

You need multiple <execution>s with different <id>s for multiple folders:

<plugin> <artifactId>maven-resources-plugin</artifactId> <version>2.6</version> <executions> <execution> <id>copy-resources-1</id> <phase>validate</phase> <goals> <goal>copy-resources</goal> </goals> <configuration> <outputDirectory>${basedir}/target/blah</outputDirectory> <resources> <resource> <directory>blah</directory> <filtering>true</filtering> </resource> </resources> </configuration> </execution> <execution> <id>copy-resources-2</id> <phase>validate</phase> <goals> <goal>copy-resources</goal> </goals> <configuration> <outputDirectory>${basedir}/target/ughh</outputDirectory> <resources> <resource> <directory>ughh</directory> <filtering>true</filtering> </resource> </resources> </configuration> </execution> </executions> </plugin>

更多推荐

使用maven将多个资源目录复制到独立目标目录

本文发布于:2023-07-15 10:16:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1110619.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:目录   多个   独立   目标   资源

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!