summaryrefslogtreecommitdiff
path: root/common.gradle
diff options
context:
space:
mode:
authorByteHamster <info@bytehamster.com>2021-05-11 22:14:56 +0200
committerByteHamster <info@bytehamster.com>2021-05-11 22:38:46 +0200
commitc72fd8188614acf981ddfd9b9078927322e3c229 (patch)
treeb5f564b3e8c0a068aa753b6a02aeb76a13739570 /common.gradle
parent65bf8bf70c008947b45991cb8c1df2e7a8e5ec42 (diff)
downloadantennapod-c72fd8188614acf981ddfd9b9078927322e3c229.zip
Move common gradle setup to a single file
Original idea by @TacoTheDank
Diffstat (limited to 'common.gradle')
-rw-r--r--common.gradle105
1 files changed, 105 insertions, 0 deletions
diff --git a/common.gradle b/common.gradle
new file mode 100644
index 000000000..4c3ee192d
--- /dev/null
+++ b/common.gradle
@@ -0,0 +1,105 @@
+android {
+ compileSdkVersion 30
+
+ defaultConfig {
+ minSdkVersion 16
+ 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-rules.pro"
+ }
+ 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
+ }
+
+ viewBinding {
+ enabled = 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 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."))
+ }
+ }
+ }
+}