You should check out CheckStyle. It will fit your needs. It was a lot of out of the box tasks like:
<module name="VisibilityModifier">
<property name="packageAllowed" value="true"/>
</module>
But you can extend it.
You write your custom rules in Java, but it check anything. In our project, we use it e.g. to check the vadility of xml, jsp, ... files.