integrating JaCoCo in sonar using Ant

前端 未结 1 748
情深已故
情深已故 2020-11-30 14:32

I am stuck integrating JaCoCo with sonar using Ant. Very new to this task, and integrating for the first time. I have gone through many links like

  • https://gith
1条回答
  •  悲&欢浪女
    2020-11-30 14:50

    The following is an ANT build that is configured to run a junit unit test and use jacoco for code coverage reporting. The results are uploaded to Sonar and finally ivy is used to download 3rd party jars and manage classpaths.

    Example

    ├── build.properties
    ├── build.xml
    ├── ivy.xml
    └── src
        ├── main
        │   └── java
        │       └── org
        │           └── demo
        │               └── App.java
        └── test
            └── java
                └── org
                    └── demo
                        └── AppTest.java
    

    build.properties

    # Build properties
    build.dir=build
    
    src.dir=src/main/java
    test.src.dir=src/test/java
    
    classes.dir=${build.dir}/classes
    test.classes.dir=${build.dir}/test-classes
    
    reports.dir=${build.dir}/reports
    
    # Sonar properties
    sonar.projectKey=org.demo:demo
    sonar.projectName=Demo project
    sonar.projectVersion=1.0
    sonar.projectDescription=This is my demo Sonar project
    
    sonar.host.url=http://localhost:9000
    
    sonar.jdbc.url=jdbc:h2:tcp://localhost:9092/sonar
    sonar.jdbc.driverClassName=org.h2.Driver
    sonar.jdbc.username=sonar
    sonar.jdbc.password=sonar
    
    sonar.working.directory=${build.dir}/sonar
    
    sonar.language=java
    sonar.sources=${src.dir}
    sonar.binaries=${classes.dir}
    sonar.tests=${test.src.dir}
    
    sonar.dynamicAnalysis=reuseReports
    sonar.surefire.reportsPath=${reports.dir}/junit
    sonar.java.coveragePlugin=jacoco
    sonar.jacoco.reportPath=${build.dir}/jacoco.exec
    

    build.xml

    
    
        
    
        
            
            
        
    
        
            
            
    
            
            
            
        
    
        
            
            
            
        
    
        
            
        
    
        
            
                
                    
                    
                
            
        
    
        
            
    
            
                
                    
                        
                        
                        
                    
                    
                    
                    
                        
                            
                            
                        
                    
                
            
        
    
        
            
    
             
    
            
        
    
        
            
        
    
        
            
        
    
    
    

    ivy.xml

    
        
    
        
            
            
            
        
    
        
            
    
            
            
    
            
            
            
    
            
            
        
    
    
    

    0 讨论(0)
提交回复
热议问题