Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 9 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import org.gradle.kotlin.dsl.`kotlin-dsl`

plugins {
`kotlin-dsl`
}

repositories {
mavenCentral()
}
47 changes: 47 additions & 0 deletions buildSrc/src/main/kotlin/AndroidConfig.kt
Original file line number Diff line number Diff line change
@@ -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)}"
}
}
5 changes: 5 additions & 0 deletions buildSrc/src/main/kotlin/Fields.kt
Original file line number Diff line number Diff line change
@@ -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
}
47 changes: 47 additions & 0 deletions buildSrc/src/main/kotlin/ModuleDependency.kt
Original file line number Diff line number Diff line change
@@ -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<String> {
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"))
}
}
15 changes: 15 additions & 0 deletions buildSrc/src/main/kotlin/Plugins.kt
Original file line number Diff line number Diff line change
@@ -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"
}
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
61 changes: 53 additions & 8 deletions gradle/libs.versions.toml2 → gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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" }
Expand All @@ -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" }
Expand All @@ -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]
5 changes: 3 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
65 changes: 31 additions & 34 deletions readium/lcp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
import ModuleDependency.Project.shared

/*
* Copyright 2018 Readium Foundation. All rights reserved.
* Use of this source code is governed by the BSD-style license
* available in the top-level LICENSE file of the project.
*/

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
Expand All @@ -31,7 +33,7 @@ android {
allWarningsAsErrors = true
}
buildTypes {
getByName("release") {
getByName(Flavors.BuildTypes.RELEASE) {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android.txt"))
}
Expand All @@ -41,9 +43,9 @@ android {
afterEvaluate {
publishing {
publications {
create<MavenPublication>("release") {
from(components.getByName("release"))
groupId = "com.github.readium"
create<MavenPublication>(Flavors.BuildTypes.RELEASE) {
from(components.getByName(Flavors.BuildTypes.RELEASE))
groupId = AndroidConfig.GROUP_ID
artifactId = "readium-lcp"
artifact(tasks.findByName("sourcesJar"))
artifact(tasks.findByName("javadocsJar"))
Expand All @@ -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)
}
Loading