/*
 * Simple TV Launcher
 * Copyright 2017 Alexandre Del Bigio
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

apply plugin: 'com.android.application'
apply plugin: 'com.github.kt3k.coveralls'
apply plugin: 'checkstyle'

checkstyle {
    toolVersion = '6.19'
}

check.dependsOn 'checkstyle'

task checkstyle(type: Checkstyle) {
    configFile file("${project.rootDir}/style/checkstyle.xml")
    configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/style/suppressions.xml").absolutePath

    source 'src/main/java'
    include 'org/cosinus/**/*.java'
    exclude '**/gen/**'

    def configProps = ['proj.module.dir': projectDir.absolutePath]
    configProperties configProps

    classpath = files()
}

android {
    compileSdkVersion 25
    buildToolsVersion '26.0.2'

    lintOptions {
        abortOnError true
        lintConfig file('lint.xml')
    }

    defaultConfig {
        applicationId "org.cosinus.launchertv"
        minSdkVersion 14
        targetSdkVersion 30
        versionCode 159
        versionName "1.5.9"
    }

    signingConfigs {
        if (project.hasProperty('keystorePassword')) {
            release {
                storeFile file(property('keystoreFile'))
                storePassword property('keystorePassword')
                keyAlias property('keystoreAlias')
                keyPassword property('keystorePassword')
            }
        }
    }

    buildTypes {
        release {
            debuggable false
            jniDebuggable false
            renderscriptDebuggable false
            minifyEnabled true
            proguardFile 'proguard-rules.pro'
            zipAlignEnabled true
            if (project.hasProperty('keystorePassword')) {
                //noinspection GroovyAssignabilityCheck
                signingConfig signingConfigs.release
            }
        }
        debug {
            applicationIdSuffix ".debug"
            testCoverageEnabled true
        }
    }
}

dependencies {
    implementation 'com.android.support:appcompat-v7:25.4.0'
}

coveralls {
    jacocoReportPath = "${buildDir}/reports/coverage/debug/report.xml"
}

tasks.coveralls {
    dependsOn 'connectedAndroidTest'
    onlyIf { System.env.'CI' }
}
