Hi everybody.
I'm trying to use the sonar generic coverage plugin on my projet. This is a multi-module maven project, let's say something like this :
root
|-- module1
| |-- sources
| | |-- com.foo.Foo.java
| | |-- ...
| |-- tests
| | |-- com.foo.FooTest.java
| | |-- ...
|-- module2
| | |-- com.bar.Bar.java
| | |-- ...
| |-- tests
| | |-- com.bar.BarTest.java
| | |-- ...
.... many many modules (jar, ejb, war, ear)
As you can see, projects don't use the standard maven (src/main/java, src/test/java), and it is probably the reason of my problems.
In maven, we configure the <sourceDirectory> to sources and <testSourceDirectory> to tests, normal.
I use the plugin com.qualinsight.mojo.cobertura to get the coverage of my tests and it works well, coverage.xml and converted-coverage.xml are generated in each module (target/cobertura/ut/).
Then, when running mvn sonar:sonar from the root project, i have the message in each module :
[INFO] Imported coverage data for 0 files
[INFO] coverage data ignored for x unknown files, including....
I first tried to allow import unknown files but did not change anything.
So I cloned the projet (generic coverage) and add some logs in the ReportParser#parseFiles method.
First I logged the fileSystem with all() predicate. I obtained something logical:
D:\workspace\module1\source\com\foo\Foo.java
Then, i logged the filePath (retrieve with mandatoryAttribute(fileCursor, "path")) and here is the trouble:
src/main/java/com/foo/Foo.java
Why is it src/main/java ? What is SMInputCursor, SMHierarchyCursor, ... and why it does not use the maven source directory configuration ?
I tried to configure sonar with the following properties :
<sonar.sources>.</sonar.sources>
<sonar.exclusions>target/**, tests/**</sonar.exclusions>
But it does not change anything except that sonar browse more files...
Please, anyone has an idea ?
Thanks.
Jerome