mvn installfrom the project root directory and then use the zip in
pmd-dist/target/pmd-bin-<version>.zip(but not the stuff in target/classes directly). But really the easiest way to install PMD is to not fiddle with the sources and to download a prebuilt archive from here, and to install it somewhere by just unzipping it.
findDescendantsOfType(...). See also https://pmd.github.io/latest/pmd_userdocs_extending_writing_pmd_rules.html
RuleContext#setAttribute(String, Object). But we are missing a final call at the end of the analysis of all files, where you could analyse the collected data and report violations based on this. It might be part of PMD 7, but that's not sure yet.