diff --git a/app/build.gradle b/app/build.gradle
index a11b70e92..c117c1f91 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,28 +1,10 @@
import com.android.build.OutputFile
-buildscript {
- repositories {
- google()
- mavenCentral()
- jcenter()
- }
-
- dependencies {
- dependencies {
- }
- }
-}
-
plugins {
id("com.android.application")
- id("checkstyle")
id("com.github.triplet.play") version("2.4.1")
}
-apply plugin: 'kotlin-android'
-apply plugin: 'kotlin-android-extensions'
-apply plugin: 'kotlin-kapt'
-apply plugin: 'jacoco-android'
-apply plugin: "org.jlleitschuh.gradle.ktlint"
+apply plugin: KiwixConfigurationPlugin
def buildNumber = System.getenv('TRAVIS_BUILD_NUMBER') ?: "dev"
@@ -56,16 +38,15 @@ private Integer generateVersionCode() {
}
android {
- compileSdkVersion 28
defaultConfig {
- minSdkVersion 15
- targetSdkVersion 28
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
archivesBaseName = "$buildNumber"
// Set vanilla config
+ buildConfigField "String", "KIWIX_DOWNLOAD_URL", "\"http://mirror.download.kiwix.org/\""
+ buildConfigField "boolean", "KIWIX_ERROR_ACTIVITY", "false"
buildConfigField "boolean", "IS_CUSTOM_APP", "false"
buildConfigField "boolean", "HAS_EMBEDDED_ZIM", "false"
buildConfigField "String", "ZIM_FILE_NAME", "\"\""
@@ -82,37 +63,8 @@ android {
cruncherEnabled true
}
- lintOptions {
- abortOnError true
- checkAllWarnings true
- warningsAsErrors true
-
- ignore 'SyntheticAccessor',
- //TODO stop ignoring below this
- 'MissingTranslation',
- 'CheckResult',
- 'LabelFor',
- 'DuplicateStrings',
- 'LogConditional'
-
- warning 'UnknownNullness',
- 'SelectableText',
- 'IconDensities',
- 'SyntheticAccessor'
- baseline file("lint-baseline.xml")
- }
-
testOptions {
execution 'ANDROIDX_TEST_ORCHESTRATOR'
- unitTests.returnDefaultValues = true
- unitTests.all {
- useJUnitPlatform()
- testLogging {
- events "passed", "skipped", "failed", "standardOut", "standardError"
- outputs.upToDateWhen { false }
- showStandardStreams = true
- }
- }
}
signingConfigs {
@@ -129,8 +81,6 @@ android {
// Main build type for debugging
debug {
multiDexKeepProguard file("multidex-instrumentation-config.pro")
- buildConfigField "String", "KIWIX_DOWNLOAD_URL", "\"http://mirror.download.kiwix.org/\""
- buildConfigField "boolean", "KIWIX_ERROR_ACTIVITY", "false"
testCoverageEnabled true
}
@@ -154,20 +104,10 @@ android {
java.srcDirs += "$rootDir/core/src/testShared"
}
}
- compileOptions {
- encoding = "UTF-8"
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
-
dexOptions {
javaMaxHeapSize "4g"
}
- androidExtensions {
- experimental = true
- }
-
def abiCodes = ['arm64-v8a': 6, 'x86': 3, 'x86_64': 4, 'armeabi-v7a': 5]
def densityCodes = ['mdpi': 2, 'hdpi': 3, 'xhdpi': 4, 'xxhdpi': 5, 'xxxhdpi': 6]
splits {
@@ -203,20 +143,6 @@ play {
resolutionStrategy = "fail"
}
-ktlint {
- android = true
-}
-
-jacoco {
- toolVersion = "0.8.3"
-}
-
-tasks.withType(Test) {
- jacoco.includeNoLocationClasses = true
-}
-
-apply from: "${rootDir}/team-props/git-hooks.gradle"
-
dependencies {
implementation project(":core")
implementation(Libs.appcompat)
diff --git a/app/lint-baseline.xml b/app/lint-baseline.xml
index 08d4888ea..9f9047f14 100644
--- a/app/lint-baseline.xml
+++ b/app/lint-baseline.xml
@@ -8,26 +8,6 @@
file="..\..\..\.android\lint\customlint.jar"/>
-
-
-
-
-
-
-
-
("clean") {
delete(rootProject.buildDir)
}
-
diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts
index 88cd14f78..e33c62f56 100644
--- a/buildSrc/build.gradle.kts
+++ b/buildSrc/build.gradle.kts
@@ -1,6 +1,20 @@
plugins {
- `kotlin-dsl`
+ `kotlin-dsl`
}
repositories {
- mavenCentral()
-}
\ No newline at end of file
+ mavenCentral()
+ google()
+ jcenter()
+ maven {
+ setUrl("https://plugins.gradle.org/m2/")
+ }
+}
+
+dependencies {
+ implementation("com.android.tools.build:gradle:3.5.0")
+ implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50")
+ implementation("com.dicedmelon.gradle:jacoco-android:0.1.4")
+ implementation("org.jlleitschuh.gradle:ktlint-gradle:8.2.0")
+ implementation(gradleApi())
+ implementation(localGroovy())
+}
diff --git a/buildSrc/src/main/kotlin/Config.kt b/buildSrc/src/main/kotlin/Config.kt
new file mode 100644
index 000000000..3d63936cd
--- /dev/null
+++ b/buildSrc/src/main/kotlin/Config.kt
@@ -0,0 +1,27 @@
+/*
+ * Kiwix Android
+ * Copyright (c) 2019 Kiwix
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+import org.gradle.api.JavaVersion
+
+object Config {
+ const val compileSdk = 28
+ const val minSdk = 15
+ const val targetSdk = 28
+ const val testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
+ val javaVersion = JavaVersion.VERSION_1_8
+}
diff --git a/buildSrc/src/main/kotlin/KiwixConfigurationPlugin.kt b/buildSrc/src/main/kotlin/KiwixConfigurationPlugin.kt
new file mode 100644
index 000000000..2d992de52
--- /dev/null
+++ b/buildSrc/src/main/kotlin/KiwixConfigurationPlugin.kt
@@ -0,0 +1,126 @@
+/*
+ * Kiwix Android
+ * Copyright (c) 2019 Kiwix
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+import com.android.build.gradle.AppExtension
+import com.android.build.gradle.AppPlugin
+import com.android.build.gradle.BaseExtension
+import com.android.build.gradle.LibraryExtension
+import com.android.build.gradle.LibraryPlugin
+import org.gradle.api.Plugin
+import org.gradle.api.Project
+import org.gradle.api.tasks.testing.Test
+import org.gradle.kotlin.dsl.KotlinClosure1
+import org.gradle.kotlin.dsl.apply
+import org.gradle.testing.jacoco.plugins.JacocoPluginExtension
+import org.gradle.testing.jacoco.plugins.JacocoTaskExtension
+import org.jetbrains.kotlin.gradle.internal.AndroidExtensionsExtension
+import org.jlleitschuh.gradle.ktlint.KtlintExtension
+
+class KiwixConfigurationPlugin : Plugin {
+ override fun apply(target: Project) {
+ target.plugins.all {
+ when (this) {
+ is LibraryPlugin -> {
+ target.configureExtension { configure(target.projectDir.toString()) }
+ }
+ is AppPlugin -> {
+ target.configureExtension { configure(target.projectDir.toString()) }
+ }
+ }
+ }
+ target.plugins.apply("kotlin-android")
+ target.plugins.apply("kotlin-android-extensions")
+ target.plugins.apply("kotlin-kapt")
+ target.plugins.apply("jacoco-android")
+ target.plugins.apply("org.jlleitschuh.gradle.ktlint")
+ target.configureExtension { isExperimental = true }
+ target.configureExtension { toolVersion = "0.8.3" }
+ target.configureExtension { android.set(true) }
+ target.apply(from = "${target.rootDir}/team-props/git-hooks.gradle")
+ }
+}
+
+private inline fun Project.configureExtension(function: T.() -> Unit) =
+ extensions.getByType(T::class.java).function()
+
+private fun LibraryExtension.configure(path: String) {
+ baseConfigure(path)
+}
+
+private fun AppExtension.configure(path: String) {
+ baseConfigure(path)
+}
+
+private fun BaseExtension.baseConfigure(path: String) {
+ setCompileSdkVersion(Config.compileSdk)
+
+ defaultConfig {
+ setMinSdkVersion(Config.minSdk)
+ setTargetSdkVersion(Config.targetSdk)
+ }
+
+ compileOptions.apply {
+ encoding = "UTF-8"
+ sourceCompatibility = Config.javaVersion
+ targetCompatibility = Config.javaVersion
+ }
+
+ testOptions {
+ unitTests.apply {
+ isReturnDefaultValues = true
+ isIncludeAndroidResources = true
+ all(KotlinClosure1({
+ (this as Test).also { testTask ->
+ testTask.useJUnitPlatform()
+ testTask.testLogging {
+ setEvents(setOf("passed", "skipped", "failed", "standardOut", "standardError"))
+ outputs.upToDateWhen { false }
+ showStandardStreams = true
+ }
+ testTask.extensions
+ .getByType(JacocoTaskExtension::class.java)
+ .isIncludeNoLocationClasses = true
+ }
+ }, this))
+ }
+ }
+
+ lintOptions {
+ isAbortOnError = true
+ isCheckAllWarnings = true
+ isCheckAllWarnings = true
+
+ ignore(
+ "SyntheticAccessor",
+ //TODO stop ignoring below this
+ "MissingTranslation",
+ "CheckResult",
+ "LabelFor",
+ "DuplicateStrings",
+ "LogConditional"
+ )
+
+ warning(
+ "UnknownNullness",
+ "SelectableText",
+ "IconDensities",
+ "SyntheticAccessor"
+ )
+ baseline("${path}/lint-baseline.xml")
+ }
+}
diff --git a/core/build.gradle b/core/build.gradle
index 78b954e60..efb20855c 100644
--- a/core/build.gradle
+++ b/core/build.gradle
@@ -19,20 +19,12 @@ plugins {
id("com.github.triplet.play") version("2.4.1")
}
apply plugin: 'com.android.library'
-apply plugin: 'kotlin-android'
-apply plugin: 'kotlin-android-extensions'
-apply plugin: 'kotlin-kapt'
+apply plugin: KiwixConfigurationPlugin
apply plugin: 'io.objectbox'
-apply plugin: 'jacoco-android'
-apply plugin: "org.jlleitschuh.gradle.ktlint"
apply plugin: 'com.jakewharton.butterknife'
android {
- compileSdkVersion 28
-
defaultConfig {
- minSdkVersion 15
- targetSdkVersion 28
versionCode 1
versionName "1.0"
@@ -56,45 +48,9 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
- compileOptions {
- encoding = "UTF-8"
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
- androidExtensions {
- experimental = true
- }
testOptions {
execution 'ANDROIDX_TEST_ORCHESTRATOR'
- unitTests.returnDefaultValues = true
- unitTests.all {
- useJUnitPlatform()
- testLogging {
- events "passed", "skipped", "failed", "standardOut", "standardError"
- outputs.upToDateWhen { false }
- showStandardStreams = true
- }
- }
- }
- lintOptions {
- abortOnError true
- checkAllWarnings true
- warningsAsErrors true
-
- ignore 'SyntheticAccessor',
- //TODO stop ignoring below this
- 'MissingTranslation',
- 'CheckResult',
- 'LabelFor',
- 'DuplicateStrings',
- 'LogConditional'
-
- warning 'UnknownNullness',
- 'SelectableText',
- 'IconDensities',
- 'SyntheticAccessor'
- baseline file("lint-baseline.xml")
}
sourceSets {
test {
@@ -107,18 +63,6 @@ android {
}
}
-jacoco {
- toolVersion = "0.8.3"
-}
-
-tasks.withType(Test) {
- jacoco.includeNoLocationClasses = true
-}
-
-ktlint {
- android = true
-}
-
private boolean shouldUseLocalVersion() {
file("./libs").exists()
}
diff --git a/core/lint-baseline.xml b/core/lint-baseline.xml
index c21c94da8..1cf0723e1 100644
--- a/core/lint-baseline.xml
+++ b/core/lint-baseline.xml
@@ -8,6 +8,15 @@
file="..\..\..\.android\lint\customlint.jar"/>
+
+
+
+
-
-
-
-
-
-
-
-