Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jacoco and Sonar PlayFramework 2.6 #104

Open
dorianboulch opened this issue Jan 5, 2018 · 5 comments
Open

Jacoco and Sonar PlayFramework 2.6 #104

dorianboulch opened this issue Jan 5, 2018 · 5 comments

Comments

@dorianboulch
Copy link

I'm using sbt-jacoco with a Play Framework (v2.6) and Sonar (sbt-sonar-scanner-plugin).
When I run sbt jacoco and then sbt sonar I have this error :
(*:sonar) java.lang.IllegalStateException: Line 13 is out of range in the file app/model/MyModel.java (lines: 10)

In Play, there is by default a plugin "sbt-play-enhancer" that generates getters/setters automatically. I suppose sonar doesn't execute this plugin but jacoco yes. This would explain the difference of number of line in the java file.

Have you got an idea about how to solve this ?

I tried this and many other configurations in my build.sbt file:

sonarProperties ++= Map(
  "sonar.host.url" -> "http://localhost:9000",
  "sonar.login" -> "mytoken",
  "sonar.projectKey" -> "myProjectKey",
  "sonar.projectVersion" -> version.value,
  "sonar.junit.reportPaths" -> "target/test-reports",
  "sonar.jacoco.reportPaths" -> "target/scala-2.12/jacoco/data/jacoco.exec",
  "sonar.sourceEncoding" -> "UTF-8",
  "sonar.sources" -> sourceDirectory.in(Compile).value.absolutePath,
  "sonar.tests" -> sourceDirectory.in(Test).value.absolutePath,
  "sonar.java.binaries" -> classDirectory.in(Compile).value.absolutePath,
  "sonar.java.test.binaries" -> classDirectory.in(Test).value.absolutePath,
  "sonar.java.libraries" -> dependencyClasspath.in(Compile).value
    .map(p => p.data.absolutePath)
    .mkString(","),
  "sonar.java.test.libraries" -> dependencyClasspath.in(Test).value
    .map(p => p.data.absolutePath)
    .filter(s => s.endsWith(".jar"))
    .mkString(",")
)

jacocoInstrumentedDirectory := classDirectory.in(Compile).value

Environment

  • SBT version: 0.13.15
  • Plugin version: 3.0.3
  • Scala version(s): 2.12.2
  • Java version: 8
@dorianboulch
Copy link
Author

Someone to help me ?

@dorianboulch
Copy link
Author

Is this repo still maintained?

@MarkJiaLinWu
Copy link

the same to you . I don't have the coverage showed in sonar

@abdelrahmanmohamed1990
Copy link

having the same issue play 2.8

@sairamyadavg
Copy link

having the same issue play 2.8

Can you provide sonar version which you are using? Report generation is dependent on sonar version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants