简体   繁体   中英

Configuring eclipse plugin PMD to use multiple rulesets

I find PMD very useful tool. So I have installed PMD eclipse plugin.

With PMD, we can define multiple ruleset files. One of the reason I have multiple rulesets file is that I need to exclude some classes from some rules say naming rules but not all. I achieved this by defined those rules in a separate ruleset file and using element. This is fine as far ant build is concerned. However, I would like to use the same ruleset files for PMD eclipse plugins to ensure that executing PMD using ant or eclipse generates same result.

I do not see an option to select multiple ruleset files for PMD eclipse plugin. Is there a way to select multiple ruleset files or any other alternative?

Please help.

Thanks

A rulesets references rules and built-in rulesets - and it can reference custom rulesets too. Just create a wrapper-ruleset.xml for basic-ruleset.xml and codesize-ruleset.xml:

<ruleset xmlns="http://pmd.sf.net/ruleset/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="pmd-eclipse" xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd" xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd">
    <rule ref="basic-ruleset.xml"/>
    <rule ref="codesize-ruleset.xml"/>
</ruleset>

You can then use wrapper-ruleset.xml in Eclipse.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM