简体   繁体   English

使用Maven自动执行自定义War文件

[英]Automate custom war files using maven

I know about maven war overlays, but they assume that the original war file is a maven project. 我知道有关Maven War的信息,但是他们认为原始War文件是Maven项目。

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? 如果我只能访问打包的war文件,并且需要使用maven通过添加新资源或更新属性文件中的几个值来进行修改,然后将新覆盖的打包war文件推送到服务器上的tomcat,该怎么办?

Is it too complex to do this in maven? 在Maven中这样做太复杂了吗?

If I install the war file in my repository does the maven build process automatically use it? 如果我在仓库中安装了war文件,那么maven构建过程会自动使用它吗?

It doesn't assume that the WAR is a Maven project, whatever that means, just that the WAR is a Maven artifact. 它并不假设WAR是Maven项目,无论这意味着什么,仅假设WAR是Maven工件。 You can install any WAR as an artifact, it does not matter how it was built. 您可以将任何WAR作为工件安装,无论其构建方式如何。 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. 尽管添加和替换文件很容易(只需创建一个包含新文件的普通Web项目结构,WAR插件即可完成其余工作),但修改它们并不容易。 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. 如果确实需要,则必须在提取原始WAR之后但在项目的打包阶段之前运行类似replacer插件的操作。 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. 也可以下载(WAR)文件,而不是通过使用某些特殊的插件从存储库中获取文件,但是您可能不应该这样做,因为它浪费了Maven的一半好处。

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. 至于将新建的应用程序部署到远程Tomcat上,虽然可以使用Tomcat插件实现 ,但我不是从Maven要做的。 It is usually a job for a build server, like eg Jenkins, while the Tomcat plugin is more for local development and testing. 对于诸如Jenkins之类的构建服务器而言,这通常是一项工作,而Tomcat插件更多地用于本地开发和测试。

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

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