You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by vl...@apache.org on 2019/08/13 15:31:53 UTC

[jmeter] branch master updated: Simplify JaCoCo - Sonar configuration

This is an automated email from the ASF dual-hosted git repository.

vladimirsitnikov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git


The following commit(s) were added to refs/heads/master by this push:
     new b71b73b  Simplify JaCoCo - Sonar configuration
b71b73b is described below

commit b71b73b7e705c170aac9ba93b725c57432cbe813
Author: Vladimir Sitnikov <si...@gmail.com>
AuthorDate: Tue Aug 13 18:31:21 2019 +0300

    Simplify JaCoCo - Sonar configuration
---
 build.gradle.kts | 42 +++++++++++++++++++-----------------------
 1 file changed, 19 insertions(+), 23 deletions(-)

diff --git a/build.gradle.kts b/build.gradle.kts
index 4c7e342..810e1ac 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -192,31 +192,24 @@ fun SonarQubeProperties.add(name: String, value: String) {
 }
 
 if (jacocoEnabled) {
-    val sonarqubeTask = tasks.sonarqube
-
-    val overallReport = jacocoReport.get().reports.xml.destination.toString()
+    val mergedCoverage = jacocoReport.get().reports.xml.destination.toString()
 
+    // For every module we pass merged coverage report
+    // That enables to see ":src:core" lines covered even in case they are covered from
+    // "batch tests"
     subprojects {
         if (File(projectDir, "src/main").exists()) {
             apply(plugin = "org.sonarqube")
             sonarqube {
                 properties {
-                    property("sonar.coverage.jacoco.xmlReportPaths", overallReport)
+                    property("sonar.coverage.jacoco.xmlReportPaths", mergedCoverage)
                 }
             }
         }
     }
 
-    sonarqubeTask {
+    tasks.sonarqube {
         dependsOn(jacocoReport)
-        doFirst {
-            println("doFirst: ${properties}")
-        }
-    }
-    sonarqubeTask {
-        allprojects {
-            dependsOn(tasks.withType<JacocoReport>())
-        }
     }
 }
 
@@ -224,24 +217,27 @@ if (enableSpotBugs) {
     // By default sonarqube does not depend on spotbugs
     val sonarqubeTask = tasks.sonarqube
 
+    // See https://jira.sonarsource.com/browse/SONARGRADL-59
+    // Unfortunately, report paths must be specified manually for now
     allprojects {
+        if (!File(projectDir, "src/main").exists()) {
+            return@allprojects
+        }
         val spotBugTasks = tasks.withType<SpotBugsTask>().matching {
             // We don't send spotbugs for test classes
             !it.name.endsWith("Test")
         }
-        if (File(projectDir, "src/main").exists()) {
-            apply(plugin = "org.sonarqube")
-            sonarqube {
-                properties {
-                    spotBugTasks.configureEach {
-                        add("sonar.java.spotbugs.reportPaths", reports.xml.destination.toString())
-                    }
-                }
-            }
-        }
         sonarqubeTask {
             dependsOn(spotBugTasks)
         }
+        apply(plugin = "org.sonarqube")
+        sonarqube {
+            properties {
+                spotBugTasks.configureEach {
+                    add("sonar.java.spotbugs.reportPaths", reports.xml.destination.toString())
+                }
+            }
+        }
     }
 }