Search code examples
mavenmaven-2

Rename static files on maven war build


I am trying to figure out a way by which I could rename the static files I have in my web project, all of them at the same time.

Exactly what I need is to be able of filtering all my statics filenames to add a version number or something similar just to avoid them from being cached by browsers.

Something like converting custom.css into custom-1.23.css where 1.23 would be the value of a given filter.

This behaviour looks really similar to what resources plugin does with the content of the files, but I couldn't find a way of doing the same with the filenames.

Does anyone knows something similar?

Thanks a lot


Solution

  • You could change the directory they are served from rather than the file name e.g.

    /static/${version}/custom.css

    The resources plugin would let you change the target directory in the war.