view metrics.gradle @ 237:66a99ce5f60a

DEP-13: re-enable new sonar analysis
author smith@nwoca.org
date Thu, 20 Oct 2016 19:03:18 +0100
parents 33c98751eb08
children d7f0ae9e28af
line wrap: on
line source
final GradleVersion gradleCurrent = GradleVersion.current()
final GradleVersion gradleV31 = GradleVersion.version('3.1')

final boolean legacySonar = gradleCurrent < gradleV31
final boolean newSonar = !legacySonar

buildscript {
    repositories {
        maven { url 'http://repos.ssdt.nwoca.org/artifactory/gradle-plugins' }
        maven { url 'http://repos.ssdt.nwoca.org/artifactory/repo' }
    }
    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 {
    dot = true
    packageFilter += 'org.slf4j*'
    packageFilter += 'groovyx.*'
}


if (newSonar) {

    apply plugin: org.sonarqube.gradle.SonarQubePlugin
    
    sonarqube {
        properties {
            property "sonar.host.url", "http://sonar.ssdt.io:9000"
            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/"
            property "sonar.jdbc.url", ant.properties['sonar.jdbc.url']
            property "sonar.jdbc.driverClassName", ant.properties['sonar.jdbc.driverClassName']
            property "sonar.jdbc.username", ant.properties['sonar.jdbc.username']
            property "sonar.jdbc.password", ant.properties['sonar.jdbc.password']
            property "sonar.build-stability.url", "http://bamboo.ssdt-ohio.org/browse/${gradle.bambooPlan}"
            property "sonar.scm.url", "scm:hg:${gradle.hgRepositoryUrl}"
        }
    }

    subprojects {
        afterEvaluate { project ->

            def groovyProject = project.plugins.hasPlugin('groovy')
            sonarRunner {
                sonarProperties {
                    property "sonar.language", groovyProject ? 'grvy' : 'java'
                    property "sonar.build-stability.url", "http://bamboo.ssdt-ohio.org/browse/${gradle.bambooPlan}"
                    property "sonar.scm.url", "scm:hg:${gradle.hgRepositoryUrl}"
                }
            }
        }
    }

    allprojects {
        afterEvaluate { project ->	
            project.getTasksByName('sonarRunner',false).each { it.enabled = gradle.branchStream == 'develop' }
        }
    }
}