Speed up maven war plugin

kan picture kan · Oct 10, 2012 · Viewed 7.9k times · Source

The maven plugin works very slow for me. In my project the webapp folder has nearly 15000 small files (images, jsp, css, etc). When I assemble it with the maven, it first copies all files to the target/myProject-1.0.0 directory, then builds myProject-1.0.0.war file from it. The copy process takes 10 minutes, building the .war takes 2 minutes.

As I see the build could be much faster if the .war file will be assembled straight from the webapp folder. Is it possible to do?

Answer

Victor Ionescu picture Victor Ionescu · Jan 3, 2017

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>