开发者

Hudson + Maven + Emma/Sonar = Build Cycle Runs 2x

I have a bunch of Maven projects building in Hudson with Sonar sitting in the side-lines. Sonar gives me Sonar stats, FindBugs stats, and code-coverage.

I've noticed that regardless of if I use Sonar or if I use EMMA via Maven directly, the entire build cycle runs twice. This includes init (which in my case, reinitializes the database -- expensive) and unit tests (a few hundred -- also expensive).

How can I prevent this? I did a lot of reading, and it seems like this is due to t开发者_JS百科he design of code-coverage plugins -- to keep uninstrumented classes separated from instrumented ones.

I've tried configurations like:

  • Maven runs: deploy, EMMA
  • Maven runs: deploy; deploy to Sonar on completion


The sonar documentation recommends running the sonar plugin in 2 stages:-

mvn clean install -Dtest=false -DfailIfNoTests=false

mvn sonar:sonar

The tests are bypassed in the first phase and run implicitly in the second stage.

A one line alternative is to run the following command:-

mvn clean install sonar:sonar -Dmaven.test.failure.ignore=true

but this will run the tests twice - as you have found.


To add to @Strawberry's answer, you could reuse the unit test reports instead of running them again. Refer to the section Reuse existing unit test reports in the sonar documentation

Once this is done, you can configure the following in Hudson

clean deploy sonar:sonar
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜