在 PMD 中添加自定义规则 - class 未找到问题
Adding custom rules in PMD - class not found issue
我正在尝试执行此处显示的示例
http://pmd.sourceforge.net/pmd-5.3.0/customizing/howtowritearule.html
WhileLoopsMustUseBracesRule class 显示未找到 [我认为是初学者的标准问题之一]
尝试过的方法:
1) cd pmd-5.3.0
2) created WhileLoopsMustUseBracesRule.java and ruleset.xml as per shown in the page.
3) javac -cp [all the required jar files seperated by ; since it is windows pc ] WhileLoopsMustUseBracesRule.java
4) bin/pmd.bat -d [code on which pmd has to check the rule] -f xml -R ruleset.xml
以上步骤没有给我 class 发现错误,开发人员在这里评论说这些步骤有效
[ http://sourceforge.net/p/pmd/discussion/188192/thread/7a34d224/ ]
如果我遗漏了什么,请告诉我。
我也尝试将 class 文件直接添加到 classpath
尝试过的其他方法:
1) compiled the WhileLoopsMustUseBracesRule.java file and got the .class file.
2) created a jar using jar -cf jar_name jar_file command
3) added that jar file in the class path , using set CLASSPATH and also tried adding directly in the batch file used to run PMD i.e. pmd.bat
请帮忙!
我找到了解决方案!
必须使用
单独设置 CLASSPATH
set CLASSPATH=path\to\my\classfile
然后在批处理中我必须添加 %CLASSPATH% ,否则我猜使用 -cp 会重置类路径。这对我有用。
谢谢
我正在尝试执行此处显示的示例
http://pmd.sourceforge.net/pmd-5.3.0/customizing/howtowritearule.html
WhileLoopsMustUseBracesRule class 显示未找到 [我认为是初学者的标准问题之一]
尝试过的方法:
1) cd pmd-5.3.0
2) created WhileLoopsMustUseBracesRule.java and ruleset.xml as per shown in the page.
3) javac -cp [all the required jar files seperated by ; since it is windows pc ] WhileLoopsMustUseBracesRule.java
4) bin/pmd.bat -d [code on which pmd has to check the rule] -f xml -R ruleset.xml
以上步骤没有给我 class 发现错误,开发人员在这里评论说这些步骤有效 [ http://sourceforge.net/p/pmd/discussion/188192/thread/7a34d224/ ]
如果我遗漏了什么,请告诉我。
我也尝试将 class 文件直接添加到 classpath 尝试过的其他方法:
1) compiled the WhileLoopsMustUseBracesRule.java file and got the .class file.
2) created a jar using jar -cf jar_name jar_file command
3) added that jar file in the class path , using set CLASSPATH and also tried adding directly in the batch file used to run PMD i.e. pmd.bat
请帮忙!
我找到了解决方案!
必须使用
单独设置 CLASSPATHset CLASSPATH=path\to\my\classfile
然后在批处理中我必须添加 %CLASSPATH% ,否则我猜使用 -cp 会重置类路径。这对我有用。
谢谢