diff --git a/build.gradle.kts b/build.gradle.kts index 36385efed9..174d0adb3f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,10 +7,10 @@ import org.jetbrains.dokka.gradle.DokkaTaskPartial plugins { - id("com.android.application") apply false - id("com.android.library") apply false - id("org.jetbrains.kotlin.android") apply false - id("org.jetbrains.dokka") apply true + id(Plugins.ANDROID_APPLICATION) apply false version "7.2.2" + id(Plugins.ANDROID_LIBRARY) apply false version "7.2.2" + kotlin(Plugins.ANDROID) apply false + id(Plugins.DOKKA) apply true } subprojects { diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 0000000000..8e88a958d7 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,9 @@ +import org.gradle.kotlin.dsl.`kotlin-dsl` + +plugins { + `kotlin-dsl` +} + +repositories { + mavenCentral() +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/AndroidConfig.kt b/buildSrc/src/main/kotlin/AndroidConfig.kt new file mode 100644 index 0000000000..1228b2f60c --- /dev/null +++ b/buildSrc/src/main/kotlin/AndroidConfig.kt @@ -0,0 +1,47 @@ +import java.util.* + +object AndroidConfig { + const val APP_NAME = "R2 Reader" + const val APP_ID = "org.readium.r2reader" + const val MIN_SDK_VERSION = 21 + const val TARGET_SDK_VERSION = 32 + const val BUILD_TOOLS_VERSION = "30.0.3" + const val COMPILE_SDK_VERSION = 32 + const val NDK_VERSION = "23.0.7599858" + const val TEST_INSTRUMENTATION_RUNNER = "androidx.test.runner.AndroidJUnitRunner" + const val GROUP_ID = "com.github.readium" + const val VERSION_CODE = 1 + val VERSION_NAME = calculateVersionName() + private const val versionMajor = 2 + private const val versionMinor = 2 + private const val versionPatch = 0 + + private fun calculateVersionName(): String = "v$versionMajor.$versionMinor.$versionPatch" +} + +object Flavors { + object ProductFlavors { + const val DEV = "dev" + const val UAT = "uat" + const val PILOT = "pilot" + const val STORE = "store" + } + + object FlavorDimensions { + const val ENVIRONMENT = "environment" + } + + object BuildTypes { + const val DEBUG = "debug" + const val RELEASE = "release" + } + + object Default { + const val MAIN = "main" + private const val BUILD_TYPE = BuildTypes.DEBUG + private const val BUILD_FLAVOR = ProductFlavors.DEV + + val BUILD_VARIANT = + "${BUILD_FLAVOR.capitalize(Locale.ROOT)}${BUILD_TYPE.capitalize(Locale.ROOT)}" + } +} diff --git a/buildSrc/src/main/kotlin/Fields.kt b/buildSrc/src/main/kotlin/Fields.kt new file mode 100644 index 0000000000..fa8d828326 --- /dev/null +++ b/buildSrc/src/main/kotlin/Fields.kt @@ -0,0 +1,5 @@ +object Fields { + const val SERVICE_URL = "SERVICE_URL" + const val SERVICE_API_KEY = "SERVICE_API_KEY" // optional + const val SERVICE_CERTIFICATE_PATH = "SERVICE_CERTIFICATE_PATH" // optional +} diff --git a/buildSrc/src/main/kotlin/ModuleDependency.kt b/buildSrc/src/main/kotlin/ModuleDependency.kt new file mode 100644 index 0000000000..182d06121c --- /dev/null +++ b/buildSrc/src/main/kotlin/ModuleDependency.kt @@ -0,0 +1,47 @@ +import org.gradle.api.artifacts.Dependency +import org.gradle.api.artifacts.dsl.DependencyHandler +import kotlin.reflect.full.memberProperties + +// "Module" means "subproject" in terminology of Gradle API. +// To be specific each "Android module" is a Gradle "subproject" +@Suppress("unused") +object ModuleDependency { + // All consts are accessed via reflection + const val APP = ":app" + const val FEATURE_DATA = ":data" + + // False positive" function can be private" + // See: https://youtrack.jetbrains.com/issue/KT-33610 + /* + Return list of all modules in the project + */ + private fun getAllModules() = ModuleDependency::class.memberProperties + .filter { it.isConst } + .map { it.getter.call().toString() } + .toSet() + + /* + Return list of feature modules in the project + */ + fun getFeatureModules(): Set { + val featurePrefix = "" + + return getAllModules() + .filter { it.startsWith(featurePrefix) } + .toSet() + } + + object Project { + fun DependencyHandler.streamer(): Dependency = project(mapOf("path" to ":readium:streamer")) + fun DependencyHandler.navigator(): Dependency = + project(mapOf("path" to ":readium:navigator")) + + fun DependencyHandler.navigatorMedia2(): Dependency = + project(mapOf("path" to ":readium:navigator-media2")) + + fun DependencyHandler.opds(): Dependency = project(mapOf("path" to ":readium:opds")) + fun DependencyHandler.lcp(): Dependency = project(mapOf("path" to ":readium:lcp")) + fun DependencyHandler.shared(): Dependency = project(mapOf("path" to ":readium:shared")) + fun DependencyHandler.app(): Dependency = project(mapOf("path" to ":test-app")) + } +} diff --git a/buildSrc/src/main/kotlin/Plugins.kt b/buildSrc/src/main/kotlin/Plugins.kt new file mode 100644 index 0000000000..3bb16df057 --- /dev/null +++ b/buildSrc/src/main/kotlin/Plugins.kt @@ -0,0 +1,15 @@ +object Plugins { + const val ANDROID_LIBRARY = "com.android.library" + const val ANDROID_APPLICATION = "com.android.application" + const val ANDROID = "android" + const val KOTLIN_PARCELIZE = "kotlin-parcelize" + const val KOTLIN_ANDROID = "kotlin-android" + const val MAVEN_PUBLISH = "maven-publish" + const val DOKKA = "org.jetbrains.dokka" + const val KAPT = "kotlin-kapt" + const val SAFE_ARGS = "androidx.navigation.safeargs.kotlin" + const val DETEKT = "io.gitlab.arturbosch.detekt" + const val KTLINT_GRADLE = "org.jlleitschuh.gradle.ktlint" + const val ANDROID_JUNIT_5 = "de.mannodermaus.android-junit5" + const val DAGGER_HILT = "dagger.hilt.android.plugin" +} diff --git a/gradle.properties b/gradle.properties index cac7c68c14..c064741c76 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,3 +19,5 @@ android.useAndroidX=true android.enableJetifier=true # Kotlin code style for this project: "official" or "obsolete": kotlin.code.style=official + +android.disableAutomaticComponentCreation=true diff --git a/gradle/libs.versions.toml2 b/gradle/libs.versions.toml similarity index 56% rename from gradle/libs.versions.toml2 rename to gradle/libs.versions.toml index a862ab6d98..4a6306205b 100644 --- a/gradle/libs.versions.toml2 +++ b/gradle/libs.versions.toml @@ -1,19 +1,17 @@ -# Eventually want to use this for dependencies, but Android Studio is not ready - [versions] kotlin = "1.6.10" dokka = "1.5.30" -room = "2.4.0" +room = "2.4.1" coroutines = "1.6.0" exoplayer = "2.16.1" lifecycle = "2.4.0" navigation = "2.3.5" -constraint = "2.1.2" +constraint = "2.1.3" androidx-core = "1.7.0" -material = "1.4.0" +material = "1.5.0" androidx-browser = "1.4.0" activity-ktx = "1.4.0" -appcompat = "1.4.0" +appcompat = "1.4.1" fragment-ktx = "1.4.0" legacy = "1.0.0" recyclerview = "1.2.1" @@ -28,6 +26,15 @@ robolectric = "4.7.3" kotlin-junit = "1.6.10" assertj = "3.21.0" coroutines-test = "1.5.2" +kovenant = "3.3.0" +mcxiaoke = "0.5.5" +zeroturnaround = "1.14" +media2 = "1.2.1" +media = "1.6.0" +viewpager2 = "1.0.0" +work-runtime = "2.7.1" +fuel = "2.3.1" +nanohttpd = "master-SNAPSHOT" [libraries] kotlin-gradle = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" } @@ -40,11 +47,14 @@ coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutin exoplayer-core = { group = "com.google.android.exoplayer", name = "exoplayer-core", version.ref = "exoplayer" } exoplayer-ui = { group = "com.google.android.exoplayer", name = "exoplayer-ui", version.ref = "exoplayer" } exoplayer-mediasession = { group = "com.google.android.exoplayer", name = "extension-mediasession", version.ref = "exoplayer" } +exoplayer-extension-media2 = { group = "com.google.android.exoplayer", name = "extension-media2", version.ref = "exoplayer" } exoplayer-workmanager = { group = "com.google.android.exoplayer", name = "extension-workmanager", version.ref = "exoplayer" } lifecycle-livedata = { group = "androidx.lifecycle", name = "lifecycle-livedata-ktx", version.ref = "lifecycle" } lifecycle-runtime = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycle" } lifecycle-viewmodel = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-ktx", version.ref = "lifecycle" } lifecycle-vmsavedstate = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-savedstate", version.ref = "lifecycle" } +lifecycle-extensions = { group = "androidx.lifecycle", name = "lifecycle-extensions", version = "2.2.0" } +lifecycle-compiler = { group = "androidx.lifecycle", name = "lifecycle-compiler", version.ref = "lifecycle" } navigation-fragment = { group = "androidx.navigation", name = "navigation-fragment-ktx", version.ref = "navigation" } navigation-ui = { group = "androidx.navigation", name = "navigation-ui-ktx", version.ref = "navigation" } activity-ktx = { group = "androidx.activity", name = "activity-ktx", version.ref = "activity-ktx" } @@ -68,13 +78,48 @@ robolectric = { group = "org.robolectric", name = "robolectric", version.ref = " kotlin-junit = { group = "org.jetbrains.kotlin", name = "kotlin-test-junit", version.ref = "kotlin-junit" } assertj = { group = "org.assertj", name = "assertj-core", version.ref = "assertj" } coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "coroutines-test" } +kovenant-base = { group = "nl.komponents.kovenant", name = "kovenant", version.ref = "kovenant" } +kovenant-android = { group = "nl.komponents.kovenant", name = "kovenant-android", version.ref = "kovenant" } +kovenant-combine = { group = "nl.komponents.kovenant", name = "kovenant-combine", version.ref = "kovenant" } +kovenant-core = { group = "nl.komponents.kovenant", name = "kovenant-core", version.ref = "kovenant" } +kovenant-functional = { group = "nl.komponents.kovenant", name = "kovenant-functional", version.ref = "kovenant" } +kovenant-jvm = { group = "nl.komponents.kovenant", name = "kovenant-jvm", version.ref = "kovenant" } +mcxiaoke-async = { group = "com.mcxiaoke.koi", name = "async", version.ref = "mcxiaoke" } +mcxiaoke-core = { group = "com.mcxiaoke.koi", name = "core", version.ref = "mcxiaoke" } +zeroturnaround = { group = "org.zeroturnaround", name = "zt-zip", version.ref = "zeroturnaround" } +media2-session = { group = "androidx.media2", name = "media2-session", version.ref = "media2" } +media2-player = { group = "androidx.media2", name = "media2-player", version.ref = "media2" } +androidx-media = { group = "androidx.media", name = "media", version.ref = "media" } +androidx-viewpager2 = { group = "androidx.viewpager2", name = "viewpager2", version.ref = "viewpager2" } +androidx-work-runtime = { group = "androidx.work", name = "work-runtime-ktx", version.ref = "work-runtime" } +rtl-viewpager = { group = "com.duolingo.open", name = "rtl-viewpager", version = "1.0.3" } +pdf-viewer = { group = "com.github.barteksc", name = "android-pdf-viewer", version = "2.8.2" } +photoview = { group = "com.github.chrisbanes", name = "PhotoView", version = "2.3.0" } +shopgun-utils = { group = "com.shopgun.android", name = "utils", version = "1.0.9" } +fuel-android = { group = "com.github.kittinunf.fuel", name = "fuel-android", version.ref = "fuel" } +fuel-core = { group = "com.github.kittinunf.fuel", name = "fuel", version.ref = "fuel" } +kotlin-reflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect", version = "1.6.10" } +nanohttpd-core = { group = "com.github.edrlab.nanohttpd", name = "nanohttpd", version.ref = "nanohttpd" } +nanohttpd-nanolets = { group = "com.github.edrlab.nanohttpd", name = "nanohttpd-nanolets", version.ref = "nanohttpd" } +pdfium-android = { group = "com.github.barteksc", name = "pdfium-android", version = "1.8.2" } +androidx-cardview = { group = "androidx.cardview", name = "cardview", version = "1.0.0" } +androidx-paging = { group = "androidx.paging", name = "paging-runtime-ktx", version = "3.1.1" } +picasso = { group = "com.squareup.picasso", name = "picasso", version = "2.71828" } + +kotlin-stdlib-jdk8 = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-jdk8", version = "1.7.10" } + [bundles] -room = ["room-runtime", "room-compiler"] -exoplayer = ["exoplayer-core", "exoplayer-ui", "exoplayer-mediasession", "exoplayer-workmanager"] +room = ["room-runtime", "room-ktx"] +exoplayer = ["exoplayer-core", "exoplayer-ui", "exoplayer-mediasession", "exoplayer-extension-media2", "exoplayer-workmanager"] coroutines = ["coroutines-core", "coroutines-android"] lifecycle = ["lifecycle-livedata", "lifecycle-runtime", "lifecycle-viewmodel", "lifecycle-vmsavedstate"] navigation = ["navigation-fragment", "navigation-ui"] +mcxiaoke = ["mcxiaoke-async", "mcxiaoke-core"] +media2 = ["media2-session", "media2-player"] +fuel = ["fuel-android", "fuel-core"] +nanohttpd = ["nanohttpd-core", "nanohttpd-nanolets"] +kovenant = ["kovenant-base", "kovenant-android", "kovenant-combine", "kovenant-core", "kovenant-functional", "kovenant-jvm"] test-frameworks = ["junit", "ext-junit", "expresso-core", "robolectric", "kotlin-junit", "assertj", "coroutines-test"] [plugins] \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ffed3a254e..be08841210 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Mon Aug 22 14:58:22 TRT 2022 distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME diff --git a/readium/lcp/build.gradle.kts b/readium/lcp/build.gradle.kts index 9e129f175a..0371c09b83 100644 --- a/readium/lcp/build.gradle.kts +++ b/readium/lcp/build.gradle.kts @@ -1,3 +1,5 @@ +import ModuleDependency.Project.shared + /* * Copyright 2018 Readium Foundation. All rights reserved. * Use of this source code is governed by the BSD-style license @@ -5,21 +7,21 @@ */ plugins { - id("com.android.library") - id("kotlin-android") - id("kotlin-parcelize") - id("kotlin-kapt") - id("maven-publish") - id("org.jetbrains.dokka") + id(Plugins.ANDROID_LIBRARY) + id(Plugins.KOTLIN_ANDROID) + id(Plugins.KOTLIN_PARCELIZE) + id(Plugins.KAPT) + id(Plugins.MAVEN_PUBLISH) + id(Plugins.DOKKA) } android { - compileSdk = 31 + compileSdk = AndroidConfig.COMPILE_SDK_VERSION defaultConfig { - minSdk = 21 - targetSdk = 31 - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + minSdk = AndroidConfig.MIN_SDK_VERSION + targetSdk = AndroidConfig.TARGET_SDK_VERSION + testInstrumentationRunner = AndroidConfig.TEST_INSTRUMENTATION_RUNNER } compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 @@ -31,7 +33,7 @@ android { allWarningsAsErrors = true } buildTypes { - getByName("release") { + getByName(Flavors.BuildTypes.RELEASE) { isMinifyEnabled = false proguardFiles(getDefaultProguardFile("proguard-android.txt")) } @@ -41,9 +43,9 @@ android { afterEvaluate { publishing { publications { - create("release") { - from(components.getByName("release")) - groupId = "com.github.readium" + create(Flavors.BuildTypes.RELEASE) { + from(components.getByName(Flavors.BuildTypes.RELEASE)) + groupId = AndroidConfig.GROUP_ID artifactId = "readium-lcp" artifact(tasks.findByName("sourcesJar")) artifact(tasks.findByName("javadocsJar")) @@ -55,32 +57,27 @@ afterEvaluate { dependencies { implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0") + implementation(libs.coroutines.core) - api(project(":readium:shared")) + api(shared()) - implementation("androidx.constraintlayout:constraintlayout:2.1.3") - implementation("androidx.core:core-ktx:1.7.0") - implementation("com.google.android.material:material:1.5.0") - implementation("com.jakewharton.timber:timber:5.0.1") - implementation("com.mcxiaoke.koi:async:0.5.5") { - exclude(module = "support-v4") - } - implementation("com.mcxiaoke.koi:core:0.5.5") { + implementation(libs.constraint.layout) + implementation(libs.androidx.core) + implementation(libs.material) + implementation(libs.timber) + implementation(libs.bundles.mcxiaoke) { exclude(module = "support-v4") } - implementation("joda-time:joda-time:2.10.13") - implementation("org.zeroturnaround:zt-zip:1.14") - implementation("androidx.browser:browser:1.4.0") + implementation(libs.joda.time) + implementation(libs.zeroturnaround) + implementation(libs.androidx.browser) // Room database - val roomVersion = "2.4.1" - implementation("androidx.room:room-runtime:$roomVersion") - implementation("androidx.room:room-ktx:$roomVersion") - kapt("androidx.room:room-compiler:$roomVersion") + implementation(libs.bundles.room) + kapt(libs.room.compiler) // Tests - testImplementation("junit:junit:4.13.2") - androidTestImplementation("androidx.test.ext:junit:1.1.3") - androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0") + testImplementation(libs.junit) + androidTestImplementation(libs.ext.junit) + androidTestImplementation(libs.expresso.core) } diff --git a/readium/navigator-media2/build.gradle.kts b/readium/navigator-media2/build.gradle.kts index bb00fa18d7..03ab7155ae 100644 --- a/readium/navigator-media2/build.gradle.kts +++ b/readium/navigator-media2/build.gradle.kts @@ -1,3 +1,6 @@ +import ModuleDependency.Project.navigator +import ModuleDependency.Project.shared + /* * Copyright 2022 Readium Foundation. All rights reserved. * Use of this source code is governed by the BSD-style license @@ -5,22 +8,22 @@ */ plugins { - id("com.android.library") - id("kotlin-android") - id("kotlin-parcelize") - id("maven-publish") - id("org.jetbrains.dokka") + id(Plugins.ANDROID_LIBRARY) + id(Plugins.KOTLIN_ANDROID) + id(Plugins.KOTLIN_PARCELIZE) + id(Plugins.MAVEN_PUBLISH) + id(Plugins.DOKKA) } android { resourcePrefix = "readium_" - compileSdk = 31 + compileSdk = AndroidConfig.COMPILE_SDK_VERSION defaultConfig { - minSdk = 21 - targetSdk = 31 - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + minSdk = AndroidConfig.MIN_SDK_VERSION + targetSdk = AndroidConfig.TARGET_SDK_VERSION + testInstrumentationRunner = AndroidConfig.TEST_INSTRUMENTATION_RUNNER } compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 @@ -31,7 +34,7 @@ android { freeCompilerArgs = freeCompilerArgs + "-Xopt-in=kotlin.RequiresOptIn" } buildTypes { - getByName("release") { + getByName(Flavors.BuildTypes.RELEASE) { isMinifyEnabled = false proguardFiles(getDefaultProguardFile("proguard-android.txt")) } @@ -44,9 +47,9 @@ android { afterEvaluate { publishing { publications { - create("release") { - from(components.getByName("release")) - groupId = "com.github.readium" + create(Flavors.BuildTypes.RELEASE) { + from(components.getByName(Flavors.BuildTypes.RELEASE)) + groupId = AndroidConfig.GROUP_ID artifactId = "readium-navigator-media2" artifact(tasks.findByName("sourcesJar")) artifact(tasks.findByName("javadocsJar")) @@ -58,22 +61,20 @@ afterEvaluate { dependencies { implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) - api(project(":readium:shared")) - api(project(":readium:navigator")) + api(shared()) + api(navigator()) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0") + implementation(libs.bundles.coroutines) - implementation("com.jakewharton.timber:timber:5.0.1") + implementation(libs.timber) - implementation("androidx.media2:media2-session:1.2.0") - implementation("androidx.media2:media2-player:1.2.0") + implementation(libs.bundles.media2) - implementation("com.google.android.exoplayer:exoplayer-core:2.16.1") - implementation("com.google.android.exoplayer:extension-media2:2.16.1") + implementation(libs.exoplayer.core) + implementation(libs.exoplayer.extension.media2) - testImplementation("junit:junit:4.13.2") + testImplementation(libs.junit) - androidTestImplementation("androidx.test.ext:junit:1.1.3") - androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0") + androidTestImplementation(libs.ext.junit) + androidTestImplementation(libs.expresso.core) } diff --git a/readium/navigator/build.gradle.kts b/readium/navigator/build.gradle.kts index 27ca2bbdc3..0d29364093 100644 --- a/readium/navigator/build.gradle.kts +++ b/readium/navigator/build.gradle.kts @@ -1,3 +1,5 @@ +import ModuleDependency.Project.shared + /* * Copyright 2018 Readium Foundation. All rights reserved. * Use of this source code is governed by the BSD-style license @@ -5,23 +7,23 @@ */ plugins { - id("com.android.library") - id("kotlin-android") - id("kotlin-parcelize") - id("maven-publish") - id("org.jetbrains.dokka") + id(Plugins.ANDROID_LIBRARY) + id(Plugins.KOTLIN_ANDROID) + id(Plugins.KOTLIN_PARCELIZE) + id(Plugins.MAVEN_PUBLISH) + id(Plugins.DOKKA) } android { // FIXME: This doesn't pass the lint because some resources don"t start with r2_ yet. We need to rename all resources for the next major version. // resourcePrefix "r2_" - compileSdk = 31 + compileSdk = AndroidConfig.COMPILE_SDK_VERSION defaultConfig { - minSdk = 21 - targetSdk = 31 - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + minSdk = AndroidConfig.MIN_SDK_VERSION + targetSdk = AndroidConfig.TARGET_SDK_VERSION + testInstrumentationRunner = AndroidConfig.TEST_INSTRUMENTATION_RUNNER } compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 @@ -32,7 +34,7 @@ android { freeCompilerArgs = freeCompilerArgs + "-Xopt-in=kotlin.RequiresOptIn" } buildTypes { - getByName("release") { + getByName(Flavors.BuildTypes.RELEASE) { isMinifyEnabled = false proguardFiles(getDefaultProguardFile("proguard-android.txt")) } @@ -45,9 +47,9 @@ android { afterEvaluate { publishing { publications { - create("release") { - from(components.getByName("release")) - groupId = "com.github.readium" + create(Flavors.BuildTypes.RELEASE) { + from(components.getByName(Flavors.BuildTypes.RELEASE)) + groupId = AndroidConfig.GROUP_ID artifactId = "readium-navigator" artifact(tasks.findByName("sourcesJar")) artifact(tasks.findByName("javadocsJar")) @@ -59,51 +61,42 @@ afterEvaluate { dependencies { implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) - api(project(":readium:shared")) + api(shared()) - implementation("androidx.activity:activity-ktx:1.4.0") - implementation("androidx.appcompat:appcompat:1.4.1") - implementation("androidx.browser:browser:1.4.0") - implementation("androidx.constraintlayout:constraintlayout:2.1.3") - implementation("androidx.core:core-ktx:1.7.0") - implementation("androidx.fragment:fragment-ktx:1.4.0") - implementation("androidx.legacy:legacy-support-core-ui:1.0.0") - implementation("androidx.legacy:legacy-support-v4:1.0.0") - implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.4.0") - implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.4.0") - implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0") - implementation("androidx.lifecycle:lifecycle-viewmodel-savedstate:2.4.0") - implementation("androidx.recyclerview:recyclerview:1.2.1") - implementation("androidx.media:media:1.4.3") - implementation("androidx.viewpager2:viewpager2:1.0.0") - implementation("androidx.webkit:webkit:1.4.0") + implementation(libs.activity.ktx) + implementation(libs.appcompat) + implementation(libs.androidx.browser) + implementation(libs.constraint.layout) + implementation(libs.androidx.core) + implementation(libs.fragment.ktx) + implementation(libs.legacy.ui) + implementation(libs.legacy.v4) + implementation(libs.bundles.lifecycle) + implementation(libs.recyclerview) + implementation(libs.androidx.media) + implementation(libs.androidx.viewpager2) + implementation(libs.webkit) // Needed to avoid a crash with API 31, see https://stackoverflow.com/a/69152986/1474476 - implementation("androidx.work:work-runtime-ktx:2.7.1") - implementation("com.duolingo.open:rtl-viewpager:1.0.3") - api("com.github.barteksc:android-pdf-viewer:2.8.2") + implementation(libs.androidx.work.runtime) + implementation(libs.rtl.viewpager) + api(libs.pdf.viewer) // ChrisBane/PhotoView ( for the Zoom handling ) - implementation("com.github.chrisbanes:PhotoView:2.3.0") + implementation(libs.photoview) - implementation("androidx.media2:media2-session:1.2.0") - implementation("androidx.media2:media2-player:1.2.0") + implementation(libs.bundles.media2) // ExoPlayer is used by the Audio Navigator. - api("com.google.android.exoplayer:exoplayer-core:2.16.1") - api("com.google.android.exoplayer:exoplayer-ui:2.16.1") - api("com.google.android.exoplayer:extension-mediasession:2.16.1") - api("com.google.android.exoplayer:extension-media2:2.16.1") - api("com.google.android.exoplayer:extension-workmanager:2.16.1") - implementation("com.google.android.material:material:1.5.0") - implementation("com.jakewharton.timber:timber:5.0.1") - implementation("com.shopgun.android:utils:1.0.9") - implementation("joda-time:joda-time:2.10.13") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0") + api(libs.bundles.exoplayer) + implementation(libs.material) + implementation(libs.timber) + implementation(libs.shopgun.utils) + implementation(libs.joda.time) + implementation(libs.bundles.coroutines) // AM NOTE: needs to stay this version for now (June 24,2020) //noinspection GradleDependency - implementation("org.jsoup:jsoup:1.14.3") + implementation(libs.jsoup) // Tests - testImplementation("junit:junit:4.13.2") - androidTestImplementation("androidx.test.ext:junit:1.1.3") - androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0") + testImplementation(libs.junit) + androidTestImplementation(libs.ext.junit) + androidTestImplementation(libs.expresso.core) } diff --git a/readium/opds/build.gradle.kts b/readium/opds/build.gradle.kts index 7d24433244..2735858903 100644 --- a/readium/opds/build.gradle.kts +++ b/readium/opds/build.gradle.kts @@ -1,3 +1,5 @@ +import ModuleDependency.Project.shared + /* * Copyright 2018 Readium Foundation. All rights reserved. * Use of this source code is governed by the BSD-style license @@ -5,19 +7,19 @@ */ plugins { - id("com.android.library") - id("kotlin-android") - id("kotlin-parcelize") - id("maven-publish") - id("org.jetbrains.dokka") + id(Plugins.ANDROID_LIBRARY) + id(Plugins.KOTLIN_ANDROID) + id(Plugins.KOTLIN_PARCELIZE) + id(Plugins.MAVEN_PUBLISH) + id(Plugins.DOKKA) } android { - compileSdk = 31 + compileSdk = AndroidConfig.COMPILE_SDK_VERSION defaultConfig { - minSdk = 21 - targetSdk = 31 - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + minSdk = AndroidConfig.MIN_SDK_VERSION + targetSdk = AndroidConfig.TARGET_SDK_VERSION + testInstrumentationRunner = AndroidConfig.TEST_INSTRUMENTATION_RUNNER } compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 @@ -27,7 +29,7 @@ android { unitTests.isIncludeAndroidResources = true } buildTypes { - getByName("release") { + getByName(Flavors.BuildTypes.RELEASE) { isMinifyEnabled = false proguardFiles(getDefaultProguardFile("proguard-android.txt")) } @@ -37,9 +39,9 @@ android { afterEvaluate { publishing { publications { - create("release") { - from(components.getByName("release")) - groupId = "com.github.readium" + create(Flavors.BuildTypes.RELEASE) { + from(components.getByName(Flavors.BuildTypes.RELEASE)) + groupId = AndroidConfig.GROUP_ID artifactId = "readium-opds" artifact(tasks.findByName("sourcesJar")) artifact(tasks.findByName("javadocsJar")) @@ -51,17 +53,17 @@ afterEvaluate { dependencies { implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) - api(project(":readium:shared")) + api(shared()) - implementation("androidx.appcompat:appcompat:1.4.1") - implementation("com.jakewharton.timber:timber:5.0.1") - implementation("joda-time:joda-time:2.10.13") - implementation("nl.komponents.kovenant:kovenant:3.3.0") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0") + implementation(libs.appcompat) + implementation(libs.timber) + implementation(libs.joda.time) + implementation(libs.kovenant.base) + implementation(libs.coroutines.core) // Tests - testImplementation("junit:junit:4.13.2") - testImplementation("org.robolectric:robolectric:4.7.3") - androidTestImplementation("androidx.test.ext:junit:1.1.3") - androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0") + testImplementation(libs.junit) + testImplementation(libs.robolectric) + androidTestImplementation(libs.ext.junit) + androidTestImplementation(libs.expresso.core) } diff --git a/readium/shared/build.gradle.kts b/readium/shared/build.gradle.kts index 5058c61d6d..371ca28bd0 100644 --- a/readium/shared/build.gradle.kts +++ b/readium/shared/build.gradle.kts @@ -5,19 +5,19 @@ */ plugins { - id("com.android.library") - id("kotlin-android") - id("kotlin-parcelize") - id("maven-publish") - id("org.jetbrains.dokka") + id(Plugins.ANDROID_LIBRARY) + id(Plugins.KOTLIN_ANDROID) + id(Plugins.KOTLIN_PARCELIZE) + id(Plugins.MAVEN_PUBLISH) + id(Plugins.DOKKA) } android { - compileSdk = 31 + compileSdk = AndroidConfig.COMPILE_SDK_VERSION defaultConfig { - minSdk = 21 - targetSdk = 31 - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + minSdk = AndroidConfig.MIN_SDK_VERSION + targetSdk = AndroidConfig.TARGET_SDK_VERSION + testInstrumentationRunner = AndroidConfig.TEST_INSTRUMENTATION_RUNNER } compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 @@ -31,7 +31,7 @@ android { unitTests.isIncludeAndroidResources = true } buildTypes { - getByName("release") { + getByName(Flavors.BuildTypes.RELEASE) { isMinifyEnabled = false proguardFiles(getDefaultProguardFile("proguard-android.txt")) } @@ -41,9 +41,9 @@ android { afterEvaluate { publishing { publications { - create("release") { - from(components.getByName("release")) - groupId = "com.github.readium" + create(Flavors.BuildTypes.RELEASE) { + from(components.getByName(Flavors.BuildTypes.RELEASE)) + groupId = AndroidConfig.GROUP_ID artifactId = "readium-shared" artifact(tasks.findByName("sourcesJar")) artifact(tasks.findByName("javadocsJar")) @@ -55,29 +55,23 @@ afterEvaluate { dependencies { implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) - implementation("androidx.appcompat:appcompat:1.4.1") - implementation("androidx.browser:browser:1.4.0") - implementation("com.github.kittinunf.fuel:fuel-android:2.3.1") - implementation("com.github.kittinunf.fuel:fuel:2.3.1") - implementation("com.jakewharton.timber:timber:5.0.1") - implementation("joda-time:joda-time:2.10.13") - implementation("nl.komponents.kovenant:kovenant-android:3.3.0") - implementation("nl.komponents.kovenant:kovenant-combine:3.3.0") - implementation("nl.komponents.kovenant:kovenant-core:3.3.0") - implementation("nl.komponents.kovenant:kovenant-functional:3.3.0") - implementation("nl.komponents.kovenant:kovenant-jvm:3.3.0") - implementation("nl.komponents.kovenant:kovenant:3.3.0") - implementation("org.jetbrains.kotlin:kotlin-reflect:1.6.10") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0") - implementation("org.jsoup:jsoup:1.14.3") + implementation(libs.appcompat) + implementation(libs.androidx.browser) + implementation(libs.bundles.fuel) + implementation(libs.timber) + implementation(libs.joda.time) + implementation(libs.bundles.kovenant) + implementation(libs.kotlin.reflect) + implementation(libs.coroutines.core) + implementation(libs.jsoup) // Tests - testImplementation("junit:junit:4.13.2") - testImplementation("org.assertj:assertj-core:3.22.0") - testImplementation("org.jetbrains.kotlin:kotlin-test-junit:1.6.10") - testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.0") - testImplementation("org.robolectric:robolectric:4.7.3") + testImplementation(libs.junit) + testImplementation(libs.assertj) + testImplementation(libs.kotlin.junit) + testImplementation(libs.coroutines.test) + testImplementation(libs.robolectric) - androidTestImplementation("androidx.test.ext:junit:1.1.3") - androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0") + androidTestImplementation(libs.ext.junit) + androidTestImplementation(libs.expresso.core) } diff --git a/readium/streamer/build.gradle.kts b/readium/streamer/build.gradle.kts index 059b1090ab..a3eedd2b1e 100644 --- a/readium/streamer/build.gradle.kts +++ b/readium/streamer/build.gradle.kts @@ -1,3 +1,5 @@ +import ModuleDependency.Project.shared + /* * Copyright 2018 Readium Foundation. All rights reserved. * Use of this source code is governed by the BSD-style license @@ -5,19 +7,19 @@ */ plugins { - id("com.android.library") - id("kotlin-android") - id("kotlin-parcelize") - id("maven-publish") - id("org.jetbrains.dokka") + id(Plugins.ANDROID_LIBRARY) + id(Plugins.KOTLIN_ANDROID) + id(Plugins.KOTLIN_PARCELIZE) + id(Plugins.MAVEN_PUBLISH) + id(Plugins.DOKKA) } android { - compileSdk = 31 + compileSdk = AndroidConfig.COMPILE_SDK_VERSION defaultConfig { - minSdk = 21 - targetSdk = 31 - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + minSdk = AndroidConfig.MIN_SDK_VERSION + targetSdk = AndroidConfig.TARGET_SDK_VERSION + testInstrumentationRunner = AndroidConfig.TEST_INSTRUMENTATION_RUNNER } compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 @@ -31,7 +33,7 @@ android { allWarningsAsErrors = true } buildTypes { - getByName("release") { + getByName(Flavors.BuildTypes.RELEASE) { isMinifyEnabled = false proguardFiles(getDefaultProguardFile("proguard-android.txt")) } @@ -41,9 +43,9 @@ android { afterEvaluate { publishing { publications { - create("release") { - from(components.getByName("release")) - groupId = "com.github.readium" + create(Flavors.BuildTypes.RELEASE) { + from(components.getByName(Flavors.BuildTypes.RELEASE)) + groupId = AndroidConfig.GROUP_ID artifactId = "readium-streamer" artifact(tasks.findByName("sourcesJar")) artifact(tasks.findByName("javadocsJar")) @@ -55,33 +57,27 @@ afterEvaluate { dependencies { implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) - api(project(":readium:shared")) + api(shared()) - implementation("androidx.appcompat:appcompat:1.4.1") + implementation(libs.appcompat) @Suppress("GradleDependency") - implementation("com.github.barteksc:pdfium-android:1.8.2") - implementation("com.jakewharton.timber:timber:5.0.1") - implementation("com.github.edrlab.nanohttpd:nanohttpd:master-SNAPSHOT") { - exclude(group = "org.parboiled") - } - implementation("com.github.edrlab.nanohttpd:nanohttpd-nanolets:master-SNAPSHOT") { + implementation(libs.pdfium.android) + implementation(libs.timber) + implementation(libs.bundles.nanohttpd) { exclude(group = "org.parboiled") } //AM NOTE: conflicting support libraries, excluding these - implementation("com.mcxiaoke.koi:core:0.5.5") { - exclude(module = "support-v4") - } // useful extensions (only ~100k) - implementation("com.mcxiaoke.koi:async:0.5.5") { + implementation(libs.bundles.mcxiaoke) { exclude(module = "support-v4") } - implementation("joda-time:joda-time:2.10.13") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0") + implementation(libs.joda.time) + implementation(libs.coroutines.core) // Tests - testImplementation("junit:junit:4.13.2") - testImplementation("org.assertj:assertj-core:3.22.0") - testImplementation("org.robolectric:robolectric:4.7.3") - androidTestImplementation("androidx.test.ext:junit:1.1.3") - androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0") + testImplementation(libs.junit) + testImplementation(libs.assertj) + testImplementation(libs.robolectric) + androidTestImplementation(libs.ext.junit) + androidTestImplementation(libs.expresso.core) } diff --git a/settings.gradle.kts b/settings.gradle.kts index cbc6e1d962..4dac5a3438 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -4,8 +4,7 @@ * available in the top-level LICENSE file of the project. */ -// FIXME: Android Studio doesn't support the gradle/libs.versions.toml2 well yet. -//enableFeaturePreview("VERSION_CATALOGS") +enableFeaturePreview("VERSION_CATALOGS") pluginManagement { repositories { diff --git a/test-app/build.gradle.kts b/test-app/build.gradle.kts index 8668c53e61..186e9bc6c9 100644 --- a/test-app/build.gradle.kts +++ b/test-app/build.gradle.kts @@ -1,3 +1,10 @@ +import ModuleDependency.Project.lcp +import ModuleDependency.Project.navigator +import ModuleDependency.Project.navigatorMedia2 +import ModuleDependency.Project.opds +import ModuleDependency.Project.shared +import ModuleDependency.Project.streamer + /* * Copyright 2021 Readium Foundation. All rights reserved. * Use of this source code is governed by the BSD-style license @@ -5,24 +12,25 @@ */ plugins { - id("com.android.application") - id("kotlin-android") - id("kotlin-kapt") - id("kotlin-parcelize") + id(Plugins.ANDROID_APPLICATION) + id(Plugins.KOTLIN_ANDROID) + id(Plugins.KAPT) + id(Plugins.KOTLIN_PARCELIZE) } android { - compileSdk = 31 + compileSdk = AndroidConfig.COMPILE_SDK_VERSION defaultConfig { - minSdk = 21 - targetSdk = 31 - applicationId = "org.readium.r2reader" + minSdk = AndroidConfig.MIN_SDK_VERSION + targetSdk = AndroidConfig.TARGET_SDK_VERSION + + applicationId = AndroidConfig.APP_ID - versionName = "2.2.0" + versionName = AndroidConfig.VERSION_NAME - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + testInstrumentationRunner = AndroidConfig.TEST_INSTRUMENTATION_RUNNER ndk.abiFilters.add("armeabi-v7a") ndk.abiFilters.add("arm64-v8a") ndk.abiFilters.add("x86") @@ -40,7 +48,7 @@ android { viewBinding = true } buildTypes { - getByName("release") { + getByName(Flavors.BuildTypes.RELEASE) { isMinifyEnabled = false proguardFiles(getDefaultProguardFile("proguard-android.txt")) } @@ -50,7 +58,7 @@ android { } sourceSets { - getByName("main") { + getByName(Flavors.Default.MAIN) { java.srcDirs("src/main/java") res.srcDirs("src/main/res") assets.srcDirs("src/main/assets") @@ -60,62 +68,55 @@ android { dependencies { implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) - implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10") - implementation("androidx.legacy:legacy-support-v4:1.0.0") - - implementation(project(":readium:shared")) - implementation(project(":readium:streamer")) - implementation(project(":readium:navigator")) - implementation(project(":readium:navigator-media2")) - - implementation(project(":readium:opds")) - implementation(project(":readium:lcp")) - - implementation("androidx.core:core-ktx:1.7.0") - implementation("androidx.activity:activity-ktx:1.4.0") - implementation("androidx.appcompat:appcompat:1.4.1") - implementation("androidx.browser:browser:1.4.0") - implementation("androidx.cardview:cardview:1.0.0") - implementation("androidx.constraintlayout:constraintlayout:2.1.3") - implementation("androidx.fragment:fragment-ktx:1.4.0") - implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.4.0") - implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.4.0") - implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0") - implementation("androidx.navigation:navigation-fragment-ktx:2.3.5") - implementation("androidx.navigation:navigation-ui-ktx:2.3.5") - implementation("androidx.paging:paging-runtime-ktx:3.1.0") - implementation("androidx.recyclerview:recyclerview:1.2.1") - implementation("androidx.viewpager2:viewpager2:1.0.0") - implementation("androidx.webkit:webkit:1.4.0") - implementation("com.github.edrlab.nanohttpd:nanohttpd:master-SNAPSHOT") { - exclude(group = "org.parboiled") - } - implementation("com.github.edrlab.nanohttpd:nanohttpd-nanolets:master-SNAPSHOT") { + implementation(libs.kotlin.stdlib.jdk8) + implementation(libs.legacy.v4) + + implementation(shared()) + implementation(streamer()) + implementation(navigator()) + implementation(navigatorMedia2()) + + implementation(opds()) + implementation(lcp()) + + implementation(libs.androidx.core) + implementation(libs.activity.ktx) + implementation(libs.appcompat) + implementation(libs.androidx.browser) + implementation(libs.androidx.cardview) + implementation(libs.constraint.layout) + implementation(libs.fragment.ktx) + implementation(libs.lifecycle.livedata) + implementation(libs.lifecycle.runtime) + implementation(libs.lifecycle.viewmodel) + implementation(libs.bundles.navigation) + implementation(libs.androidx.paging) + implementation(libs.recyclerview) + implementation(libs.androidx.viewpager2) + implementation(libs.webkit) + implementation(libs.bundles.nanohttpd) { exclude(group = "org.parboiled") } - implementation("com.google.android.material:material:1.5.0") - implementation("com.jakewharton.timber:timber:5.0.1") + implementation(libs.material) + implementation(libs.timber) // AM NOTE: needs to stay this version for now (June 24,2020) - implementation("com.squareup.picasso:picasso:2.71828") - implementation("joda-time:joda-time:2.10.13") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0") + implementation(libs.picasso) + implementation(libs.joda.time) + implementation(libs.coroutines.core) // AM NOTE: needs to stay this version for now (June 24,2020) - implementation("org.jsoup:jsoup:1.14.3") + implementation(libs.jsoup) - implementation("androidx.media2:media2-session:1.2.0") - implementation("androidx.media2:media2-player:1.2.0") + implementation(libs.bundles.media2) // Room database - val roomVersion = "2.4.1" - implementation("androidx.room:room-runtime:$roomVersion") - implementation("androidx.room:room-ktx:$roomVersion") - kapt("androidx.room:room-compiler:$roomVersion") + implementation(libs.bundles.room) + kapt(libs.room.compiler) - implementation("androidx.lifecycle:lifecycle-extensions:2.2.0") - kapt("androidx.lifecycle:lifecycle-compiler:2.4.0") + implementation(libs.lifecycle.extensions) + kapt(libs.lifecycle.compiler) // Tests - testImplementation("junit:junit:4.13.2") - androidTestImplementation("androidx.test.ext:junit:1.1.3") - androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0") + testImplementation(libs.junit) + androidTestImplementation(libs.ext.junit) + androidTestImplementation(libs.expresso.core) }