diff --git a/app/build.gradle b/app/build.gradle index 49b485fa1..8b16da71b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,11 +1,4 @@ -import com.android.annotations.NonNull import com.android.build.OutputFile -import com.android.builder.testing.api.TestServer -import com.testdroid.api.APIClient -import com.testdroid.api.APIKeyClient -import com.testdroid.api.model.APIProject -import com.testdroid.api.model.APIUser -import groovy.json.JsonSlurper buildscript { repositories { @@ -15,11 +8,11 @@ buildscript { } dependencies { - classpath "com.android.tools.build:gradle:$androidGradlePluginVersion" - classpath "org.apache.httpcomponents:httpclient-android:4.3.3" - classpath "com.testdroid:testdroid-api:2.71" - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" - classpath "org.jlleitschuh.gradle:ktlint-gradle:8.2.0" + dependencies { + classpath Libs.com_android_tools_build_gradle + classpath Libs.kotlin_gradle_plugin + classpath Libs.ktlint_gradle + } } } @@ -75,7 +68,6 @@ private Integer generateVersionCode() { android { compileSdkVersion 28 - testServer new TestDroidUpload() defaultConfig { minSdkVersion 15 @@ -124,15 +116,6 @@ android { } } } - sourceSets { - test { - java.srcDirs += "$projectDir/src/testShared" - } - - androidTest { - java.srcDirs += "$projectDir/src/testShared" - } - } flavorDimensions "default" @@ -191,8 +174,6 @@ android { versionName generateVersionName() } } - - } compileOptions { @@ -248,77 +229,35 @@ ktlint { android = true } -class TestDroidUpload extends TestServer { - def buildNumber = System.getenv("TRAVIS_BUILD_NUMBER") - def API_KEY = System.getenv("PUBLIC_TESTDROID_API_KEY") - def TESTDROID_SERVER = "https://cloud.testdroid.com" - def RUNNER_GATEWAY = System.getenv("TESTDROID_RUNNER_GATEWAY") - def accessGroup = System.getenv("ACCESS_GROUP_ID") - - @Override - String getName() { - return "kiwixtest" - } - - @Override - void uploadApks(@NonNull String variantName, @NonNull File testApk, File testedApk) { - APIUser.metaClass.shareFile { id, accessGroup -> - System.out.println(id) - try { - delegate.postResource(createUri(selfURI, "/files/" + id + "/share"), - [accessGroupId: accessGroup], APIProject.class) - } catch (Exception e) { - System.out.println(e.getLocalizedMessage()) - } - } - - APIClient client = new APIKeyClient(TESTDROID_SERVER, API_KEY) - APIUser user = client.me() - String testId = user.uploadFile(testApk).getId() - user.shareFile(testId, accessGroup) - String testedId = user.uploadFile(testedApk).getId() - user.shareFile(testedId, accessGroup) - - new URL(RUNNER_GATEWAY + "?apk=" + testedId + "&test=" + testId + "&buildno=" + buildNumber). - getText() - } - - @Override - boolean isConfigured() { - return true - } -} - apply from: "${rootDir}/team-props/git-hooks.gradle" -afterEvaluate { - tasks['preBuild'].dependsOn installGitHooks -} -dependencies { - implementation project(":core") - androidTestImplementation("androidx.test.espresso:espresso-core:$espressoVersion") - androidTestImplementation "androidx.test.espresso:espresso-web:$espressoVersion" - androidTestImplementation "androidx.test.espresso:espresso-intents:$espressoVersion" - androidTestImplementation("com.schibsted.spain:barista:$baristaVersion") { - exclude group: "com.android.support.test.uiautomator" + dependencies { + implementation project(":core") + implementation(Libs.appcompat) + androidTestImplementation(Libs.espresso_core) + androidTestImplementation(Libs.espresso_web) + androidTestImplementation(Libs.espresso_intents) + androidTestImplementation(Libs.barista) { + exclude group: "com.android.support.test.uiautomator" + } + androidTestImplementation(Libs.espresso_contrib) + androidTestImplementation(Libs.androidx_annotation) + androidTestImplementation(Libs.junit) + androidTestImplementation(Libs.androidx_test_runner) + androidTestImplementation(Libs.androidx_test_rules) + androidTestImplementation(Libs.androidx_test_core) + androidTestImplementation(Libs.mockwebserver) + androidTestUtil(Libs.orchestrator) + androidTestImplementation(Libs.mockito_android) + androidTestCompileOnly(Libs.javax_annotation_api) + implementation(Libs.dagger) + kaptAndroidTest(Libs.dagger_compiler) + androidTestImplementation(Libs.mockk_android) + androidTestImplementation(Libs.uiautomator) + androidTestImplementation(Libs.assertj_core) + androidTestImplementation(Libs.simple_xml) { + exclude module: 'stax' + exclude module: 'stax-api' + exclude module: 'xpp3' + } } - androidTestImplementation("androidx.test.espresso:espresso-contrib:$espressoVersion") - androidTestImplementation "androidx.annotation:annotation:$annotationVersion" - androidTestImplementation "androidx.test.ext:junit:1.1.1" - androidTestImplementation "androidx.test:runner:1.2.0" - androidTestImplementation "androidx.test:rules:1.2.0" - androidTestImplementation "androidx.test:core:1.2.0" - androidTestImplementation "com.squareup.okhttp3:mockwebserver:3.6.0" - androidTestUtil 'androidx.test:orchestrator:1.1.0' - androidTestImplementation "org.mockito:mockito-android:$mockitoVersion" - androidTestCompileOnly "javax.annotation:javax.annotation-api:$javaxAnnotationVersion" - kaptAndroidTest "com.google.dagger:dagger-compiler:$daggerVersion" - androidTestImplementation "io.mockk:mockk-android:1.9" - androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0' - androidTestImplementation "org.assertj:assertj-core:3.11.1" - androidTestImplementation("org.simpleframework:simple-xml:2.7.1") { - exclude module: 'stax' - exclude module: 'stax-api' - exclude module: 'xpp3' - } -} diff --git a/app/lint-baseline.xml b/app/lint-baseline.xml index 72e307cd0..1d0a57a3f 100644 --- a/app/lint-baseline.xml +++ b/app/lint-baseline.xml @@ -1,5 +1,5 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -356,7 +37,7 @@ errorLine2=" ~~~~~~~~"> @@ -367,7 +48,7 @@ errorLine2=" ~~~~~~~~~~~"> @@ -378,9055 +59,8 @@ errorLine2=" ^"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/BaseActivityTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/BaseActivityTest.kt index f81e0966c..4a56aea8f 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/BaseActivityTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/BaseActivityTest.kt @@ -26,7 +26,9 @@ abstract class BaseActivityTest { getInstrumentation().targetContext.applicationContext } - inline fun activityTestRule(noinline beforeActivityAction: (() -> Unit)? = null) = + inline fun activityTestRule( + noinline beforeActivityAction: (() -> Unit)? = null + ) = object : ActivityTestRule(T::class.java) { override fun beforeActivityLaunched() { super.beforeActivityLaunched() diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/KiwixMockServer.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/KiwixMockServer.kt index 4bfd0e4bf..93d85d55a 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/KiwixMockServer.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/KiwixMockServer.kt @@ -45,7 +45,10 @@ class KiwixMockServer { override fun dispatch(request: RecordedRequest) = mapOfPathsToResponses[request.path]?.let(::successfulResponse) ?: forcedResponse?.let { return@let it } - ?: throw RuntimeException("No response mapped for ${request.path}\nmapped $mapOfPathsToResponses\nqueued $forcedResponse") + ?: throw RuntimeException( + "No response mapped for ${request.path}" + + "\nmapped $mapOfPathsToResponses\nqueued $forcedResponse" + ) }) } @@ -67,5 +70,3 @@ class KiwixMockServer { "$it" } } - - diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/di/components/TestComponent.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/di/components/TestComponent.kt index ad5505294..50937f347 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/di/components/TestComponent.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/di/components/TestComponent.kt @@ -33,7 +33,14 @@ import javax.inject.Singleton */ @Singleton -@Component(modules = [ApplicationModule::class, TestNetworkModule::class, JNIModule::class, DataModule::class]) +@Component( + modules = [ + ApplicationModule::class, + TestNetworkModule::class, + JNIModule::class, + DataModule::class + ] +) interface TestComponent : ApplicationComponent { @Component.Builder diff --git a/build.gradle.kts b/build.gradle.kts index 4f0c10a96..e04f1d58e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,6 +11,9 @@ buildscript { // in the individual module build.gradle files } } +plugins { + buildSrcVersions +} ext { set("androidGradlePluginVersion", "3.5.0") diff --git a/buildSrc/.gitignore b/buildSrc/.gitignore new file mode 100644 index 000000000..192221b47 --- /dev/null +++ b/buildSrc/.gitignore @@ -0,0 +1,2 @@ +.gradle/ +build/ \ No newline at end of file diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 000000000..88cd14f78 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,6 @@ +plugins { + `kotlin-dsl` +} +repositories { + mavenCentral() +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/Libs.kt b/buildSrc/src/main/kotlin/Libs.kt new file mode 100644 index 000000000..f9fa744dd --- /dev/null +++ b/buildSrc/src/main/kotlin/Libs.kt @@ -0,0 +1,408 @@ +import kotlin.String + +/** + * Generated by https://github.com/jmfayard/buildSrcVersions + * + * Update this file with + * `$ ./gradlew buildSrcVersions` + */ +object Libs { + const val de_fayard_buildsrcversions_gradle_plugin: String = + "de.fayard.buildSrcVersions:de.fayard.buildSrcVersions.gradle.plugin:" + + Versions.de_fayard_buildsrcversions_gradle_plugin + + const val com_github_triplet_play_gradle_plugin: String = + "com.github.triplet.play:com.github.triplet.play.gradle.plugin:" + + Versions.com_github_triplet_play_gradle_plugin + + /** + * https://developer.android.com/topic/libraries/architecture/index.html + */ + const val android_arch_lifecycle_extensions: String = "android.arch.lifecycle:extensions:" + + Versions.android_arch_lifecycle_extensions + + /** + * https://developer.android.com/studio + */ + const val com_android_tools_build_gradle: String = "com.android.tools.build:gradle:" + + Versions.com_android_tools_build_gradle + + const val androidx_multidex_multidex: String = "androidx.multidex:multidex:" + + Versions.androidx_multidex_multidex + + /** + * https://github.com/JakeWharton/butterknife/ + */ + const val butterknife_gradle_plugin: String = "com.jakewharton:butterknife-gradle-plugin:" + + Versions.butterknife_gradle_plugin + + const val multidex_instrumentation: String = "androidx.multidex:multidex-instrumentation:" + + Versions.multidex_instrumentation + + /** + * https://developer.android.com/testing + */ + const val espresso_contrib: String = "androidx.test.espresso:espresso-contrib:" + + Versions.androidx_test_espresso + + /** + * https://developer.android.com/testing + */ + const val espresso_core: String = "androidx.test.espresso:espresso-core:" + + Versions.androidx_test_espresso + + /** + * https://developer.android.com/testing + */ + const val espresso_intents: String = "androidx.test.espresso:espresso-intents:" + + Versions.androidx_test_espresso + + /** + * https://developer.android.com/testing + */ + const val espresso_web: String = "androidx.test.espresso:espresso-web:" + + Versions.androidx_test_espresso + + /** + * https://github.com/square/retrofit/ + */ + const val adapter_rxjava2: String = "com.squareup.retrofit2:adapter-rxjava2:" + + Versions.com_squareup_retrofit2 + + /** + * https://github.com/square/retrofit/ + */ + const val converter_simplexml: String = "com.squareup.retrofit2:converter-simplexml:" + + Versions.com_squareup_retrofit2 + + /** + * https://github.com/square/retrofit/ + */ + const val retrofit: String = "com.squareup.retrofit2:retrofit:" + Versions.com_squareup_retrofit2 + + const val play_services_location: String = "com.google.android.gms:play-services-location:" + + Versions.play_services_location + + /** + * https://developer.android.com/testing + */ + const val androidx_test_runner: String = "androidx.test:runner:" + Versions.androidx_test_runner + + /** + * https://github.com/JakeWharton/butterknife/ + */ + const val butterknife_compiler: String = "com.jakewharton:butterknife-compiler:" + + Versions.butterknife_compiler + + /** + * http://jcp.org/en/jsr/detail?id=250 + */ + const val javax_annotation_api: String = "javax.annotation:javax.annotation-api:" + + Versions.javax_annotation_api + + /** + * https://kotlinlang.org/ + */ + const val kotlin_android_extensions: String = "org.jetbrains.kotlin:kotlin-android-extensions:" + + Versions.org_jetbrains_kotlin + + /** + * https://kotlinlang.org/ + */ + const val kotlin_android_extensions_runtime: String = + "org.jetbrains.kotlin:kotlin-android-extensions-runtime:" + Versions.org_jetbrains_kotlin + + /** + * https://kotlinlang.org/ + */ + const val kotlin_annotation_processing_gradle: String = + "org.jetbrains.kotlin:kotlin-annotation-processing-gradle:" + Versions.org_jetbrains_kotlin + + /** + * https://kotlinlang.org/ + */ + const val kotlin_gradle_plugin: String = "org.jetbrains.kotlin:kotlin-gradle-plugin:" + + Versions.org_jetbrains_kotlin + + /** + * https://kotlinlang.org/ + */ + const val kotlin_stdlib_jdk7: String = "org.jetbrains.kotlin:kotlin-stdlib-jdk7:" + + Versions.org_jetbrains_kotlin + + /** + * https://developer.android.com/testing + */ + const val androidx_test_rules: String = "androidx.test:rules:" + Versions.androidx_test_rules + + /** + * https://github.com/square/okhttp + */ + const val logging_interceptor: String = "com.squareup.okhttp3:logging-interceptor:" + + Versions.logging_interceptor + + /** + * https://developer.android.com/testing + */ + const val androidx_test_core: String = "androidx.test:core:" + Versions.androidx_test_core + + /** + * http://hc.apache.org/httpcomponents-client/ + */ + const val httpclient_android: String = "org.apache.httpcomponents:httpclient-android:" + + Versions.httpclient_android + + const val ink_page_indicator: String = "com.pacioianu.david:ink-page-indicator:" + + Versions.ink_page_indicator + + /** + * http://github.com/square/leakcanary/ + */ + const val leakcanary_android: String = "com.squareup.leakcanary:leakcanary-android:" + + Versions.leakcanary_android + + /** + * https://github.com/google/dagger + */ + const val dagger: String = "com.google.dagger:dagger:" + Versions.com_google_dagger + + /** + * https://github.com/google/dagger + */ + const val dagger_android: String = "com.google.dagger:dagger-android:" + + Versions.com_google_dagger + + /** + * https://github.com/google/dagger + */ + const val dagger_android_processor: String = "com.google.dagger:dagger-android-processor:" + + Versions.com_google_dagger + + /** + * https://github.com/google/dagger + */ + const val dagger_compiler: String = "com.google.dagger:dagger-compiler:" + + Versions.com_google_dagger + + /** + * https://github.com/yahoo/squidb + */ + const val squidb: String = "com.yahoo.squidb:squidb:" + Versions.com_yahoo_squidb + + /** + * https://github.com/yahoo/squidb + */ + const val squidb_annotations: String = "com.yahoo.squidb:squidb-annotations:" + + Versions.com_yahoo_squidb + + /** + * https://github.com/yahoo/squidb + */ + const val squidb_processor: String = "com.yahoo.squidb:squidb-processor:" + + Versions.com_yahoo_squidb + + /** + * http://tools.android.com + */ + const val constraintlayout: String = "androidx.constraintlayout:constraintlayout:" + + Versions.constraintlayout + + /** + * https://github.com/mockito/mockito + */ + const val mockito_android: String = "org.mockito:mockito-android:" + Versions.mockito_android + + /** + * http://developer.android.com/tools/extras/support-library.html + */ + const val collection_ktx: String = "androidx.collection:collection-ktx:" + Versions.collection_ktx + + const val jacoco_android: String = "com.dicedmelon.gradle:jacoco-android:" + + Versions.jacoco_android + + /** + * https://junit.org/junit5/ + */ + const val junit_jupiter: String = "org.junit.jupiter:junit-jupiter:" + Versions.junit_jupiter + + const val ktlint_gradle: String = "org.jlleitschuh.gradle:ktlint-gradle:" + Versions.ktlint_gradle + + /** + * https://github.com/square/okhttp + */ + const val mockwebserver: String = "com.squareup.okhttp3:mockwebserver:" + Versions.mockwebserver + + /** + * https://github.com/bitbar/testdroid-api + */ + const val testdroid_api: String = "com.testdroid:testdroid-api:" + Versions.testdroid_api + + const val xfetch2okhttp: String = "androidx.tonyodev.fetch2okhttp:xfetch2okhttp:" + + Versions.xfetch2okhttp + + /** + * http://assertj.org + */ + const val assertj_core: String = "org.assertj:assertj-core:" + Versions.assertj_core + + /** + * https://developer.android.com/topic/libraries/architecture/index.html + */ + const val core_testing: String = "androidx.arch.core:core-testing:" + Versions.core_testing + + /** + * https://developer.android.com/jetpack/androidx + */ + const val fragment_ktx: String = "androidx.fragment:fragment-ktx:" + Versions.fragment_ktx + + /** + * http://objectbox.io + */ + const val objectbox_android: String = "io.objectbox:objectbox-android:" + Versions.io_objectbox + + /** + * https://objectbox.io + */ + const val objectbox_gradle_plugin: String = "io.objectbox:objectbox-gradle-plugin:" + + Versions.io_objectbox + + /** + * http://objectbox.io + */ + const val objectbox_kotlin: String = "io.objectbox:objectbox-kotlin:" + Versions.io_objectbox + + /** + * https://objectbox.io + */ + const val objectbox_processor: String = "io.objectbox:objectbox-processor:" + + Versions.io_objectbox + + /** + * http://objectbox.io + */ + const val objectbox_rxjava: String = "io.objectbox:objectbox-rxjava:" + Versions.io_objectbox + + /** + * http://objectbox.io + */ + const val objectbox_windows: String = "io.objectbox:objectbox-windows:" + Versions.io_objectbox + + /** + * https://developer.android.com/testing + */ + const val orchestrator: String = "androidx.test:orchestrator:" + Versions.orchestrator + + /** + * https://github.com/JakeWharton/butterknife/ + */ + const val butterknife: String = "com.jakewharton:butterknife:" + Versions.butterknife + + /** + * https://developer.android.com/studio + */ + const val lint_gradle: String = "com.android.tools.lint:lint-gradle:" + Versions.lint_gradle + + /** + * https://github.com/jraska/livedata-testing + */ + const val testing_ktx: String = "com.jraska.livedata:testing-ktx:" + Versions.testing_ktx + + /** + * https://github.com/JakeWharton/ThreeTenABP/ + */ + const val threetenabp: String = "com.jakewharton.threetenabp:threetenabp:" + Versions.threetenabp + + /** + * https://developer.android.com/testing + */ + const val uiautomator: String = "androidx.test.uiautomator:uiautomator:" + Versions.uiautomator + + /** + * http://developer.android.com/tools/extras/support-library.html + */ + const val androidx_annotation: String = "androidx.annotation:annotation:" + Versions.annotation + + /** + * http://jacoco.org + */ + const val org_jacoco_agent: String = "org.jacoco:org.jacoco.agent:" + Versions.org_jacoco + + /** + * http://jacoco.org + */ + const val org_jacoco_ant: String = "org.jacoco:org.jacoco.ant:" + Versions.org_jacoco + + /** + * http://simple.sourceforge.net + */ + const val simple_xml: String = "org.simpleframework:simple-xml:" + Versions.simple_xml + + /** + * https://developer.android.com/jetpack/androidx + */ + const val appcompat: String = "androidx.appcompat:appcompat:" + Versions.appcompat + + /** + * https://github.com/ReactiveX/RxAndroid + */ + const val rxandroid: String = "io.reactivex.rxjava2:rxandroid:" + Versions.rxandroid + + /** + * http://developer.android.com/tools/extras/support-library.html + */ + const val cardview: String = "androidx.cardview:cardview:" + Versions.cardview + + /** + * http://developer.android.com/tools/extras/support-library.html + */ + const val core_ktx: String = "androidx.core:core-ktx:" + Versions.core_ktx + + /** + * http://mockk.io + */ + const val mockk: String = "io.mockk:mockk:" + Versions.io_mockk + + /** + * http://mockk.io + */ + const val mockk_android: String = "io.mockk:mockk-android:" + Versions.io_mockk + + /** + * https://github.com/kiwix/kiwix-lib + */ + const val kiwixlib: String = "org.kiwix.kiwixlib:kiwixlib:" + Versions.kiwixlib + + /** + * http://developer.android.com/tools/extras/support-library.html + */ + const val material: String = "com.google.android.material:material:" + Versions.material + + const val barista: String = "com.schibsted.spain:barista:" + Versions.barista + + const val xfetch2: String = "androidx.tonyodev.fetch2:xfetch2:" + Versions.xfetch2 + + /** + * http://findbugs.sourceforge.net/ + */ + const val jsr305: String = "com.google.code.findbugs:jsr305:" + Versions.jsr305 + + /** + * https://github.com/square/okhttp + */ + const val okhttp: String = "com.squareup.okhttp3:okhttp:" + Versions.okhttp + + /** + * https://github.com/ReactiveX/RxJava + */ + const val rxjava: String = "io.reactivex.rxjava2:rxjava:" + Versions.rxjava + + /** + * https://developer.android.com/studio + */ + const val aapt2: String = "com.android.tools.build:aapt2:" + Versions.aapt2 + + /** + * https://developer.android.com/testing + */ + const val junit: String = "androidx.test.ext:junit:" + Versions.junit +} diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt new file mode 100644 index 000000000..bc5b073f7 --- /dev/null +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -0,0 +1,145 @@ +import kotlin.String +import org.gradle.plugin.use.PluginDependenciesSpec +import org.gradle.plugin.use.PluginDependencySpec + +/** + * Generated by https://github.com/jmfayard/buildSrcVersions + * + * Find which updates are available by running + * `$ ./gradlew buildSrcVersions` + * This will only update the comments. + * + * YOU are responsible for updating manually the dependency version. + */ +object Versions { + const val de_fayard_buildsrcversions_gradle_plugin: String = "0.6.1" + + const val com_github_triplet_play_gradle_plugin: String = "2.4.1" // available: "2.4.2" + + const val android_arch_lifecycle_extensions: String = "1.1.1" + + const val com_android_tools_build_gradle: String = "3.5.0" + + const val androidx_multidex_multidex: String = "2.0.1" + + const val butterknife_gradle_plugin: String = "10.2.0" + + const val multidex_instrumentation: String = "2.0.0" + + const val androidx_test_espresso: String = "3.1.1" // available: "3.2.0" + + const val com_squareup_retrofit2: String = "2.5.0" // available: "2.6.2" + + const val play_services_location: String = "17.0.0" + + const val androidx_test_runner: String = "1.2.0" + + const val butterknife_compiler: String = "10.1.0" // available: "10.2.0" + + const val javax_annotation_api: String = "1.3.2" + + const val org_jetbrains_kotlin: String = "1.3.50" + + const val androidx_test_rules: String = "1.2.0" + + const val logging_interceptor: String = "3.12.1" // available: "4.2.0" + + const val androidx_test_core: String = "1.2.0" + + const val httpclient_android: String = "4.3.3" // available: "4.3.5.1" + + const val ink_page_indicator: String = "1.3.0" + + const val leakcanary_android: String = "2.0-alpha-2" + + const val com_google_dagger: String = "2.21" // available: "2.24" + + const val com_yahoo_squidb: String = "2.0.0" // available: "3.2.3" + + const val constraintlayout: String = "1.1.3" + + const val mockito_android: String = "2.24.5" // available: "3.0.0" + + const val collection_ktx: String = "1.1.0" + + const val jacoco_android: String = "0.1.4" + + const val junit_jupiter: String = "5.4.2" // available: "5.5.2" + + const val ktlint_gradle: String = "8.2.0" + + const val mockwebserver: String = "3.6.0" // available: "4.2.0" + + const val testdroid_api: String = "2.71" // available: "2.81" + + const val xfetch2okhttp: String = "3.1.4" + + const val assertj_core: String = "3.11.1" // available: "3.13.2" + + const val core_testing: String = "2.0.1" // available: "2.1.0" + + const val fragment_ktx: String = "1.0.0" // available: "1.1.0" + + const val io_objectbox: String = "2.3.4" + + const val orchestrator: String = "1.1.0" // available: "1.2.0" + + const val butterknife: String = "10.1.0" // available: "10.2.0" + + const val lint_gradle: String = "26.5.0" + + const val testing_ktx: String = "1.1.0" + + const val threetenabp: String = "1.1.1" // available: "1.2.1" + + const val uiautomator: String = "2.2.0" + + const val annotation: String = "1.0.0" // available: "1.1.0" + + const val org_jacoco: String = "0.7.9" + + const val simple_xml: String = "2.7.1" + + const val appcompat: String = "1.0.2" // available: "1.1.0" + + const val rxandroid: String = "2.1.0" // available: "2.1.1" + + const val cardview: String = "1.0.0" + + const val core_ktx: String = "1.0.2" // available: "1.1.0" + + const val io_mockk: String = "1.9" // available: "1.9.3" + + const val kiwixlib: String = "8.1.0" + + const val material: String = "1.0.0" + + const val barista: String = "2.7.1" // available: "3.2.0" + + const val xfetch2: String = "3.1.4" + + const val jsr305: String = "3.0.2" + + const val okhttp: String = "3.12.1" // available: "4.2.0" + + const val rxjava: String = "2.2.5" // available: "2.2.12" + + const val aapt2: String = "3.5.0-5435860" + + const val junit: String = "1.1.1" + + /** + * Current version: "5.6.1" + * See issue 19: How to update Gradle itself? + * https://github.com/jmfayard/buildSrcVersions/issues/19 + */ + const val gradleLatestVersion: String = "5.6.2" +} + +/** + * See issue #47: how to update buildSrcVersions itself + * https://github.com/jmfayard/buildSrcVersions/issues/47 + */ +val PluginDependenciesSpec.buildSrcVersions: PluginDependencySpec + inline get() = + id("de.fayard.buildSrcVersions").version(Versions.de_fayard_buildsrcversions_gradle_plugin) diff --git a/core/build.gradle b/core/build.gradle index 84dcbb19a..1d6e7809f 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -6,13 +6,11 @@ buildscript { } dependencies { - classpath "com.android.tools.build:gradle:$androidGradlePluginVersion" - classpath "org.apache.httpcomponents:httpclient-android:4.3.3" - classpath "com.testdroid:testdroid-api:2.71" - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" - classpath "io.objectbox:objectbox-gradle-plugin:$objectboxVersion" - classpath "org.jlleitschuh.gradle:ktlint-gradle:8.2.0" - classpath 'com.jakewharton:butterknife-gradle-plugin:10.2.0' + classpath Libs.com_android_tools_build_gradle + classpath Libs.kotlin_gradle_plugin + classpath Libs.objectbox_gradle_plugin + classpath Libs.ktlint_gradle + classpath Libs.butterknife_gradle_plugin } } @@ -66,6 +64,34 @@ android { androidExtensions { experimental = 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 { + java.srcDirs += "$projectDir/src/testShared" + } + + androidTest { + java.srcDirs += "$projectDir/src/testShared" + } + } } jacoco { @@ -87,49 +113,49 @@ private boolean shouldUseLocalVersion() { dependencies { // use jdk8 java.time backport, as long app < Build.VERSION_CODES.O - implementation("com.jakewharton.threetenabp:threetenabp:1.1.1") + implementation(Libs.threetenabp) // Get kiwixlib online if it is not populated locally if (!shouldUseLocalVersion()) { - implementation 'org.kiwix.kiwixlib:kiwixlib:8.1.0' + implementation(Libs.kiwixlib) } else { implementation 'com.getkeepsafe.relinker:relinker:1.3.1' implementation fileTree(include: ['*.aar'], dir: 'libs') } // Android Support - implementation "androidx.appcompat:appcompat:$appCompatVersion" - implementation "com.google.android.material:material:$materialVersion" - implementation "androidx.cardview:cardview:$cardViewVersion" - implementation "androidx.multidex:multidex:$multidexVersion" - implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion" - implementation "androidx.core:core-ktx:1.0.2" - implementation "androidx.fragment:fragment-ktx:1.0.0" - implementation "androidx.collection:collection-ktx:1.1.0" + implementation(Libs.appcompat) + implementation(Libs.material) + implementation(Libs.cardview) + implementation(Libs.androidx_multidex_multidex) + implementation(Libs.constraintlayout) + implementation(Libs.core_ktx) + implementation(Libs.fragment_ktx) + implementation(Libs.collection_ktx) // Tab indicator - implementation "com.pacioianu.david:ink-page-indicator:$inkPageIndicatorVersion" + implementation(Libs.ink_page_indicator) // Dagger - compileOnly "javax.annotation:javax.annotation-api:$javaxAnnotationVersion" + compileOnly(Libs.javax_annotation_api) - implementation "com.google.dagger:dagger:$daggerVersion" - implementation "com.google.dagger:dagger-android:$daggerVersion" - kapt "com.google.dagger:dagger-compiler:$daggerVersion" - kapt "com.google.dagger:dagger-android-processor:$daggerVersion" + implementation(Libs.dagger) + implementation(Libs.dagger_android) + kapt(Libs.dagger_compiler) + kapt(Libs.dagger_android_processor) // SquiDB - implementation 'com.yahoo.squidb:squidb:2.0.0' - implementation 'com.yahoo.squidb:squidb-annotations:2.0.0' - kapt 'com.yahoo.squidb:squidb-processor:2.0.0' + implementation(Libs.squidb) + implementation(Libs.squidb_annotations) + kapt(Libs.squidb_processor) // Square - implementation "com.squareup.okhttp3:okhttp:$okHttpVersion" - implementation "com.squareup.okhttp3:logging-interceptor:$okHttpVersion" - implementation "com.squareup.retrofit2:retrofit:$retrofitVersion" - implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion" - implementation("com.squareup.retrofit2:converter-simplexml:$retrofitVersion") { + implementation(Libs.okhttp) + implementation(Libs.logging_interceptor) + implementation(Libs.retrofit) + implementation(Libs.adapter_rxjava2) + implementation(Libs.converter_simplexml) { exclude group: "xpp3", module: "xpp3" exclude group: "stax", module: "stax-api" exclude group: "stax", module: "stax" @@ -137,28 +163,27 @@ dependencies { // ButterKnife - implementation "com.jakewharton:butterknife:$butterKnifeVersion" - kapt "com.jakewharton:butterknife-compiler:$butterKnifeVersion" + implementation(Libs.butterknife) + kapt(Libs.butterknife_compiler) // RxJava - implementation "io.reactivex.rxjava2:rxandroid:$rxAndroidVersion" - implementation "io.reactivex.rxjava2:rxjava:$rxJavaVersion" + implementation(Libs.rxandroid) + implementation(Libs.rxjava) // Leak canary - debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-alpha-2' + debugImplementation(Libs.leakcanary_android) - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion" - implementation "android.arch.lifecycle:extensions:1.1.1" - implementation "io.objectbox:objectbox-kotlin:$objectboxVersion" - implementation "io.objectbox:objectbox-rxjava:$objectboxVersion" - implementation 'com.google.android.gms:play-services-location:17.0.0' + implementation(Libs.kotlin_stdlib_jdk7) + implementation(Libs.android_arch_lifecycle_extensions) + implementation(Libs.objectbox_kotlin) + implementation(Libs.objectbox_rxjava) - implementation "androidx.tonyodev.fetch2:xfetch2:$fetchVersion" - implementation "androidx.tonyodev.fetch2okhttp:xfetch2okhttp:$fetchVersion" + implementation(Libs.xfetch2) + implementation(Libs.xfetch2okhttp) - testImplementation "org.junit.jupiter:junit-jupiter:5.4.2" - testImplementation "io.mockk:mockk:1.9" - testImplementation "org.assertj:assertj-core:3.11.1" - testImplementation 'com.jraska.livedata:testing-ktx:1.1.0' - testImplementation 'androidx.arch.core:core-testing:2.0.1' + testImplementation(Libs.junit_jupiter) + testImplementation(Libs.mockk) + testImplementation(Libs.assertj_core) + testImplementation(Libs.testing_ktx) + testImplementation(Libs.core_testing) } diff --git a/core/lint-baseline.xml b/core/lint-baseline.xml new file mode 100644 index 000000000..232835a03 --- /dev/null +++ b/core/lint-baseline.xml @@ -0,0 +1,7846 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/src/main/java/org/kiwix/kiwixmobile/zim_manager/ZimFileReader.kt b/core/src/main/java/org/kiwix/kiwixmobile/zim_manager/ZimFileReader.kt index 15d690dab..c67f9fbe6 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/zim_manager/ZimFileReader.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/zim_manager/ZimFileReader.kt @@ -30,7 +30,6 @@ import org.kiwix.kiwixlib.JNIKiwixInt import org.kiwix.kiwixlib.JNIKiwixReader import org.kiwix.kiwixlib.JNIKiwixString import org.kiwix.kiwixlib.Pair -import org.kiwix.kiwixmobile.core.BuildConfig import org.kiwix.kiwixmobile.KiwixApplication import org.kiwix.kiwixmobile.library.entity.LibraryNetworkEntity.Book import org.kiwix.kiwixmobile.utils.SharedPreferenceUtil @@ -220,7 +219,8 @@ class ZimFileReader( @JvmField val UI_URI: Uri? = Uri.parse("content://org.kiwix.ui/") @JvmField - val CONTENT_URI: Uri? = Uri.parse("content://${KiwixApplication.getInstance().packageName}.zim.base/") + val CONTENT_URI: Uri? = + Uri.parse("content://${KiwixApplication.getInstance().packageName}.zim.base/") private const val INVERT_IMAGES_VIDEO = "img, video { \n -webkit-filter: invert(1); \n filter: invert(1); \n} \n" private val VIDEO_REGEX = Regex("([^\\s]+(\\.(?i)(3gp|mp4|m4a|webm|mkv|ogg|ogv))\$)") diff --git a/core/src/main/java/org/kiwix/kiwixmobile/zim_manager/fileselect_view/effects/ShareFiles.kt b/core/src/main/java/org/kiwix/kiwixmobile/zim_manager/fileselect_view/effects/ShareFiles.kt index 4695e78ba..8f04e6b19 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/zim_manager/fileselect_view/effects/ShareFiles.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/zim_manager/fileselect_view/effects/ShareFiles.kt @@ -5,8 +5,6 @@ import android.content.Intent import android.net.Uri import android.os.Build import androidx.core.content.FileProvider -import org.kiwix.kiwixmobile.KiwixApplication -import org.kiwix.kiwixmobile.core.BuildConfig import org.kiwix.kiwixmobile.core.R import org.kiwix.kiwixmobile.zim_manager.fileselect_view.adapter.BooksOnDiskListItem.BookOnDisk diff --git a/core/src/test/java/org/kiwix/kiwixmobile/language/viewmodel/LanguageViewModelTest.kt b/core/src/test/java/org/kiwix/kiwixmobile/language/viewmodel/LanguageViewModelTest.kt index 331800fcb..277f7f08c 100644 --- a/core/src/test/java/org/kiwix/kiwixmobile/language/viewmodel/LanguageViewModelTest.kt +++ b/core/src/test/java/org/kiwix/kiwixmobile/language/viewmodel/LanguageViewModelTest.kt @@ -39,7 +39,7 @@ import org.kiwix.kiwixmobile.language.viewmodel.State.Content import org.kiwix.kiwixmobile.language.viewmodel.State.Loading import org.kiwix.kiwixmobile.language.viewmodel.State.Saving import org.kiwix.kiwixmobile.languageItem -import org.kiwix.kiwixmobile.core.ResetSchedulers +import org.kiwix.kiwixmobile.resetSchedulers import org.kiwix.kiwixmobile.setScheduler import org.kiwix.kiwixmobile.zim_manager.Language diff --git a/core/src/test/java/org/kiwix/kiwixmobile/language/viewmodel/SaveLanguagesAndFinishTest.kt b/core/src/test/java/org/kiwix/kiwixmobile/language/viewmodel/SaveLanguagesAndFinishTest.kt index 16099aa36..74770c717 100644 --- a/core/src/test/java/org/kiwix/kiwixmobile/language/viewmodel/SaveLanguagesAndFinishTest.kt +++ b/core/src/test/java/org/kiwix/kiwixmobile/language/viewmodel/SaveLanguagesAndFinishTest.kt @@ -24,7 +24,7 @@ import io.mockk.verify import io.reactivex.schedulers.Schedulers import org.junit.jupiter.api.Test import org.kiwix.kiwixmobile.database.newdb.dao.NewLanguagesDao -import org.kiwix.kiwixmobile.core.ResetSchedulers +import org.kiwix.kiwixmobile.resetSchedulers import org.kiwix.kiwixmobile.setScheduler import org.kiwix.kiwixmobile.zim_manager.Language diff --git a/core/src/test/java/org/kiwix/kiwixmobile/utils/files/FileSearchTest.kt b/core/src/test/java/org/kiwix/kiwixmobile/utils/files/FileSearchTest.kt index ef62b5186..6babb0b30 100644 --- a/core/src/test/java/org/kiwix/kiwixmobile/utils/files/FileSearchTest.kt +++ b/core/src/test/java/org/kiwix/kiwixmobile/utils/files/FileSearchTest.kt @@ -35,7 +35,7 @@ import org.junit.jupiter.api.AfterAll import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Nested import org.junit.jupiter.api.Test -import org.kiwix.kiwixmobile.core.ResetSchedulers +import org.kiwix.kiwixmobile.resetSchedulers import org.kiwix.kiwixmobile.setScheduler import java.io.File diff --git a/core/src/test/java/org/kiwix/kiwixmobile/zim_manager/ZimManageViewModelTest.kt b/core/src/test/java/org/kiwix/kiwixmobile/zim_manager/ZimManageViewModelTest.kt index 44f3b9113..d9edc4c26 100644 --- a/core/src/test/java/org/kiwix/kiwixmobile/zim_manager/ZimManageViewModelTest.kt +++ b/core/src/test/java/org/kiwix/kiwixmobile/zim_manager/ZimManageViewModelTest.kt @@ -48,7 +48,7 @@ import org.kiwix.kiwixmobile.downloader.model.DownloadModel import org.kiwix.kiwixmobile.language import org.kiwix.kiwixmobile.library.entity.LibraryNetworkEntity.Book import org.kiwix.kiwixmobile.libraryNetworkEntity -import org.kiwix.kiwixmobile.core.ResetSchedulers +import org.kiwix.kiwixmobile.resetSchedulers import org.kiwix.kiwixmobile.setScheduler import org.kiwix.kiwixmobile.utils.BookUtils import org.kiwix.kiwixmobile.zim_manager.Fat32Checker.FileSystemState diff --git a/core/src/test/java/org/kiwix/kiwixmobile/zim_manager/fileselect_view/StorageObserverTest.kt b/core/src/test/java/org/kiwix/kiwixmobile/zim_manager/fileselect_view/StorageObserverTest.kt index e7ad39b50..bdaa81975 100644 --- a/core/src/test/java/org/kiwix/kiwixmobile/zim_manager/fileselect_view/StorageObserverTest.kt +++ b/core/src/test/java/org/kiwix/kiwixmobile/zim_manager/fileselect_view/StorageObserverTest.kt @@ -30,7 +30,7 @@ import org.kiwix.kiwixmobile.book import org.kiwix.kiwixmobile.bookOnDisk import org.kiwix.kiwixmobile.database.newdb.dao.FetchDownloadDao import org.kiwix.kiwixmobile.downloader.model.DownloadModel -import org.kiwix.kiwixmobile.core.ResetSchedulers +import org.kiwix.kiwixmobile.resetSchedulers import org.kiwix.kiwixmobile.setScheduler import org.kiwix.kiwixmobile.utils.SharedPreferenceUtil import org.kiwix.kiwixmobile.utils.files.FileSearch diff --git a/app/src/test/resources/io/mockk/settings.properties b/core/src/test/resources/io/mockk/settings.properties similarity index 100% rename from app/src/test/resources/io/mockk/settings.properties rename to core/src/test/resources/io/mockk/settings.properties diff --git a/app/src/test/resources/junit-platform.properties b/core/src/test/resources/junit-platform.properties similarity index 100% rename from app/src/test/resources/junit-platform.properties rename to core/src/test/resources/junit-platform.properties diff --git a/app/src/test/resources/wikipedia_af_all_nopic_2016-05.zim.meta4 b/core/src/test/resources/wikipedia_af_all_nopic_2016-05.zim.meta4 similarity index 100% rename from app/src/test/resources/wikipedia_af_all_nopic_2016-05.zim.meta4 rename to core/src/test/resources/wikipedia_af_all_nopic_2016-05.zim.meta4 diff --git a/app/src/testShared/org/kiwix/kiwixmobile/TestConstants.kt b/core/src/testShared/org/kiwix/kiwixmobile/TestConstants.kt similarity index 100% rename from app/src/testShared/org/kiwix/kiwixmobile/TestConstants.kt rename to core/src/testShared/org/kiwix/kiwixmobile/TestConstants.kt diff --git a/app/src/testShared/org/kiwix/kiwixmobile/TestModelFunctions.kt b/core/src/testShared/org/kiwix/kiwixmobile/TestModelFunctions.kt similarity index 100% rename from app/src/testShared/org/kiwix/kiwixmobile/TestModelFunctions.kt rename to core/src/testShared/org/kiwix/kiwixmobile/TestModelFunctions.kt diff --git a/custom/build.gradle b/custom/build.gradle index 7ac4a6119..08ade3ebe 100644 --- a/custom/build.gradle +++ b/custom/build.gradle @@ -143,8 +143,29 @@ android { 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") + } } dependencies { implementation project(':core') + implementation(Libs.appcompat) } diff --git a/custom/lint-baseline.xml b/custom/lint-baseline.xml new file mode 100644 index 000000000..af7e1028d --- /dev/null +++ b/custom/lint-baseline.xml @@ -0,0 +1,188 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/custom/src/androidTest/java/org/kiwix/kiwixmobile/custom/ExampleInstrumentedTest.kt b/custom/src/androidTest/java/org/kiwix/kiwixmobile/custom/ExampleInstrumentedTest.kt deleted file mode 100644 index 2c59d535a..000000000 --- a/custom/src/androidTest/java/org/kiwix/kiwixmobile/custom/ExampleInstrumentedTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -package org.kiwix.kiwixmobile.custom - -import androidx.test.platform.app.InstrumentationRegistry -import androidx.test.ext.junit.runners.AndroidJUnit4 - -import org.junit.Test -import org.junit.runner.RunWith - -import org.junit.Assert.* - -/** - * Instrumented test, which will execute on an Android device. - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -@RunWith(AndroidJUnit4::class) -class ExampleInstrumentedTest { - @Test - fun useAppContext() { - // Context of the app under test. - val appContext = InstrumentationRegistry.getInstrumentation().targetContext - assertEquals("org.kiwix.kiwixmobile.custom", appContext.packageName) - } -} diff --git a/custom/src/test/java/org/kiwix/kiwixmobile/custom/ExampleUnitTest.kt b/custom/src/test/java/org/kiwix/kiwixmobile/custom/ExampleUnitTest.kt deleted file mode 100644 index b7bf49c18..000000000 --- a/custom/src/test/java/org/kiwix/kiwixmobile/custom/ExampleUnitTest.kt +++ /dev/null @@ -1,17 +0,0 @@ -package org.kiwix.kiwixmobile.custom - -import org.junit.Test - -import org.junit.Assert.* - -/** - * Example local unit test, which will execute on the development machine (host). - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -class ExampleUnitTest { - @Test - fun addition_isCorrect() { - assertEquals(4, 2 + 2) - } -} diff --git a/team-props/git-hooks.gradle b/team-props/git-hooks.gradle index 83bd52f00..41aae5d0b 100644 --- a/team-props/git-hooks.gradle +++ b/team-props/git-hooks.gradle @@ -24,3 +24,7 @@ task installGitHooks(type: Exec) { logger.info('Git hook installed successfully.') } } + +afterEvaluate { + tasks['preBuild'].dependsOn installGitHooks +} diff --git a/team-props/git-hooks/pre-commit.sh b/team-props/git-hooks/pre-commit.sh index 77231c23c..297062c39 100644 --- a/team-props/git-hooks/pre-commit.sh +++ b/team-props/git-hooks/pre-commit.sh @@ -2,7 +2,7 @@ echo "Running lint..." -./gradlew app:ktlintKiwixDebugCheck app:lintKiwixDebug --daemon +./gradlew ktlintCheck lint --daemon status=$? @@ -10,7 +10,7 @@ if [ "$status" = 0 ] ; then echo "Static analysis found no problems." exit 0 else - ./gradlew app:ktlintKiwixDebugFormat --daemon + ./gradlew ktlintFormat --daemon echo 1>&2 "Static analysis found violations and attempted to autofix, please commit these autoformat changes" echo "If the build failed for another reason please make sure JAVA_HOME is set to JDK8" exit 1