只复制maven-war-plugin中修改过的文件
我目前正在使用 Maven 3.x 和 maven-war-plugin。对于开发人员构建,我希望能够使用 war:exploaded 目标,但仅复制已更改的资源。有办法做到这一点吗?
我一直在浏览文档,但无法找到在当前版本中执行此操作的方法,但曾经(在旧的 Maven 1.x 版本中)有一个属性 maven.war.resources.overwrite ,会允许这样做。
谢谢。
I'm currently using maven 3.x with the maven-war-plugin. For developer builds I would like to be able to use the war:exploaded goal, but only copy resources that have changed. Is there a way to do this?
I've been looking through the docs and have not been able to find a way to do this in the current versions, but there used to be (in the old maven 1.x version) a property maven.war.resources.overwrite that would allow this.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道使用 maven-war-plugin 执行此操作的方法,但如果您的 IDE 支持它,您可以让 IDE 自动部署更改。例如,Eclipse 的 Web 工具平台支持 Tomcat 的此功能。但是,如果您的构建过程很复杂或者在调用 maven-war-plugin 之前做了一些奇怪的事情,那么这可能不适合您。
第二个选项:如果您运行的是 Linux,请设置 rsync 以将最近修改的文件复制到您的 servlet 容器。一位同事通过将 servlet 容器的 Web 应用程序目录与 Eclipse 项目的输出目录同步来做到这一点,并且效果很好(只需修改您的代码,Eclipse 将自动构建它,rsync 将复制您的更改)。
I'm not aware of a way to do this using the maven-war-plugin, but if your IDE supports it, you could have the IDE auto-deploy changes. For example, the Web Tools Platform for Eclipse supports this feature for Tomcat. However, if your build process is complex or does something weird before invoking the maven-war-plugin, this may not work for you.
A second option: if you're running Linux, set up rsync to copy recently modified files to your servlet container. A co-worker did this by having the servlet container's web app directory sync with the Eclipse project's output directory, and it worked well (just modify your code, Eclipse will build it automatically, and rsync will copy your changes).
为此,我使用 maven-antrun-plugin
示例:
然后使用参数运行 maven:
mvn pom.xml compile install org.apache.maven.plugins:maven-war-plugin:2.1-alpha-1:exploded
结果只有更改的文件将被重新编译,并且只有重新编译的文件将在 tomcat webapp 目录中被替换。
For this purpose I use maven-antrun-plugin
Example:
Then run maven with params:
mvn pom.xml compile install org.apache.maven.plugins:maven-war-plugin:2.1-alpha-1:exploded
As result only changed files will be recompiled and only recompiled filed will be replaced in tomcat webapp dir.