How can I exlude files from WAR when using WAR plugin against default or webAppDirName location

Yes - the jar files are actually coming from the web apps classpath and they are getting thrown into the web-inf/lib directory in the war file.

So these files are not in your webapp source directory, and are not controlled by an exclude element.

But the example I provided was illustrative only. There are plenty of other examples such as trying to exclude the .class files which would be on the src/main/webapp path.

But this example is the same as above. Unless your project is very unusual, ‘.class’ files will not be located under ‘src/main/webapp’. Are they?

Again, ‘exclude’ controls the files that are copied from ‘src/main/webapp’ to the war. It doesn’t control the files that are included in the WEB-INF directory, such as those coming from the classpath. To control these files, you need to work with the ‘classpath’ property of the war task.

Also, if I set the webAppDirName to ‘WebContent’, all the content is being included and I am not able to exclude any content such as .xml, .html, .jsp files, etc…

This also works fine for me.

What is the best way to provide a zip file of a sample app?

A github repository is often the easiest. Otherwise, you could share a zip file via dropbox, Google Drive, etc, and link it here.