简体   繁体   English

在Maven Assembly Plugin中包含子项目zip文件

[英]Include subproject zip file with Maven Assembly Plugin

My Maven project structure is : 我的Maven项目结构为:

+ parent
++ moduleA
++ moduleB

In moduleB, I use the assembly plugin to generate a first zip file. 在moduleB中,我使用Assembly插件生成第一个zip文件。 As expected, it generates a moduleB.zip file in moduleB/target/ directory : 如预期的那样,它将在moduleB / target /目录中生成一个moduleB.zip文件:

<assembly>
    <formats>
        <format>zip</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <fileSets>
        <!-- ... -->
    </fileSets>
</assembly>

Now in my parent module, I would like to generate another zip file, and include moduleB.zip file. 现在在我的父模块中,我想生成另一个zip文件,并包含moduleB.zip文件。

How can I do that? 我怎样才能做到这一点? Should I use moduleSets? 我应该使用moduleSets吗? dependencySets? 依赖集? something else? 还有什么吗

When you are in the parent project you cannot create an assembly that will embed its modules, but there are two solutions : 在父项目中时,无法创建将嵌入其模块的程序集,但是有两种解决方案:

  1. You can create a second assembly in the moduleB that will create the final assembly that you want and that will surely be different from the first one created, you just have to pay attention to the order of the executions in your plugin configuration 您可以在moduleB中创建第二个程序集,该程序集将创建所需的最终程序集,并且肯定与创建的第一个程序集不同,您只需要注意插件配置中的executions顺序即可。
  2. Or you can create a third module moduleC (for example ^^) that will have a dependency on moduleB (with type zip for example and a classifier that you can define in moduleB ) and in which you will create your final assembly 或者,您可以创建第三个模块moduleC (例如^^) ,该模块将依赖于moduleB (例如zip type和可以在moduleB定义的classifier moduleB ),并在其中创建最终装配

You can find additional information here : http://maven.apache.org/plugins/maven-assembly-plugin/faq.html#module-binaries 您可以在此处找到其他信息: http : //maven.apache.org/plugins/maven-assembly-plugin/faq.html#module-binaries

Personally the solution I always use is the second one with a module dedicated to the final assembly. 就我个人而言,我一直使用的解决方案是第二个解决方案,其中包含专门用于最终组装的模块。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM