It looks like there’s a few different things going on here, although one of your solutions does actually work.
First, we can eliminate the ones that absolutely will not work:
The first few that use exclude(...)
alter the mainSpec, but the classpath resources that are by default added to the War file are added to a different copySpec. Additionally, we don’t want to consider the into location. Your excludes that do work look like files that are actually in a WEB-INF folder in src/main/webapp. The last couple specify the rootSpec, so will have an effect on the spec that contain the resources, but without a **/
in front of the file name, it will only exclude those files if they are at the root path of the copy location not under /manual.
That leaves the one that does work:
This one affects the rootSpec and specifies a path that matches where you said the DOCBOOK XML files are located.
However, if you are just making changes to the excludes and running a task to create a new war, Gradle is considering that things are UP-TO-DATE, so that may be the reason that this particular attempt didn’t appear to work for you. After running clean, this should work as expected.
You also have the option that if you don’t care for these XML files to be copied from the src/main/resources to the build/resources/main folder (not just excluded when build/resources/main is copied to the War), you could use:
processResources {
exclude('manual/*.xml')
}