i need analyse code via sonar using gradle , have strange problem cannot handle. have following project structure
-java |-src |-main |-test |-integration-test
and sonar analyse test directory default , integration-test directory if change sonar.test property /src/integration-test, want analyze 2 directories , dont know how it. below have sonarqube task properties gradle.build file.
sonarqube { properties { property "sonar.projectname", "projectname" property "sonar.projectkey", "org.sonarqube:projectname" property "sonar.host.url", "http://sonar.doesntmetter" property "sonar.java.coverageplugin", "jacoco" property "sonar.junit.reportspath", "build/test-results/test" property "sonar.jacoco.reportpath", "build/jacoco/test.exec" property "sonar.jacoco.itreportpath", "build/jacoco/integrationtest.exec" property "sonar.login", "admin" property "sonar.password", "admin" } }
what noticed when run gradle build there integrationtest.exec , test.exec in /build/jacoco/ directory, in case run gradle sonarqube default sonar.test property there test.exec, , other hand when run gradle sonarqube sonar.test=/src/integration-test there both test.exec , integrationtest.exec.
dont know how analyze unit , integration test in 1 run?
i think can add gradle:
sonarqube { properties { properties["sonar.sources"] += sourcesets.custom.allsource.srcdirs properties["sonar.tests"] += sourcesets.integtest.allsource.srcdirs } }
just use +=
add more tests/sources. more information , examples here.
edit:
add report paths too! properties named:
sonar.surefire.reportspath - test.testresultsdir (if directory exists)
sonar.junit.reportspath - test.testresultsdir (if directory exists)
edit:
i rewrite code , set sources testing in 1 line, check structure
sonarqube { properties { property "sonar.projectname", "projectname" property "sonar.projectkey", "projectkey" property "sonar.host.url", "http://itsprettyprivate" property "sonar.java.coverageplugin", "jacoco" // or add via += properties, ;) property "sonar.sources", "src/java,src/test,src/integration-test" //tells sonarqube unit tests execution reports property "sonar.junit.reportspath", "build/test-results/test" //tells sonarqube unit tests code coverage report property "sonar.jacoco.reportpath", "build/jacoco/test.exec" //tells sonarqube integration tests code coverage report property "sonar.jacoco.itreportpath", "build/jacoco/integrationtest.exec" property "sonar.login", "admin" property "sonar.password", "password" } }
Comments
Post a Comment