...
Example of structure :
- sonar-foo-plugin/
- src/
- main/
- java/
- com/
- foo/
- MyWidget.java
- foo/
- com/
- resources/
- com/
- foo/
- my_widget.html.erb
- foo/
- com/
- java/
- main/
- src/
...
To enable the development mode on a widget :
- Install SonarSonarQube
- Edit the method
RubyRailsWidget#getTemplatePath()in order to return the absolute path but not the class path. - Build the plugin and copy it to /extensions/plugins
- Start server
Do not forget to revert the path before commiting your changes
...
| Info |
|---|
Ruby on Rails applications are supported since Sonar 3SonarQube3.0. |
Ruby on Rails applications allow plugins to extend the Sonar SonarQube webapp with a complete MVC stack : controllers, helpers, models and views. Contrary to widgets, it does not require to declare a Java component. Ruby sources just have to be stored in the plugin directory : /src/main/resources/org/sonar/ror/<plugin key>. This directory must also contain an empty file named init.rb.
...
Controller URLs are not isolated from the core URLs used by SonarSonarQube. You have to be careful of potential conflicts and choose controller names different than : https://github.com/SonarSource/sonar/tree/master/sonar-server/src/main/webapp/WEB-INF/app/controllers
| Code Block | ||||
|---|---|---|---|---|
| ||||
class MyConsoleController < ApplicationController
# this is an administration console
SECTION=Navigation::SECTION_CONFIGURATION
before_filter :admin_required
# GET http://<server>/my_console/index
def index
# automatically renders the file ../views/my_console/index.html.erb
end
end |
...
To enable the development mode on an application :
- Install SonarSonarQube
- Install the plugin by copying the initial JAR file to /extensions/plugins
- Edit the file war/sonar-server/WEB-INF/web.xml and set the context-params
rails.envtodevelopmentandjruby.max.runtimesto3. Edit the file war/sonar-server/WEB-INF/config/environment.rb and set the absolute path to your ruby application by replacing the property
config.plugin_paths:Code Block #config.plugin_paths << "#{Java::OrgSonarServerUi::JRubyFacade.getInstance().getServerHome()}/temp/ror" config.plugin_paths << '/absolute/path/to/sonar-foo-plugin/src/main/resources/org/sonar/ror'- Start server
...
| Info | ||
|---|---|---|
| ||
The Java extension point org.sonar.api.web.RubyRailsWebservice is still supported but is useless since Sonar SonarQube 3.0. |
Static files
Plugins can provide static files like images, CSS or JS files. They have to be copied in src/main/resources/static and then can by accessible from the public URL :
...
| Info |
|---|
Static files are not deployed on the fly when the development mode is enabled. The plugin has to be built and re-installed after changes. |
Dynamic charts
Sonar SonarQube integrates JFreechart Eastwood 1.1.0, a partial implementation of the Google Chart API . To know if a chart is implemented, simply replace http://chart.apis.google.com/chart?<params> by http://<sonar>/gchart?<params>.
...

