Jacoco Maven multi module project coverage

后端 未结 5 1853
余生分开走
余生分开走 2020-12-30 01:49

Seems like there are couple of questions, which are quite old and things changed from Java 8 support of Jacoco.

My Project contains following structure



        
5条回答
  •  忘掉有多难
    2020-12-30 02:18

    Follow below-mentioned instructions

    1. Create a new sub-project. This will be used as , report aggregator. parent pom will be like:

    
            A
            B
            C
            ReportAggregator
        

    1. In aggregator branch pom- add other subprojects dependencies.

    
                xyz
                A
                ${project.version}
            

    1. In aggregator branch pom- configure jacoco plugin

    
                    org.jacoco
                    jacoco-maven-plugin
                    0.8.6
                    
                        
                            
                                prepare-agent
                            
                        
                        
                            report-aggregate
                            verify
                            
                                report-aggregate
                            
                            
                                
                                    **/jacoco.exec
                                
                                ${project.reporting.outputDirectory}/jacoco-aggregate
                            
                        
                    
                

    1. In aggregator branch pom- configure surefire plugin as

    
                    org.apache.maven.plugins
                    maven-surefire-plugin
                    3.0.0-M5
                    
                        
                            **/jacoco.exec
                        
                    
                

    1. (optional step) If anybody face warning/error like: Classes in bundle '*' do no match with execution data. For report generation, the same class files must be used as at runtime.**

    Then add below mentioned lines in aggregator branch pom

     
                    org.jacoco
                    jacoco-maven-plugin
                    0.8.6
                    
                        
                            instrument-ut
                            
                                instrument
                            
                        
                        
                            restore-ut
                            
                                restore-instrumented-classes
                            
                        
                        
                            
                                prepare-agent
                            
                        
                        
                            report-aggregate
                            verify
                            
                                report-aggregate
                            
                            
                                
                                    **/jacoco.exec
                                
                                ${project.reporting.outputDirectory}/jacoco-aggregate
                            
                        
                    
                

    1. run mvn clean install

提交回复
热议问题