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:26:43 UTC

[jmeter] branch master updated: Add batch test coverage and SpotBugs to SonarQube analysis report

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 c64b9f8  Add batch test coverage and SpotBugs to SonarQube analysis report
c64b9f8 is described below

commit c64b9f8078a0eb27d505adb6e75d113eb900f82c
Author: Vladimir Sitnikov <si...@gmail.com>
AuthorDate: Tue Aug 13 18:25:53 2019 +0300

    Add batch test coverage and SpotBugs to SonarQube analysis report
---
 build.gradle.kts | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 55 insertions(+), 4 deletions(-)

diff --git a/build.gradle.kts b/build.gradle.kts
index 3cc47fc..4c7e342 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -26,6 +26,7 @@ import com.github.vlsi.gradle.git.dsl.gitignore
 import com.github.vlsi.gradle.release.RepositoryType
 import org.ajoberstar.grgit.Grgit
 import org.gradle.api.tasks.testing.logging.TestExceptionFormat
+import org.sonarqube.gradle.SonarQubeProperties
 
 plugins {
     java
@@ -182,16 +183,64 @@ sonarqube {
     }
 }
 
+fun SonarQubeProperties.add(name: String, value: String) {
+    properties.getOrPut(name) { mutableSetOf<String>() }
+        .also {
+            @Suppress("UNCHECKED_CAST")
+            (it as MutableCollection<String>).add(value)
+        }
+}
+
+if (jacocoEnabled) {
+    val sonarqubeTask = tasks.sonarqube
+
+    val overallReport = jacocoReport.get().reports.xml.destination.toString()
+
+    subprojects {
+        if (File(projectDir, "src/main").exists()) {
+            apply(plugin = "org.sonarqube")
+            sonarqube {
+                properties {
+                    property("sonar.coverage.jacoco.xmlReportPaths", overallReport)
+                }
+            }
+        }
+    }
+
+    sonarqubeTask {
+        dependsOn(jacocoReport)
+        doFirst {
+            println("doFirst: ${properties}")
+        }
+    }
+    sonarqubeTask {
+        allprojects {
+            dependsOn(tasks.withType<JacocoReport>())
+        }
+    }
+}
+
 if (enableSpotBugs) {
     // By default sonarqube does not depend on spotbugs
     val sonarqubeTask = tasks.sonarqube
 
     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(tasks.withType<SpotBugsTask>().matching {
-                // We don't send spotbugs for test classes
-                !it.name.endsWith("Test")
-            })
+            dependsOn(spotBugTasks)
         }
     }
 }
@@ -394,6 +443,8 @@ allprojects {
                 reports {
                     html.isEnabled = reportsForHumans()
                     xml.isEnabled = !reportsForHumans()
+                    // This is for Sonar
+                    xml.isWithMessages = true
                 }
                 enabled = enableSpotBugs
             }