diff metrics.gradle @ 233:400f9d8bbf5b

DEP-13: enable sonar analysis for gradle 3.1 projects. disable sonar for ant based projects
author smith@nwoca.org
date Wed, 19 Oct 2016 22:42:08 +0100
parents 47535c8358ce
children 5969e8210e0b
line wrap: on
line diff
--- a/metrics.gradle	Tue Oct 18 18:29:04 2016 +0100
+++ b/metrics.gradle	Wed Oct 19 22:42:08 2016 +0100
@@ -2,11 +2,7 @@
 final GradleVersion gradleV31 = GradleVersion.version('3.1')
 
 final boolean legacySonar = gradleCurrent < gradleV31
-
-if (legacySonar) {
-    apply plugin: "sonar-runner"
-    ant.property(file: System.getProperty('user.home') + "/.ssdt/sonar.properties")
-}
+final boolean newSonar = !legacySonar
 
 buildscript {
     repositories {
@@ -15,9 +11,11 @@
     }
     dependencies {
         classpath 'me.davesmith:jaranalyzerplugin:0.2.0-SNAPSHOT'
+        classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.2"
     }
 }
 
+
 apply plugin: me.davesmith.gradle.plugins.jaranalyzer.JarAnalyzerPlugin
 
 jaranalyzer {
@@ -26,16 +24,26 @@
     packageFilter += 'groovyx.*'
 }
 
-if (!legacySonar) {
+
+if (newSonar) {
 
-   task('sonar') << {
-        println "sonar analysis currently disabled"
-   }
-
+    apply plugin: org.sonarqube.gradle.SonarQubePlugin
+    
+    sonarqube {
+        properties {
+            property "sonar.host.url", "https://sonar.ssdt.io"
+            property "sonar.login", System.getenv('bamboo_SONAR_TOKEN')
+            property "sonar.exclusions","**/ProjectVersion*"
+        }
+    }
+    
 }
 
 if (legacySonar) {
 
+    apply plugin: "sonar-runner"
+    ant.property(file: System.getProperty('user.home') + "/.ssdt/sonar.properties")
+
     sonarRunner {
         sonarProperties {
             property "sonar.host.url", "http://sonar.ssdt-ohio.org/"