Sonar scanner for Play?

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    SonarQube 8.9.0-DE (dockerized)
  • what are you trying to achieve
    We need to analyze application written in Play framework, (java CRUD, not maven or gradle)
  • what have you tried so far to achieve this
    Used standard sonar java setup, resulted in error:
-----------------------------------
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
	at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
	at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
	at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
	at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
	at org.sonar.runner.api.Runner.execute(Runner.java:100)
	at org.sonar.runner.Main.executeTask(Main.java:70)
	at org.sonar.runner.Main.execute(Main.java:59)
	at org.sonar.runner.Main.main(Main.java:53)
Caused by: org.sonar.squid.api.AnalysisException: SonarQube is unable to analyze file : '/<<Jenkins Job path>>/workspace/apiui/WEB-INF/application/modules/crud/app/controllers/CRUD.java'

Hi @Jaff ,

Can you provide a sample toy project that reproduces your issue? If so, please link/attach it here and I can take a look.

Joe

Here is an example project; it does not have any build/analysis file associated as yet.playSampleProjects.zip (222.1 KB)

Hi @Jaff ,

Thanks for the sample projects. I scanned your helloworld project with SonarQube 8.9.1 (with latest version of Sonar scanner CLI) with this command:

sonar-scanner -Dsonar.projectKey=play-helloworld -Dsonar.login=<INSERT-USER-TOKEN> -Dsonar.host.url=http://localhost:9000 -Dsonar.java.binaries=tmp/classes -Dsonar.java.libraries=lib  

If you are not using Maven or Gradle, then you need to use sonar-scanner CLI and ensure you set sonar.java.binaries (see Java | SonarQube Docs for more information). You may need to adjust sonar.java.binaries and sonar.java.libraries (and set proper sonar.exclusions also).