如何使用 maven- assembly-plugin (或其他方式)将外部工件组装到一个全局目录中
我正在尝试使用 Maven,并尝试将最初使用 shell 脚本构建的项目进行 mavenize。
根据 Maven 的经验法则:一个项目,一个工件,我创建了以下结构:
<PROJECT>
<MODULE-1>
<MODULE-2>
<MODULE-3>
..
<MODULE-N>
<RESOURCES>
<DISTRIB>
RESOURCES 模块的结构如下:
<RESOURCES>/src/main/resources/<MODULE-1>/bin
<RESOURCES>/src/main/resources/<MODULE-1>/lib
<RESOURCES>/src/main/resources/<MODULE-1>/doc
<RESOURCES>/src/main/resources/<MODULE-2>/bin
<RESOURCES>/src/main/resources/<MODULE-2>/lib
<RESOURCES>/src/main/resources/<MODULE-2>/doc
...
<RESOURCES>/src/main/resources/<MODULE-N>/bin
<RESOURCES>/src/main/resources/<MODULE-N>/lib
<RESOURCES>/src/main/resources/<MODULE-N>/doc
这样做的原因是上面的资源是在运行时而不是编译时需要的它们主要是属性文件、配置文件和调用各种 jar 文件的 shell 脚本。对于最后的资源步骤,我想将子目录合并到一个全局 bin/lib/doc 目录中。但是,我在程序集描述符中没有看到一个选项可以去除模块的前缀以获得我想要的内容:
<RESOURCES>/target/resources/bin
<RESOURCES>/target/resources/lib
<RESOURCES>/target/resources/doc
其中 bin 将包含 /src/main/resources 中找到的所有文件//bin 目录、/src/main/resources//bin 目录等。lib、doc 类似。
我的问题:我应该有一个:
<MODULE-1>/src/external/resources/bin
<MODULE-1>/src/external/resources/lib
<MODULE-1>/src/external/resources/doc
...
<MODULE-N>/src/external/resources/bin
<MODULE-N>/src/external/resources/lib
<MODULE-N>/src/external/resources/doc
结构,然后我可以通过依赖集访问它吗?这些文件不应该是各个模块的 jar 文件的一部分,因此不能存储在各自项目的 src/main/resources 中。或者我想通过使用其他 Maven 插件来实现什么?
在 DISTRIB 模块中,我将 RESOURCES 模块的输出与 JAR 文件和依赖项结合起来,创建一个目录结构,然后将其与打包工具(Solaris 包和 WiX 安装程序)一起使用。
任何帮助将不胜感激!
I am experimenting with Maven and I am trying to mavenize a project originally build with shell scripts.
With the Maven rule-of-thumb: one project, one artifact, I created the following structure:
<PROJECT>
<MODULE-1>
<MODULE-2>
<MODULE-3>
..
<MODULE-N>
<RESOURCES>
<DISTRIB>
The RESOURCES module is structured as follows:
<RESOURCES>/src/main/resources/<MODULE-1>/bin
<RESOURCES>/src/main/resources/<MODULE-1>/lib
<RESOURCES>/src/main/resources/<MODULE-1>/doc
<RESOURCES>/src/main/resources/<MODULE-2>/bin
<RESOURCES>/src/main/resources/<MODULE-2>/lib
<RESOURCES>/src/main/resources/<MODULE-2>/doc
...
<RESOURCES>/src/main/resources/<MODULE-N>/bin
<RESOURCES>/src/main/resources/<MODULE-N>/lib
<RESOURCES>/src/main/resources/<MODULE-N>/doc
The reason for doing it this way was that the resources above are needed at runtime, not compile-time and they are mostly property files, config files and shell scripts to invoke the various jar-files. For the final resources step, I wanted to combine the subdirectories into one global bin/lib/doc directory. However, I do not see an option in the assembly descriptor to strip of the prefix of the modules to get to what I want:
<RESOURCES>/target/resources/bin
<RESOURCES>/target/resources/lib
<RESOURCES>/target/resources/doc
where bin would contain all the files found in the /src/main/resources//bin directory, /src/main/resources//bin directory etc. Similarly for lib, doc.
My question: should I have a:
<MODULE-1>/src/external/resources/bin
<MODULE-1>/src/external/resources/lib
<MODULE-1>/src/external/resources/doc
...
<MODULE-N>/src/external/resources/bin
<MODULE-N>/src/external/resources/lib
<MODULE-N>/src/external/resources/doc
structure instead, that I would then access through a dependency-set? These files should not be part of the jar-file of the various modules and therefore cannot be stored in src/main/resources of their respective projects. Or is what I want to achieve doable by using some other maven plugin instead?
In the DISTRIB module I would combine the output of the RESOURCES module with the JAR-files and dependencies to create a directory structure that would then be used with a packaging tool (Solaris package and WiX installer).
Any help would be appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 pom 堡垒中,资源模块将源目录设置为 /src/main/resources/ 以外的目录,以便它不会将它们复制到目标文件夹。然后使用 Maven Resources Plugin 将资源文件复制到 target/bin 并目标库等,
例如
In the pom fort he resources module set the source directory to something other than /src/main/resources/ so that it does not copy them to the target folder. Then use the Maven Resources Plugin to copy the resource files to target/bin and target lib etc.
e.g.