Speed up maven war plugin

旧时模样 提交于 2019-12-03 06:08:47

I suggest that you use the use the war:inplace goal of maven-war-plugin together with a custom maven-antrun-plugin task.

The war:inplace will generate the webapp in the WAR source directory. It will create all necessary extra folders under webapp.

The antrun:run can be customized to create the war according to your special requirements.

This will potentially improve the performance since most of those resource files you have will still be in the webapp folder and not being copied.

Just want to mention that there is a useCache setting which significantly increases performance (~3 minute instead of 12). However it is acceptable for development only, not for CI-server which should always do clean builds.

In the configuration section for the war plugin, use warSourceExcludes to exclude unneeded files and directories. In the example below, the directories components and node_modules will be excluded from the exploded war as well as from the final war. In my case this reduced the build time from 3 minutes to 14 seconds.

        <configuration>
              <warSourceExcludes>
                components/**,
                node_modules/**
              </warSourceExcludes>
        </configuration>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!