Move common configuration of all modules into buildSrc

This commit is contained in:
Sean Mac Gillicuddy 2019-10-02 14:20:54 +01:00
parent 21e8988ccd
commit c32aed4e46
10 changed files with 184 additions and 251 deletions

View File

@ -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)

View File

@ -8,26 +8,6 @@
file="..\..\..\.android\lint\customlint.jar"/>
</issue>
<issue
id="ObsoleteLintCustomCheck"
message="Lint found an issue registry (`butterknife.lint.LintRegistry`) which is older than the current API level; these checks may not work correctly.&#xA;&#xA;Recompile the checks against the latest version. Custom check API version is 2 (3.2), current lint API level is 5 (3.5+)"
includedVariants="debug"
excludedVariants="release">
<location
file="..\..\..\.gradle\caches\transforms-2\files-2.1\155b1c6c67a15ea2c33b631c0e6e3dd4\butterknife-runtime-10.1.0\jars\lint.jar"/>
</issue>
<issue
id="OldTargetApi"
message="Not targeting the latest versions of Android; compatibility modes apply. Consider testing and updating this version. Consult the android.os.Build.VERSION_CODES javadoc for details."
errorLine1=" targetSdkVersion 28"
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="build.gradle"
line="63"
column="5"/>
</issue>
<issue
id="UnusedAttribute"
message="Attribute `networkSecurityConfig` is only used in API level 24 and higher (current min is 15)"

View File

@ -16,35 +16,6 @@ plugins {
buildSrcVersions
}
ext {
set("androidGradlePluginVersion", "3.5.0")
set("testdroidGradlePluginVersion", "2.63.0")
set("appCompatVersion", "1.0.2")
set("materialVersion", "1.0.0")
set("annotationVersion", "1.0.0")
set("cardViewVersion", "1.0.0")
set("rxJavaVersion", "2.2.5")
set("rxAndroidVersion", "2.1.0")
set("okHttpVersion", "3.12.1")
set("retrofitVersion", "2.5.0")
set("javaxAnnotationVersion", "1.3.2")
set("daggerVersion", "2.21")
set("inkPageIndicatorVersion", "1.3.0")
set("constraintLayoutVersion", "1.1.3")
set("butterKnifeVersion", "10.1.0")
set("espressoVersion", "3.1.1")
set("apacheCommonsVersion", "2.6")
set("multidexVersion", "2.0.1")
set("jUnitVersion", "4.12")
set("mockitoVersion", "2.24.5")
set("powerMockVersion", "1.6.6")
set("powerMockJUnitVersion", "1.7.4")
set("baristaVersion", "2.7.1")
set("kotlinVersion", "1.3.50")
set("objectboxVersion", "2.3.4")
set("fetchVersion", "3.1.4")
}
allprojects {
repositories {
google()
@ -56,4 +27,3 @@ allprojects {
tasks.create<Delete>("clean") {
delete(rootProject.buildDir)
}

View File

@ -1,6 +1,20 @@
plugins {
`kotlin-dsl`
`kotlin-dsl`
}
repositories {
mavenCentral()
}
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())
}

View File

@ -0,0 +1,27 @@
/*
* Kiwix Android
* Copyright (c) 2019 Kiwix <android.kiwix.org>
* 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 <http://www.gnu.org/licenses/>.
*
*/
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
}

View File

@ -0,0 +1,126 @@
/*
* Kiwix Android
* Copyright (c) 2019 Kiwix <android.kiwix.org>
* 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 <http://www.gnu.org/licenses/>.
*
*/
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<Project> {
override fun apply(target: Project) {
target.plugins.all {
when (this) {
is LibraryPlugin -> {
target.configureExtension<LibraryExtension> { configure(target.projectDir.toString()) }
}
is AppPlugin -> {
target.configureExtension<AppExtension> { 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<AndroidExtensionsExtension> { isExperimental = true }
target.configureExtension<JacocoPluginExtension> { toolVersion = "0.8.3" }
target.configureExtension<KtlintExtension> { android.set(true) }
target.apply(from = "${target.rootDir}/team-props/git-hooks.gradle")
}
}
private inline fun <reified T> 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<Any, Test>({
(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")
}
}

View File

@ -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()
}

View File

@ -8,6 +8,15 @@
file="..\..\..\.android\lint\customlint.jar"/>
</issue>
<issue
id="ObsoleteLintCustomCheck"
message="Lint found an issue registry (`butterknife.lint.LintRegistry`) which is older than the current API level; these checks may not work correctly.&#xA;&#xA;Recompile the checks against the latest version. Custom check API version is 2 (3.2), current lint API level is 5 (3.5+)"
includedVariants="debug"
excludedVariants="release">
<location
file="..\..\..\.gradle\caches\transforms-2\files-2.1\5fe77b6973f8fa017590206274e7a5f7\butterknife-runtime-10.1.0\jars\lint.jar"/>
</issue>
<issue
id="MissingPermission"
message="Missing permissions required by ConnectivityManager.getActiveNetworkInfo: android.permission.ACCESS_NETWORK_STATE"
@ -180,17 +189,6 @@
file="..\..\..\.gradle\caches\modules-2\files-2.1\org.simpleframework\simple-xml\2.7.1\dd91fb744c2ff921407475cb29a1e3fee397d411\simple-xml-2.7.1.jar"/>
</issue>
<issue
id="OldTargetApi"
message="Not targeting the latest versions of Android; compatibility modes apply. Consider testing and updating this version. Consult the android.os.Build.VERSION_CODES javadoc for details."
errorLine1=" targetSdkVersion 28"
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="build.gradle"
line="35"
column="5"/>
</issue>
<issue
id="SdCardPath"
message="Do not hardcode &quot;`/data/`&quot;; use `Context.getFilesDir().getPath()` instead"

View File

@ -1,10 +1,7 @@
import groovy.json.JsonSlurper
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'jacoco-android'
apply plugin: "org.jlleitschuh.gradle.ktlint"
apply plugin: KiwixConfigurationPlugin
String[] archs = ['arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64']
@ -30,12 +27,9 @@ if (custom.listFiles()) {
}
}
android {
compileSdkVersion 28
defaultConfig {
applicationId "org.kiwix.kiwixmobile.custom"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
multiDexEnabled true
@ -139,43 +133,8 @@ android {
}
}
}
compileOptions {
encoding = "UTF-8"
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
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")
}
}
ktlint {
android = true
}
jacoco {
toolVersion = "0.8.3"
}
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
}
dependencies {
implementation project(':core')
implementation(Libs.appcompat)

View File

@ -41,17 +41,6 @@
column="5"/>
</issue>
<issue
id="OldTargetApi"
message="Not targeting the latest versions of Android; compatibility modes apply. Consider testing and updating this version. Consult the android.os.Build.VERSION_CODES javadoc for details."
errorLine1=" targetSdkVersion 28"
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="build.gradle"
line="38"
column="5"/>
</issue>
<issue
id="UnusedAttribute"
message="Attribute `networkSecurityConfig` is only used in API level 24 and higher (current min is 15)"