Removing files from a war file?

I have a war project. The war file builds fine but I need to remove some of the libs/projects from the final war archive. Since the dependency tree for the war project might change I cannot statically add the relevant dependencies to the “providedCompile” configuration and thereby removing them from the final archive.

Is there a way to enter a build phase in gradle just before the war archive is created and do a filtering of the content based on some special conditions?