开发者

How to instrument a multiproject Maven 2 with Cobertura?

My Maven 2 project consists of several sub-modules. It s structured containing and EJB, WAR and Jar sub modules.. Now i want to instrument the packaged EAR that contains all submodules as mentioned.

Example:

Interface Maven Project consists of several modules:
- InterfacePOM --> parent pom
- InterfaceEAR --> EAR module which does not actual code but is the packaging for Domain, EJB and WAR
- InterfaceEJB --> EJB module
- interfaceWAR --> WAR module
- interfaceDomain --> JAR module

When using Cobertura i can succesfully instrument all various independent modules but that generated a .ser file per module. Is there a way to instrument an enitre EAR file at once? So that the开发者_Go百科 result will be a single .ser file which i can use??


Short answer: no (have a look at this previous answer for more details). You'll need an external plugin like the dashboard (actually, don't use it, see my previous answer), XRadar or Sonar to aggregate the reports. But in this area, Sonar is the clear winner (this project just rocks) and I'd recommend it without any hesitation. Check out Nemo, their public instance, pick up any project and have a look at the drill down of code coverage (for example Apache CXF) to get an idea of what it can do.

UPDATE: It appears that I missed the point of the initial question so I'm updating my answer accordingly. Basically, I now understand the question as "how to instrument an ear with cobertura" and this is indeed a totally different story.

Unfortunately, while cobertura can instrument an ear, sar, zip, war, jar, I' don't think that the cobertura-maven-plugin supports this out-of-the-box and it may be a better option to use cobertura's ant task with the antrun plugin. See MCOBERTURA-86, this thread and this discussion for more background on this (and an antrun sample).

TBH, what you are trying to do is really not easy in terms of build lifecycle, packaging, reporting, etc and is going to be a tough task because of the lack of support from the cobertura plugin. I'd really think about it twice (time to invest to get the whole thing working vs the value generated) or consider spending that time (understand money) to get a clover license (which offers better support for this).


I implemented a solution now based on your previous answers around Maven 2. It is still not very easy to use but so far it goes OK. The implementation is as follows:

1. Modified my parent pom to generate cobertura instrumented classes when giving a specific profile.This generates the .ser files and the instrumented classes.

2. The instrumented classes are copied to the /target/classes folder by using the maven-resource-plugin, so the actual packaging uses the instrumented classes.

3. As there is no module wide .ser file i manually combine those .ser files from the EJB,WAR,JAR and ear file using the commandline solution given by Cobertura. coberture-merge.bat/.sh

4. Deploy the .ser file into my JBoss container and also deploy the instrumented EAR.

5. After testing i run a report on the merged .ser file and voila.. it seems to work..

I surely will look into Clover as the solution implemented is somewhat manual..


It looks like there is no task in the cobertura-maven-plugin for merging .ser files from individual projects into a single report.

A google search turned up this feature request and patch for the plugin to add a merge task, but it doesn't look like it was accepted. One of the comments suggests using the dashboard plugin to accomplish the same thing, you might have some success with that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜