简体   繁体   English

SonarQube Java插件自定义规则-部署

[英]SonarQube Java plugin custom rule - deploy

I am using SonarQube 4.2 with sonar-java-plugin-2.2.1. 我正在将SonarQube 4.2与sonar-java-plugin-2.2.1。 I am trying to deploy a custom rule based on the BaseTreeVisitor ( https://github.com/SonarSource/sonar-examples/blob/master/plugins/java-custom-rules/src/main/java/org/sonar/samples/java/ExampleCheck.java ). 我正在尝试基于BaseTreeVisitor部署自定义规则( https://github.com/SonarSource/sonar-examples/blob/master/plugins/java-custom-rules/src/main/java/org/sonar/samples /java/ExampleCheck.java )。

I am using gradle(not maven) to create jar (containing ExampleCheck) and than I copy this jar to sonarqube-4.2/extensions/plugins. 我正在使用gradle(不是maven)创建jar(包含ExampleCheck),然后将其复制到sonarqube-4.2 / extensions / plugins。

I expected to see ExampleCheck rule (with key nomethod)in the in/active rules after sonar will get up. 我希望在声纳起床后,在活动规则中可以看到ExampleCheck规则(带有关键的方法)。

But no such rule appears. 但是没有这样的规则出现。 On the page http://docs.sonarqube.org/display/SONAR/Extending+Coding+Rules is nothing about deployment to the Sonarqube. http://docs.sonarqube.org/display/SONAR/Extending+Coding+Rules页面上,与部署到Sonarqube无关。

Is anything on above described deployment wrong? 上述部署有什么问题吗? How to deploy ExampleCheck rule to SonarQube 4.2 ? 如何将ExampleCheck规则部署到SonarQube 4.2?

规则本身不会显示,需要由插件注册。

To complete @Mithfindel answer : 完成@Mithfindel答案:

You can have a look at JavaExtensionRuleRepository and JavaExtensionPlugin in the github repository you mentioned to create your own plugin that will register the rules. 您可以在提到的github存储库中查看JavaExtensionRuleRepositoryJavaExtensionPlugin ,以创建自己的插件来注册规则。

You would have then to deploy this plugin to see your custom rule appear. 然后,您必须部署此插件才能看到您的自定义规则。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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