11

We have a pretty standard web project using Java, which contains also some javascript code in the standard src/main/webapp folder. We are using Gradle 2.14 as our build tool.

We have just installed a brand new Sonarqube 6.0.1 on a fresh server, checked that both the Java and Javascript plugins are installed, and modified the build.gradle file as recommended on the Sonarqube documentation:

plugins {
    id 'org.sonarqube' version '2.0.1'
}

sonarqube {
    properties {
        property 'sonar.projectName', 'Our-Project'
        property 'sonar.projectKey', 'com.ourcompany:our-project'
    }
}

This doesn't work as expected: the java code is analyzed correctly and we can browse the results on sonar, but the javascript code isn't analyzed.

What are we doing wrong? Thanks.

G. Ann - SonarSource Team
  • 22,346
  • 4
  • 40
  • 76
Andrea Bergia
  • 5,502
  • 1
  • 23
  • 38

2 Answers2

7

I have managed to fix our issues by adding this property inside the sonarqube block:

property 'sonar.sources', 'src/main'
Andrea Bergia
  • 5,502
  • 1
  • 23
  • 38
2

Are you sure the sonar.sources is including the js files in the analysis? Can you add the module's gradle config? The file above looks like the app level gradle file. You should have at least one module for your app that also has a gradle file.
Android Studio Project Structure

You need to add the sources to the module's gradle file. Here's an example:

project(":app") {
    sonarqube {
        properties {
            property "sonar.analysis.mode", "publish"
            property "sonar.sources", "src/main/java"
            property "sonar.java.binaries", 
                "build/intermediates/classes/debug"
            property "sonar.junit.reportsPath", 
                "build/test-results/developDebug"
            property "sonar.android.lint.report", 
                "build/outputs/lint-results-developDebug.xml"
            property "sonar.test", "src/test/java"
        }
     }
 } 
  • I am not sure whether sonar is picking up the js files; it seems it isn't, but I haven't changed any of the default settings and I expected it to work out of the box to be honest. I don't have any submodules, which is why the file above looks like the app level gradle file - it _is_ the top level file. – Andrea Bergia Sep 01 '16 at 06:37
  • I added a screen shot of a typical project in android studio showing the module level gradle file. – Beren Erchamion Sep 02 '16 at 11:38