使用 Maven 自动化自定义战争文件 [英] Automate custom war files using maven

查看:18
本文介绍了使用 Maven 自动化自定义战争文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 Maven 战争覆盖,但他们假设原始战争文件是一个 Maven 项目.

I know about maven war overlays, but they assume that the original war file is a maven project.

如果我只能访问打包的 war 文件,而我需要通过添加新资源或使用 maven 更新属性文件中的几个值来修改它,并将新的过度播放的打包 war 文件推送到服务器上的 tomcat,该怎么办?

What if I only have access to the packaged war file and I need to modify it by adding new resources or updating few values in properties file using maven and push the new overplayed packaged war file to tomcat on a server?

在 maven 中这样做是否太复杂了?

Is it too complex to do this in maven?

如果我在我的存储库中安装了 war 文件,maven 构建过程会自动使用它吗?

If I install the war file in my repository does the maven build process automatically use it?

推荐答案

它并不假设 WAR 是一个 Maven 项目,不管这意味着什么,只是假设 WAR 是一个 Maven 工件.您可以将任何 WAR 安装为工件,无论它是如何构建的.如果您随后声明对此工件的依赖项,您将能够覆盖它.虽然添加和替换文件很容易(只需创建一个包含新文件的普通 Web 项目结构,其余的 WAR 插件将完成),但修改它们并不容易.如果你真的想要那个,你必须运行类似 replacer 插件 在提取原始 WAR 之后但在项目的打包阶段之前.也可以下载 (WAR) 文件而不是使用一些奇特的插件从 repo 获取它,但这可能不是您应该做的事情,因为它吹走了 Maven 的一半好处.

It doesn't assume that the WAR is a Maven project, whatever that means, just that the WAR is a Maven artifact. You can install any WAR as an artifact, it does not matter how it was built. If you then declare a dependency to this artifact, you'll be able to overlay it. While it is easy to add and replace files (just create a normal web project structure containing the new files and the WAR plugin will do the rest), it is not easy to modify them. If you really wanted that, you'd have to run something like the replacer plugin after the original WAR is extracted but before the package phase of your project. It is also possible to download a (WAR) file instead of getting it from a repo by using some exotic plugins, but this is probably not something you should be doing as it blows away half the benefits of Maven.

至于将新建的应用部署到远程Tomcat,而可以使用 Tomcat 插件,这不是我从 Maven 做的事情.它通常是构建服务器的工作,例如Jenkins,而Tomcat插件更多用于本地开发和测试.

As for deploying the newly-built application to a remote Tomcat, while doable using the Tomcat plugin, it is not something I would be doing from Maven. It is usually a job for a build server, like e.g. Jenkins, while the Tomcat plugin is more for local development and testing.

这篇关于使用 Maven 自动化自定义战争文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆