import java.io.ByteArrayOutputStream val ignoreGitVersion: String by project val acraVersion = "5.9.7" plugins { id("com.android.application") kotlin("android") kotlin("kapt") id("com.mikepenz.aboutlibraries.plugin") id("org.jetbrains.kotlinx.kover") version "0.6.1" } fun Project.execWithOutput(cmd: String, ignore: Boolean = false): String { var result: String = ByteArrayOutputStream().use { outputStream -> project.exec { commandLine = cmd.split(" ") standardOutput = outputStream isIgnoreExitValue = ignore ?: false } outputStream.toString() } return result } fun gitVersion(): String { var process = "" val maybeTagOfCurrentCommit = execWithOutput("git -C ../ describe --contains HEAD", true) process = if (maybeTagOfCurrentCommit.isEmpty()) { println("No tag on current commit. Will take the latest one.") execWithOutput("git -C ../ for-each-ref refs/tags --sort=-authordate --format='%(refname:short)' --count=1") } else { println("Tag found on current commit") execWithOutput("git -C ../ describe --contains HEAD") } return process.replace("^0", "").replace("'", "").substring(1).replace("\\.", "").trim() } fun versionCodeFromGit(): Int { if (ignoreGitVersion == "true") { // don't care return 1 } println("version code " + gitVersion()) return gitVersion().toInt() } fun versionNameFromGit(): String { if (ignoreGitVersion == "true") { // don't care return "1" } println("version name " + gitVersion()) return gitVersion() } android { compileOptions { // Flag to enable support for the new language APIs sourceCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_11 } // For Kotlin projects kotlinOptions { jvmTarget = "11" } compileSdk = 33 buildToolsVersion = "31.0.0" buildFeatures { viewBinding = true } defaultConfig { applicationId = "bou.amine.apps.readerforselfossv2.android" minSdk = 21 targetSdk = 33 versionCode = versionCodeFromGit() versionName = versionNameFromGit() multiDexEnabled = true lint { abortOnError = true } vectorDrawables.useSupportLibrary = true // tests testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } packagingOptions { resources { excludes += "/META-INF/{AL2.0,LGPL2.1}" } } buildTypes { getByName("release") { isMinifyEnabled = true isShrinkResources = true proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") } getByName("debug") { } } flavorDimensions.add("build") productFlavors { create("githubConfig") { versionNameSuffix = "-github" dimension = "build" } } namespace = "bou.amine.apps.readerforselfossv2.android" } dependencies { implementation(project(":shared")) implementation("com.google.android.material:material:1.5.0") implementation("androidx.appcompat:appcompat:1.4.1") implementation("androidx.constraintlayout:constraintlayout:2.1.3") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0") implementation("androidx.preference:preference-ktx:1.1.1") implementation(fileTree(mapOf("include" to listOf("*.jar"), "dir" to "libs"))) // Android Support implementation("androidx.appcompat:appcompat:1.4.1") implementation("com.google.android.material:material:1.5.0") implementation("androidx.recyclerview:recyclerview:1.3.0-alpha01") implementation("androidx.legacy:legacy-support-v4:1.0.0") implementation("androidx.vectordrawable:vectordrawable:1.2.0-alpha02") implementation("androidx.cardview:cardview:1.0.0") implementation("androidx.annotation:annotation:1.3.0") implementation("androidx.work:work-runtime-ktx:2.7.1") implementation("androidx.constraintlayout:constraintlayout:2.1.3") implementation("org.jsoup:jsoup:1.14.3") //multidex implementation("androidx.multidex:multidex:2.0.1") // About implementation("com.mikepenz:aboutlibraries-core:10.5.1") implementation("com.mikepenz:aboutlibraries:10.5.1") // Material-ish things implementation("com.ashokvarma.android:bottom-navigation-bar:2.2.0") implementation("com.amulyakhare:com.amulyakhare.textdrawable:1.0.1") // glide kapt("com.github.bumptech.glide:compiler:4.11.0") implementation("com.github.bumptech.glide:okhttp3-integration:4.1.1") // Themes implementation("com.github.rubensousa:floatingtoolbar:1.5.1") // Pager implementation("me.relex:circleindicator:2.1.6") implementation("androidx.viewpager2:viewpager2:1.1.0-beta01") //Dependency Injection implementation("org.kodein.di:kodein-di:7.14.0") implementation("org.kodein.di:kodein-di-framework-android-x:7.14.0") implementation("org.kodein.di:kodein-di-framework-android-x-viewmodel:7.14.0") //Settings implementation("com.russhwolf:multiplatform-settings-no-arg:0.9") //Logging implementation("io.github.aakira:napier:2.6.1") //PhotoView implementation("com.github.chrisbanes:PhotoView:2.3.0") implementation("androidx.core:core-ktx:1.8.0") implementation("androidx.lifecycle:lifecycle-extensions:2.2.0") // Network information implementation("com.github.ln-12:multiplatform-connectivity-status:1.3.0") // SQLDELIGHT implementation("com.squareup.sqldelight:android-driver:1.5.4") //test testImplementation("junit:junit:4.13.2") testImplementation("io.mockk:mockk:1.12.0") testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0") implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0") implementation("ch.acra:acra-http:$acraVersion") implementation("ch.acra:acra-toast:$acraVersion") // Matomo implementation("com.github.matomo-org:matomo-sdk-android:4.1.4") } tasks.withType { outputs.upToDateWhen { false } useJUnit() testLogging { exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL events = setOf( org.gradle.api.tasks.testing.logging.TestLogEvent.PASSED, org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED, org.gradle.api.tasks.testing.logging.TestLogEvent.STANDARD_ERROR ) showStandardStreams = true } } aboutLibraries { offlineMode = true fetchRemoteLicense = false fetchRemoteFunding = false includePlatform = false strictMode = com.mikepenz.aboutlibraries.plugin.StrictMode.FAIL duplicationMode = com.mikepenz.aboutlibraries.plugin.DuplicateMode.MERGE duplicationRule = com.mikepenz.aboutlibraries.plugin.DuplicateRule.GROUP }