我应该如何让 Maven 同时为所有支持的架构部署工件?
我有一个问题可能与这个非常相似。我需要解决一个我认为非常常见的问题——如何配置 Maven 以在同一工件上生成多个变体——但我还没有找到一个好的解决方案。
我有一个多模块项目,最终导致 assemble
插件生成一个工件。然而,程序集的一部分包含最近发生了重大变化的库,导致该项目的一些使用者需要库版本 N,而其他使用者则需要版本 N+1。理想情况下,我们只是自动生成多个工件,例如 theproject-1.2.3.thelib-1.0.tar.gz
、theproject-1.2.3.thelib-1.1.tar.gz< /code> 等(这是我们项目的版本 1.2.3,针对库版本 1.0 或 1.1 运行)。
现在,我有一堆默认属性,它们是针对相关库的最新版本构建的,还有一个针对旧版本构建的配置文件。我可以通过这种方式部署其中之一,但不能在一个构建中同时部署两者。这是与上述问题不同的关键问题:我无法在 release
插件的内部自动执行 build-one-clean-build-the-other 操作。
通常,我们会从多模块项目的根目录 mvn release:prepare release:perform
来负责将所有内容部署到我们的内部 Nexus。然而,在这种情况下,我们必须选择一个 - 要么运行旧的库配置文件,要么不运行并获取新的配置文件。我需要发布插件来部署两者。难道这根本不可能吗?我必须想象我们不是第一批希望我们的自动化构建生成对不同平台的支持的人......
I have a question that's probably pretty similar to this. I need to solve what I have to imagine to be a pretty common problem -- how to configure Maven to produce multiple variations on the same artifact -- but I have yet to find a good solution.
I have a multi-module project, that eventually results in the assembly
plugin generating an artifact. However, part of the assembly includes libraries that have changed substantially in the recent past, with the result that some consumers of the project need library version N, while others need version N+1. Ideally, we'd just automatically generate multiple artifacts, e.g. theproject-1.2.3.thelib-1.0.tar.gz
, theproject-1.2.3.thelib-1.1.tar.gz
, etc. (where that's release 1.2.3 of our project, running against either library version 1.0 or 1.1).
Right now, I have a bunch of default properties, which build against the latest version of the library in question, plus a profile to build against the older version. I can deploy one or the other this way, but cannot deploy both in one build. Here's the key wrinkle that differs from the above question: I can't automate build-one-clean-build-the-other inside of the release
plugin.
Normally, we'd mvn release:prepare release:perform
from the root of the multi-module project to take care of deploying everything to our internal Nexus. However, in that case, we have to pick one -- either run the old-library profile, or run without and get the new one. I need the release plugin to deploy both. Is this just impossible? I have to imagine we're not the first people who want to have our automated builds generate support for different platforms....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以安装具有不同类型/分类器的其他工件。使用 build-helper-maven- 的
attach-artifact
目标插件来实现这一点。这是一个小例子 - 我们正在将产品的 Windows 和 Unix 安装程序部署为 windows/exe 和 unix/sh 文件。这些文件将安装到本地存储库并部署到分发管理。希望这有帮助。
You may install additional artifacts with differrent types/classifiers. Use
attach-artifact
goal of the build-helper-maven-plugin to achieve this. Here is a small example - we are deploying a Windows and a Unix installers of the product as windows/exe and unix/sh files. These files will be installed to the local repo and deploy to the distribution management.Hope this helps.