Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Example of structure :

  • sonar-foo-plugin/
    • src/
      • main/
        • java/
          • com/
            • foo/
              • MyWidget.java
        • resources/
          • com/
            • foo/
              • my_widget.html.erb

...

To enable the development mode on a widget :

  1. Install SonarSonarQubeTM
  2. Edit the method RubyRailsWidget#getTemplatePath() in order to return the absolute path but not the class path.
  3. Build the plugin and copy it to /extensions/plugins
  4. Start server
  5. (warning)Do not forget to revert the path before commiting your changes

...

Info

Ruby on Rails applications are supported since Sonar SonarQubeTM 3.0.

Ruby on Rails applications allow plugins to extend the Sonar SonarQubeTM 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 SonarSonarQubeTM. 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

...

To enable the development mode on an application :

  1. Install SonarSonarQubeTM
  2. Install the plugin by copying the initial JAR file to /extensions/plugins
  3. Edit the file war/sonar-server/WEB-INF/web.xml and set the context-params rails.env to development and jruby.max.runtimes to 3.
  4. 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'
  5. Start server

...

Info
iconfalse

The Java extension point org.sonar.api.web.RubyRailsWebservice is still supported but is useless since Sonar SonarQubeTM 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 SonarQubeTM 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>.

...