Search code examples
mavensonarqubesonarqube5.1.2

How to use incremental mode in SonarQube?


I've trying to fiddle with SonarQube and now I'm learning about the incremental mode. In my understanding it should analyze only the changed files.

So my first test is just to run SonarQube twice on our project without any change. I run SonarQube (5.1.2) installed locally on windows 7 64-bit machine with SSD drive and I7 CPU. We use java 1.7 and Maven 3.3.3. Our project is fairly big (~570 modules) of maven, most of them are java code. After I run a prepare-agent of jacoco along with my unit tests I understand that its time to run sonar:sonar and create a report.

So what I try is:

mvn sonar:sonar -Dsonar.analysis.mode=incremental -Dsonar.host.url=http://localhost:9000 -Dsonar.java.coveragePlugin=jacoco

This runs for 20 minutes. Ok, now I run the same command again without doing any change and it still runs the same 20 minutes

So my question is - whether someone can explain me how to use the incremental mode correctly? I have a hard time understanding what I'm doing wrong, in my understanding the second run has to be much faster, otherwise I don't see any advantage over the preview mode here.

Thanks Mark


Solution

  • The incremental mode will analyze only changed files since latest "regular" analysis on server. So in your case you should first run a normal (now called "publish") analysis:

    mvn sonar:sonar -Dsonar.java.coveragePlugin=jacoco
    

    Then your can use the incremental mode:

    mvn sonar:sonar -Dsonar.analysis.mode=incremental -Dsonar.java.coveragePlugin=jacoco