Source files are not linked in jacoco report when using regular expression to include source files

1,499 views
Skip to first unread message

minna hu

unread,
Jan 13, 2014, 9:18:57 PM1/13/14
to jac...@googlegroups.com
I use maven-antrun-plugin and org.jacoco.ant.ReportTask to read source codes from multiple projects and then generate jacoco report. 

My project structure is as follows:
|--A
|-- A-jar
|----src/main/java (source files here)
|----target/classes (compiled files here)
|-- A-ear
|-- A-ejb
|--B
|-- B-jar
|----src/main/java (source files here)
|----target/classes (compiled files here)
|-- B-ear
|-- B-ejb 

I have several projects with at the same level of A, and follow the same maven structure, so I repeated <group> definition for each project, and use <include> to specify classfiles and sourcefiles, such as 
                                              <group name="A">
                                                    <classfiles>
                                                        <fileset dir="../../../A">
                                                            <include name="**/target/classes/**/*.class" />
                                                        </fileset>
                                                    </classfiles>
                                                    <sourcefiles encoding="UTF-8">
                                                        <fileset dir="../../../A">
                                                            <include name="**/src/main/java/**/*.java" />
                                                        </fileset>
                                                    </sourcefiles>
                                                </group>

But the problem is:

In the generated jacoco report, source files are not linked. I can track to a single method, but cannot check source code of the method by clicking the method. There is no link url for each method. 

I tried my best to troubleshoot, and find the following facts, but still didn't know why source files are not linked in jacoco report,  please help me, thank you~
  1. <include> of <classfiles> works
  2. if i replace 
  <sourcefiles encoding="UTF-8">
                                                        <fileset dir="../../../A">
                                                            <include name="**/src/main/java/**/*.java" />
                                                        </fileset>
                                                    </sourcefiles>
           with 
<sourcefiles encoding="UTF-8">
                                                        <fileset dir="../../../A/A-jar/src/main/java" />
                                                        <fileset dir="../../../A/A-jar/src/main/java" />
                                                        <fileset dir="../../../A/A-jar/src/main/java" />
                                                    </sourcefiles>
           the source files can be linked

Thank you~

Marc R. Hoffmann

unread,
Jan 14, 2014, 1:40:10 AM1/14/14
to jac...@googlegroups.com
Hi,

see documentation: http://www.eclemma.org/jacoco/trunk/doc/ant.html
Source file resources must always be specified relative to the respective source folder. If directory resources are given, they must directly point to source folders. Otherwise source lookup will not succeed.
A possible solution in your case is to specify a set of source folders instead of files:

    <dirset dir="../../../A">
        <include name="**/src/main/java" />
    </dirset>

Best regards,
-marc
______________________________ Mountainminds GmbH & Co. KG Nussbaumstr. 4 * 80336 Muenchen * Germany Phone/Fax +49-700-68664637 * 0700-MTNMINDS Registergericht Muenchen * HRA 80201 Mountainminds Verwaltungs GmbH Registergericht Muenchen * HRB 143183 Geschaeftsfuehrer Marc Hoffmann

minna hu

unread,
Jan 14, 2014, 3:00:27 AM1/14/14
to jac...@googlegroups.com
<dirset> works, thank you~


--
You received this message because you are subscribed to a topic in the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jacoco/h6-P6ND5xQk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jacoco+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--

Best Regards,
Minna Hu
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages