/*
 * Copyright (c) 2024 Adyen N.V.
 *
 * This file is open source and available under the MIT license. See the LICENSE file for more info.
 *
 * Created by oscars on 12/1/2024.
 */

sonar {
    properties {
        property 'sonar.projectKey', 'Adyen_adyen-android'
        property 'sonar.organization', 'adyen'
        property 'sonar.host.url', 'https://sonarcloud.io'
        property 'sonar.gradle.skipCompile', 'true'
    }
}

project(":example-app") {
    sonar {
        skipProject = true
    }
}

project(":lint") {
    sonar {
        skipProject = true
    }
}

project(":test-core") {
    sonar {
        skipProject = true
    }
}

subprojects {
    // cannot reference the plugins declared in the version catalogs here because it requires the use of the `plugins` block instead of the `apply plugin` command
    // the `plugins` block cannot be used in gradle files such as this one, which are imported into other gradle files with the `apply from` command
    apply plugin: 'org.sonarqube'

    sonar {
        properties {
            property 'sonar.androidLint.reportPaths', "${layout.buildDirectory.get().asFile}/reports/lint-results-debug.xml"
            property 'sonar.kotlin.detekt.reportPaths', "${layout.buildDirectory.get().asFile}/reports/detekt/detekt-results.xml"
            property 'sonar.coverage.jacoco.xmlReportPaths', "${layout.buildDirectory.get().asFile}/reports/jacoco/jacocoDebugTestReport/jacocoDebugTestReport.xml"

            def sonarExclusions = coverageExclusions.join(', ')
            property 'sonar.coverage.exclusions', sonarExclusions
        }
    }
}
