summaryrefslogtreecommitdiff
path: root/common.gradle
blob: 4f023212bc09c560f94c6c6b421e2865fd9217e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
android {
    compileSdkVersion 31

    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 30

        multiDexEnabled false
        vectorDrawables.useSupportLibrary true
        vectorDrawables.generatedDensities = []

        testApplicationId "de.danoeh.antennapod.core.tests"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard.cfg"
        }
        debug {
            // debug build has method count over 64k single-dex threshold.
            // For building debug build to use on Android < 21 (pre-Android 5) devices,
            // you need to manually change class
            // de.danoeh.antennapod.PodcastApp to extend MultiDexApplication .
            // See Issue #2813
            multiDexEnabled true
        }
    }

    packagingOptions {
        exclude "META-INF/LICENSE.txt"
        exclude "META-INF/NOTICE.txt"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    testOptions {
        animationsDisabled = true
        unitTests {
            includeAndroidResources = true
        }
    }

    lintOptions {
        disable "GradleDependency"
        checkDependencies true
        warningsAsErrors true
        abortOnError true
        checkGeneratedSources = true
    }

    buildFeatures {
        viewBinding true
    }
}

tasks.withType(Test) {
    testLogging {
        exceptionFormat "full"
        events "skipped", "passed", "failed"
        showStandardStreams true
        displayGranularity 2
    }
}

gradle.projectsEvaluated {
    tasks.withType(JavaCompile) {
        options.compilerArgs << "-Xlint"
    }
}

apply plugin: 'com.github.spotbugs'

spotbugs {
    effort = 'max'
    reportLevel = 'medium'
    excludeFilter = rootProject.file('config/spotbugs/exclude.xml')
    ignoreFailures = true // Handled by printing task
}

gradle.taskGraph.beforeTask { task ->
    if (task.name.toLowerCase().contains('spotbugs')) {
        task.doLast {
            def reportFile = task.project.file("build/reports/spotbugs/playDebug.xml")
            if (!reportFile.exists()) return
            def slurped = new groovy.xml.XmlSlurper().parse(reportFile)

            def foundErrors = false
            slurped['BugInstance'].each { bug ->
                logger.error "[SpotBugs] ${bug['LongMessage']} [${bug.@'type'}]"
                bug['SourceLine'].each { line ->
                    logger.error "[SpotBugs]     ${line['Message']}"
                    foundErrors = true
                }
            }
            if (foundErrors) {
                throw new TaskExecutionException(task,
                        new Exception("SpotBugs violations were found. See output above for details."))
            }
        }
    }
}