Source code analysis is not happening for the groovy gradle based project

SonarQube version using 9.9.6.92038

  • SonarQube deployed: Docker
  • I am trying to get a source code analysis for a groovy gradle based project. I have generated the jacoco repotrs and given the source destination and class destination also. It is showing how much percentage of coverage i will get after i merge, But the source code analysis is not happening. On new code it is showing nothing since it is not able to read my source code. does anyone face this before. I have mutiple projects configured and my android projects are working fine. but my groovy projects is not getting code anaysis.

Hi,

Welcome to the community!

This implies that you’re analyzing a pull request.

But pull request analysis only analyzes what changed in the pull request. Since you seem to still be in a testing phase… did you actually change any code? Because if you didn’t, then it’s quite normal not to see much in SonarQube after you analyze the PR.

 
HTH,
Ann

Hi,
Yes you are right, This is about analyzing PR.
We had this in place before and recently we moved to developer edition.
As you said i have some changes in my PR, and still it didnt show any code change or analysing my code.
I am using this sonarTask in couple projects, and the android projects works fine. But the groovy based gradle projects are one not showing any code change or failing in the pr analysis.
I have set these properties also.

sonar {
    properties {
        property 'sonar.host.url', "${ -> (ciExtension.getSonarUrl)() }"
        property 'sonar.login', "${ -> (ciExtension.getSonarToken)() }"
        property 'sonar.java.coveragePlugin', 'jacoco'
        property 'sonar.android.lint.report', 'build/reports/lint-results.xml'
        property "sonar.java.binaries", "build/classes/groovy"
        property "sonar.groovy.binaries", 'build/classes/groovy'
        property "sonar.inclusions", "**/*.groovy, **/*.java"
        property 'sonar.coverage.jacoco.xmlReportPaths', 'build/reports/test/jacoco.xml'
        property 'sonar.junit.reportPaths', 'build/test-results/test'
        property 'sonar.sources', 'src, vars'
        property 'sonar.tests', 'test'
        property 'sonar.pullrequest.key', prKey
        property 'sonar.pullrequest.branch', branch
        property 'sonar.pullrequest.base', fub
     }
}

Hi,

It looks like you’re using the vanilla SonarScanner CLI for analysis. But… how are you building your Groovy projects? With Gradle? If so, you should be using the SonarScanner for Gradle. Among other things, it’ll save you a log of configuration.

Speaking of configuration, this does nothing and can be removed:

Can you provide your analysis log?

The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

This guide will help you find them.

 
Thx,
Ann

  1. I am building my project with gradle and I am using sonarScanner for gradle.
  2. when I saved the log files and try to upload, the system is not allowing me to upload it says the size is too big.
  3. I have took debug logs, can I copy paste it here?

Hi,

Perfect! Thanks for clarifying.

Can we start with an --info log? That should be a reasonable size, and a good starting point.

 
Thx,
Ann

sure i am adding the info logs here
sonar-info-log.zip (14.5 KB)

Thank you

Hi,

Pull request a421605-dev for merge into v3UninstallApk from a421605-dev

The log you’ve provided is a PR analysis log. For PRs, we only analyze & report on the lines/files that were changed in the PR. So, what changed in this PR?

 
Thx,
Ann

Hi,
I have added couple of methods and even if add a new file this is not showing as a new change in the PR analysis.

Thank you

Hi,

Can you provide a --info log of that analysis?

 
Thx,
Ann

Hi,
That’s the log which i provided above.

Thank you

Hi,

The log you provided above is of this?

 
Thx,
Ann

yes it is,
I have run gradle clean, test, and jacocoReport tasks before running sonar task.
And I have added --info also to sonar task.

Hi,

Thanks for that clarification. Looking back at that log, nothing jumps out at me. Since this is Groovy, and we don’t support it natively, I would normally advise you to reach out to the maintainers of that plugin. However, I believe it’s abandoned.

 
Ann

Hi,

The plugin you are mentioning is Jacoco ?.

Thank you

Hi,

The plugin I’m mentioning is Groovy.

 
Ann

Hi,
I am not using any groovy plugins for sonar specific task, I just use groovy-gradle-plugin.

Thank you

Hi,

What language are you coding in?

 
Thx,
Ann

groovy,

Hi,

We don’t natively support the analysis of Groovy.

 
HTH,
Ann