I just want to jump in and clarify our change in direction.
A few days ago, Ogi and I sat down and looked at the report mojo in the maven plugin. It's just a single class that gathers some configuration data (most importantly, the location of the jacoco.exec file, the java classes, and the java sources) from the pom.xml and then uses the JaCoCo reporting library to generate the XML and HTML reports.
Then we adapted this class to work within Jenkins and do the same thing: gather configuration data (this time from the job config rather than the pom) and then use the JaCoCo reporting library to generate the XML and HTML reports. After sorting out the asm version conflict, this approach now works!
I think this approach to the integration has several advantages over the XML based integration:
- less burden on users (no need to configure the build to generate the reports) — this was Mickael's point
- produces output identical to the report mojo/ant task
- gives us access to the JaCoCo library for merging coverage data and gathering interesting metrics to plot
- requires much less code in the Jenkins plugin vs. parsing the xml
In all, I think my original adaptation of the emma Jenkins plugin was a useful stopgap, but switching to the .exec file will let us trivially solve all the major issues reported so far while also significantly reducing the amount of code in the Jenkins plugin.
-Jonathan
Well said, Ogi. Looks like we were writing the same email at the same time. :)
-Jonathan
Then we adapted this class to work within Jenkins and do the same thing: gather configuration data (this time from the job config rather than the pom) and then use the JaCoCo reporting library to generate the XML and HTML reports. After sorting out the asm version conflict, this approach now works!
I think this approach to the integration has several advantages over the XML based integration:
- less burden on users (no need to configure the build to generate the reports) � this was Mickael's point
- produces output identical to the report mojo/ant task
- gives us access to the JaCoCo library for merging coverage data and gathering interesting metrics to plot
- requires much less code in the Jenkins plugin vs. parsing the xml
Agreed on these advantages. Especially #1 ;)
Good continuation with that. That's IMHO the good direction, at least for our use-cases.Switching to the .exec file will let us trivially solve all the major issues reported so far while also significantly reducing the amount of code in the Jenkins plugin.
With Jonathan's help we integrated the ReportMojo into the plugin. I generated the exact report using only the exec file, the class and source files, so now I have HTML files. And I was thinking of parsing them (HTML source) and put them into Jenkink's structure, so it would look exacty as a JaCoCo report looks. Users do not need to get use to 2 views, and our work would be simpler too.
We realized that throwing away the XML parsing would be better right now.
Of course if we want a fast release we can use the existing code and generated HTML files with sourcefile highlighting to fix the 404 issue. That would work, but if we have already all the reports we need I think using it would be reasonable.
Does this mean you've decided to implement the source highlightingfeature based on the JaCoCo XML report?
Even if you want to use the jacoco.xml file for generating
line-by-line coverage reports (which I don't think is optimal), you
will still need the source code.
I need it only once at the build. JaCoCo generates the sourcehighlighting of the actual build, the plugin copies the whole generated HTML structure to the buildfolder (where the previous builds are stored), so we do not need to regenerate it. Hmm, I copied somewhere else the sourcecode and the sourcehighlighting is still working in the generated HTMLs, so maybe I do not need to store the sourcecode.
I would like to ask if someone has experience with HTML parsing and could recommend me a good parser.
On Jul 27, 2012 6:22 PM, "Ognjen Bubalo" <ognjen...@gmail.com> wrote:
> This is ok for me. How should we retreive and save the data? In which form? I understand that we can use the API to retrieve the data we need, but we need a good way to save this data. Wouldn't be good to generate the XML report with the API + the highlighted HTML sourcefiles? So our data would be saved in an acceptable format, also we wouldn't have to change the existing plugin. Or is there another, better way to simply save the data we need?
After both of us taking a few hours to investigate today, the answer seems to be that we can save as much data as we want, and in whichever files we want, using instances of the Jenkins FilePath class. The root path for storing and retrieving files under a particular build is build.getRootDir().
At post-build time, the Emma plugin uses this technique to make copies of all the Emma XML files. So we have a working example of how to use this technique.
>
> Currently the plugin saves the highlighted sourcefiles after every build, I only need to connect it with the MethodReport by passing a parameter, but this is some Digester magic :)
As I mentioned, I do have lots of experience with Digester. But I think our goal of eliminating all this duplication and relying as much as possible on what JaCoCo can provide is a good one. Now that we know how to store arbitrary files associated with a build, and then retrieve them later, I think we're in good shape.
-Jonathan
| all classes |
|
|
|
|
|
|
Hello all, I started using JaCoCo Jenkins plugin from last month. Our application is an Eclipse RCP and we obviously have a multi-module Maven project. I couldn't find a suitable example of using JaCoCo Maven plugin to create xml reports for multi-module Maven project.
I love the way you are progressing now - scan for exec, java and class files and link automatically for each build.