Groovy Unable to Load XML from Jar Resource

I see a couple of odd things here.

You say you put “pmd-ruleset.xml” in “src/main/resources”. That directory is the default location for non-test resources, but you’re overriding that location with your sourceset declaration, so it will think your resources are in “src/main”. Then you say that the xml file is in the root of the jar, which seems hard to believe, from what I’m seeing here.

Then, you show the code that references “/pmd-ruleset.xml”, but the error message clearly says that it couldn’t find “pmdrules/pmd-ruleset.xml”.

Assuming you actually put the file in “src/main/resources”, I would first remove your sourcesets declaration. If you still have problems after that, show us what you’re actually getting, and make sure the code and facts match reality.