I'm using Maven 3 to package a WAR file, and I cannot figure out how to exclude files in src/main/webapp
from the final WAR generated. One of the directories in src/main/webapp
is a git submodule, and I want to exclude files like README, docs/, etc. in that git submodule form going to my final WAR.
My initial attempt was to use the maven-antrun-plugin
to delete the files. I tried the delete actions in prepare-package
and package
, but neither worked. Doing the deletes in package
removed the files from my target/<projname>/...
, but the final WAR still contains the files. Running maven with -debug
shows that the files are deleted after the WAR file is generated. It's almost as if I want to do the deletes in between prepare-package
and package
.
My next attempts were to try to specify files to exclude from the WAR (some solutions linked below), but nothing seems to work. I might not be specifying the path to the unwanted files correctly, and I'm wondering if it has to do with the fact that my unwanted files are not in src/main/resources
, but in src/main/webapp
.
I've tried many solutions, but nothing seems to work. Each time I try something new, I do mvn clean
and delete the target
directory. The final generated WAR file always contains the unwanted files.
I feel like the answer to my problem exists on the SO and google searches I've come across, but nothing I've tried has worked exactly as I need. Below are some solutions I've tried.