maven-2 - 马文 : local development deploy vs bundling for distribution

标签 maven-2

请耐心等待,我正在从 Ant 迁移到 Maven2:我想我已经遇到了一些在 Ant 中很容易但在 Maven 中却不是这样的小事情......

我如何处理本地部署与创建存档/ bundle 以分发到另一台机器之间的区别?

让我们假设我的项目的输出是一个 EAR 加上一些额外的配置文件。积极参与项目的开发人员需要经常部署和重新部署到他的本地应用程序服务器(比如 JBoss),而集成工程师正在构建对于 QA/production,只需要创建最终的存档程序集 (tar/gz)。

在 Ant 中,我们有两个目标:“dev-deploy”和“bundle”。两者都进行完整构建,但在最后一步有所不同:“dev-deploy”将 EAR 和配置文件复制到各自的本地文件夹,而“bundle”只是将 EAR 和配置文件放入 tar.gz 程序集中。

如何在 Maven 中执行此操作?

我已经看到程序集插件可以创建存档(tar、gz 等)或分解目录(来自相同的程序集描述符)。我可以调用 assembly:assemblyassembly:directory,但对于后者,我如何将最终输出复制到本地 JBoss 部署文件夹?来自 related post似乎临时复制文件并不是 Maven 的真正目的,所以 antrun 复制可能是最合适的?

最后,由于程序集的类型可能会因调用者的不同而有所不同,因此将程序集绑定(bind)到构建生命周期似乎并不明智,不是吗?但这意味着开发人员将始终需要调用 'mvn package',然后调用 'mvn assembly:directory' 来重建和测试更改。相反,集成工程师将始终需要运行 'mvn package',然后运行 ​​'mvn assembly:assembly' 来创建可分发的存档。我希望为每个解决方案提供一个命令解决方案,还是我应该编写脚本?

最佳答案

In Ant we had two targets for this: "dev-deploy" and "bundle". Both do a complete build, but differ in the final step: "dev-deploy" copies the EAR and config files to the respective local folders, while "bundle" just puts the EAR & config files in a tar.gz assembly.

不确定关于“dev-deploy”的各自的本地文件夹是什么意思,但这听起来像 mvn pacakge 正在做的事情,“bundle”确实听起来像一个专家assembly .

I've seen that the assembly plugin can create either archives (tar, gz, etc.) or exploded directories (from the same assembly descriptor). I can invoke either assembly:assembly or assembly:directory, but for the latter, how do I copy the final output to the local JBoss deployment folders? From a related post it seems that ad-hoc copying of files is not really what Maven is about, so an antrun copy is probably the most appropriate?

我想我们在这里谈论的是集成工程师的任务。由于您没有解释“bundle”到底包含什么,目标应用程序服务器是什么(我的理解是您也在使用 JBoss 进行 QA/生产,但同样,这是一个猜测),如果这个 bundle 必须是自动部署,很难想象 antrun 的所有解决方案和/或替代方案。但实际上,要复制/移动/解压缩/无论程序集如何,maven antrun 插件都是一个候选者。

Finally, since the type of assembly may differ depending on who invokes it, it doesn't seem wise to bind assembly to the build lifecycle, not so? But this means that a developer will always need to invoke 'mvn package' followed by 'mvn assembly:directory' to rebuild and test a change. Conversely, an Integration Engineer will always need to run 'mvn package' followed by 'mvn assembly:assembly' to create the distributable archive. I was hoping for a one-command solution for each, or should I just script it?

我的理解是集成工程师正在构建 bundle 。为什么开发人员需要 bundle ?这令人困惑......无论如何,我真的不需要细节来想出答案。您实际上可以将 Maven 程序集插件声明为特定的 build profiles ,一个用于开发,一个用于集成,并绑定(bind) singledirectory-single mojos 到每个配置文件中的项目构建生命周期。这将允许仅使用一个命令并避免任何脚本编写(真的,不要这样做)。

关于maven-2 - 马文 : local development deploy vs bundling for distribution,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1929199/

相关文章:

eclipse - m2eclipse 工作空间分辨率

java - 使用 Maven 2 构建可运行的 jar

maven-2 - 使用 JUnit 的 maven2 中的类加载问题

Maven不会运行测试

java - 谁负责更新 App Engine 的 Maven 存储库?其他人可以这样做吗?

deployment - 部署 Maven 项目

Java 6 : how to pass multiple parameters to APT

maven - 从 Nexus3 下载单个/最新 Assets (JAR)

maven - 如何查找有关 Liberty Maven 插件的详细文档?

java - Maven exec 插件-如何包含 "system"类路径?