简体   繁体   English

如何将内容从Maven模块目标目录复制到父目录

[英]How to copy content from maven module target directory to the parent

I have a maven project which has 2 maven modules ie module 1 and module 2. Below is the structure of the project 我有一个Maven项目,其中有2个Maven模块,即模块1和模块2。下面是项目的结构

Parent 父级

-- module 1
        -- pom.xml
-- module 2
        -- pom.xml
-- pom.xml

Now when i build the project, both module 1 and module 2 build directory will have a jar and xml file. 现在,当我构建项目时,模块1和模块2的构建目录都将具有jar和xml文件。

What i want to achieve is to have content of build directory of both module 1 and module 2 to be copied to a specific directory structure under parent when i build the project. 我想要实现的是在构建项目时,将模块1和模块2的构建目录的内容复制到父目录下的特定目录结构中。

Please can you suggest on how i can achieve this ? 请您就我如何做到这一点提出建议?

You can use maven-resources-plugin to do this. 您可以使用maven-resources-plugin执行此操作。

Configure it to copy all needed files to your wanted path, and bind the execution during the phase install of both module 1 and 2. 配置它以将所有需要的文件复制到所需的路径,并在模块1和2的阶段安装期间绑定执行。

Doing this, when the module has just been compiled and artifacts produced, the resource plugin will execute and copy your files. 这样做时,在刚刚编译模块并生成构件时,资源插件将执行并复制您的文件。

You can find the documentation of the plugin here: https://maven.apache.org/plugins/maven-resources-plugin/examples/copy-resources.html 您可以在此处找到该插件的文档: https : //maven.apache.org/plugins/maven-resources-plugin/examples/copy-resources.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 Maven 将目录从父模块复制到子模块 - How to copy a directory from parent to child module with Maven 如何将 Maven 构建工件从子模块目标复制到父目标? - How to copy Maven build artifact from a sub-module target to the parent target? 从目标到外部目录的Maven复制子文件夹 - maven copy subfolder from target to an external directory 如何使用Maven将资源复制到src目标目录? - How to copy resource to src target directory with Maven? 如何使用Maven将生成的文件从依赖项复制到当前项目的目标? - How to copy a generated files from a dependency to the target of current project with maven? Maven:如何从命令行更改目标目录的路径? - Maven: How to change path to target directory from command line? zip 一些模块,包括来自多模块 maven 项目的目标目录 - zip some modules including target directory from multi-module maven project 如何使用 Maven 复制文件并将第一个模块指定为目标文件夹? - How do I copy a file using Maven and specify the first module as the target folder? 如何将目录从源复制到Maven中的结果jar - How to copy a directory from the source to resulting jar in maven 使用Maven在父目标目录中自动创建JAR文件 - automatically created JAR File in parent target-directory with maven
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM