TODO
mvn package
Notice there will be a jar
file generated, we will use it later.
brew install sonar
Copy the generated plugin jar file to <sonar-path>/libexec/extensions/plugins
and start the sonar server:
sonar start
Login to sonar server as admin/admin
.
Administration
-> System
-> Update Center
-> Installed
, see if the plugin is listed there
The new custom rules not active by default.
We can activate them by:
Rules
-> Repository
-> my custom plugin name -> Bulk Change
-> Sonar way: Java
Go to a maven project, e.g.:
- https://github.com/java-demos/mars-rover-with-if-else-demo
- https://github.com/java-demos/mars-rover-with-enum-demo
and run:
mvn sonar:sonar
It will scan the project and send the results to the sonar server.
Open http://localhost:9000 you will see the results and check if the code breaks your rule.
- Writing custom Java plugins: http://docs.sonarqube.org/display/PLUG/Writing+Custom+Java+Rules+101