Search code examples
sonarqubebuildr

Sonar and Apache Buildr


can anyone tell me how to integrate Sonar and Apache Buildr?

I downloaded sonar.rb from https://github.com/apache/buildr and placed it in /var/lib/gems/1.8/gems/buildr-1.4.6/addon/buildr

But I don't know how to call this task from my project. I have already added a

require 'buildr/sonar'
include Buildr::Sonar

I don't know where I have to configure the sonar properties.

Thank you, Soccertrash


Solution

  • The Sonar extension uses the underlying ant task and passes parameters from buildr to ant. The parameters that you can use will be documented in the next release of Buildr. But to get you started here is a simple example that uses all the configuration parameters. The only property that must be set is "enabled", while the remainder attempt to have sensible defaults.

    require 'buildr/sonar'
    
    define "foo" do
      project.version = "1.0.0"
    
      define "bar" do ... end
    
      sonar.enabled = true
      sonar.project_name = 'Foo-Project'
      sonar.key = 'foo:project'
      sonar.jdbc_url = 'jdbc:jtds:sqlserver://example.org/SONAR;instance=MyInstance;SelectMethod=Cursor'
      sonar.jdbc_driver_class_name = 'net.sourceforge.jtds.jdbc.Driver'
      sonar.jdbc_username = 'sonar'
      sonar.jdbc_password = 'secret'
      sonar.host_url = 'http://127.0.0.1:9000'
      sonar.sources << project('foo:bar')._(:source, :main, :java)
      sonar.binaries << project('foo:bar').compile.target
      sonar.libraries << project('foo:bar').compile.dependencies
    
    end