From 7564f19d5eaeef02ac5d9f1f288a92075c49488d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Menu?= Date: Tue, 23 Jan 2024 15:17:57 +0100 Subject: [PATCH] Fix Maven Central publishing and refactor Gradle configurations (#452) --- .github/workflows/publish.yml | 26 +---- .gitignore | 6 + build.gradle.kts | 18 +-- buildSrc/build.gradle.kts | 21 ++++ buildSrc/settings.gradle.kts | 13 +++ .../readium.library-conventions.gradle.kts | 107 ++++++++++++++++++ gradle.properties | 8 ++ gradle/libs.versions.toml | 22 +++- gradle/wrapper/gradle-wrapper.properties | 2 +- .../adapters/exoplayer/audio/build.gradle.kts | 42 +------ .../exoplayer/audio/gradle.properties | 1 + readium/adapters/exoplayer/build.gradle.kts | 37 +----- readium/adapters/exoplayer/gradle.properties | 1 + readium/adapters/pdfium/build.gradle.kts | 37 +----- .../adapters/pdfium/document/build.gradle.kts | 40 +------ .../pdfium/document/gradle.properties | 1 + readium/adapters/pdfium/gradle.properties | 1 + .../pdfium/navigator/build.gradle.kts | 40 +------ .../pdfium/navigator/gradle.properties | 1 + readium/adapters/pspdfkit/build.gradle.kts | 37 +----- .../pspdfkit/document/build.gradle.kts | 40 +------ .../pspdfkit/document/gradle.properties | 1 + readium/adapters/pspdfkit/gradle.properties | 1 + .../pspdfkit/navigator/build.gradle.kts | 39 +------ .../pspdfkit/navigator/gradle.properties | 1 + readium/lcp/build.gradle.kts | 42 +------ readium/lcp/gradle.properties | 1 + readium/navigator-media2/build.gradle.kts | 38 +------ readium/navigator-media2/gradle.properties | 1 + .../media2/DefaultMetadataFactory.kt | 3 + .../navigator/media2/MediaMetadataFactory.kt | 2 + .../navigator/media2/MediaNavigator.kt | 4 + .../navigator/media2/SessionPlayerCallback.kt | 2 + .../navigator/media2/SessionPlayerFacade.kt | 2 + .../navigator/media2/SessionPlayerHelpers.kt | 2 + readium/navigator/build.gradle.kts | 44 +------ readium/navigator/gradle.properties | 1 + .../org/readium/r2/navigator/Deprecated.kt | 24 +--- .../readium/r2/navigator/VisualNavigator.kt | 22 +--- .../navigator/epub/EpubNavigatorFragment.kt | 2 +- .../r2/navigator/media/MediaService.kt | 3 + .../navigator/media/MediaSessionNavigator.kt | 7 +- .../media/extensions/MediaControllerCompat.kt | 2 + .../media/extensions/MediaSessionCompat.kt | 2 + .../navigators/media/audio/build.gradle.kts | 38 +------ .../navigators/media/audio/gradle.properties | 1 + readium/navigators/media/build.gradle.kts | 37 +----- .../navigators/media/common/build.gradle.kts | 40 +------ .../navigators/media/common/gradle.properties | 1 + readium/navigators/media/gradle.properties | 1 + readium/navigators/media/tts/build.gradle.kts | 42 +------ .../navigators/media/tts/gradle.properties | 1 + readium/opds/build.gradle.kts | 39 +------ readium/opds/gradle.properties | 1 + readium/shared/build.gradle.kts | 44 +------ readium/shared/gradle.properties | 1 + readium/streamer/build.gradle.kts | 39 +------ readium/streamer/gradle.properties | 1 + scripts/publish-module.gradle | 99 ---------------- scripts/publish-root.gradle | 45 -------- settings.gradle.kts | 30 +---- test-app/build.gradle.kts | 9 +- .../r2/testapp/reader/VisualReaderFragment.kt | 2 - 63 files changed, 270 insertions(+), 948 deletions(-) create mode 100644 buildSrc/build.gradle.kts create mode 100644 buildSrc/settings.gradle.kts create mode 100644 buildSrc/src/main/kotlin/readium.library-conventions.gradle.kts create mode 100644 readium/adapters/exoplayer/audio/gradle.properties create mode 100644 readium/adapters/exoplayer/gradle.properties create mode 100644 readium/adapters/pdfium/document/gradle.properties create mode 100644 readium/adapters/pdfium/gradle.properties create mode 100644 readium/adapters/pdfium/navigator/gradle.properties create mode 100644 readium/adapters/pspdfkit/document/gradle.properties create mode 100644 readium/adapters/pspdfkit/gradle.properties create mode 100644 readium/adapters/pspdfkit/navigator/gradle.properties create mode 100644 readium/lcp/gradle.properties create mode 100644 readium/navigator-media2/gradle.properties create mode 100644 readium/navigator/gradle.properties create mode 100644 readium/navigators/media/audio/gradle.properties create mode 100644 readium/navigators/media/common/gradle.properties create mode 100644 readium/navigators/media/gradle.properties create mode 100644 readium/navigators/media/tts/gradle.properties create mode 100644 readium/opds/gradle.properties create mode 100644 readium/shared/gradle.properties create mode 100644 readium/streamer/gradle.properties delete mode 100644 scripts/publish-module.gradle delete mode 100644 scripts/publish-root.gradle diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1b8a9556a8..aafe5cc62e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,4 +1,3 @@ -# Inspired by https://getstream.io/blog/publishing-libraries-to-mavencentral-2021/ name: Publish on: @@ -13,30 +12,17 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - with: - ref: develop - name: Set up JDK 17 uses: actions/setup-java@v3 with: distribution: adopt java-version: 17 - # Builds the release artifacts of the library - - name: Release build - run: ./gradlew assembleRelease - - # Generates other artifacts (javadocJar is optional) - - name: Source jar and dokka - run: ./gradlew androidSourcesJar javadocJar - - # Runs upload, and then closes & releases the repository - name: Publish to Maven Central - run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository + run: ./gradlew publishToMavenCentral --no-configuration-cache env: - OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} - OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} - SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} - SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} - SIGNING_KEY: ${{ secrets.SIGNING_KEY }} - SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} - + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }} diff --git a/.gitignore b/.gitignore index d46e9173c1..7ff29501cc 100644 --- a/.gitignore +++ b/.gitignore @@ -85,3 +85,9 @@ docs/index.md docs/package-list site/ androidTestResultsUserPreferences.xml + +# Custom Git patch enabling LCP in the Test App +lcp.patch + +# direnv file containing Maven Central secrets +.envrc diff --git a/build.gradle.kts b/build.gradle.kts index 922c54d8bb..7e96d92cc2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,20 +7,8 @@ import org.jetbrains.dokka.gradle.DokkaTaskPartial plugins { - id("com.android.application") apply false - id("com.android.library") apply false - id("io.github.gradle-nexus.publish-plugin") apply true - id("org.jetbrains.dokka") apply true - id("org.jetbrains.kotlin.android") apply false - id("com.google.devtools.ksp") apply false - id("org.jlleitschuh.gradle.ktlint") apply true -} - -apply(from = "$rootDir/scripts/publish-root.gradle") - -ext { - set("publish.groupId", "org.readium.kotlin-toolkit") - set("publish.version", "3.0.0-alpha.1") + alias(libs.plugins.dokka) + alias(libs.plugins.ktlint) } subprojects { @@ -28,8 +16,6 @@ subprojects { ktlint { android.set(true) - disabledRules.add("no-wildcard-imports") - disabledRules.add("max-line-length") } } diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 0000000000..ae750dd372 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,21 @@ +/* + * Copyright 2024 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 { + `kotlin-dsl` +} + +repositories { + gradlePluginPortal() + google() + mavenCentral() +} + +dependencies { + implementation(libs.plugin.android) + implementation(libs.plugin.kotlin) + implementation(libs.plugin.maven.publish) +} \ No newline at end of file diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts new file mode 100644 index 0000000000..956169c8f7 --- /dev/null +++ b/buildSrc/settings.gradle.kts @@ -0,0 +1,13 @@ +/* + * Copyright 2024 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. + */ + +dependencyResolutionManagement { + versionCatalogs { + create("libs") { + from(files("../gradle/libs.versions.toml")) + } + } +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/readium.library-conventions.gradle.kts b/buildSrc/src/main/kotlin/readium.library-conventions.gradle.kts new file mode 100644 index 0000000000..94635c26df --- /dev/null +++ b/buildSrc/src/main/kotlin/readium.library-conventions.gradle.kts @@ -0,0 +1,107 @@ +import com.vanniktech.maven.publish.SonatypeHost + +plugins { + // FIXME: For now, we cannot use the versions catalog in precompiled scripts: https://github.com/gradle/gradle/issues/15383 + id("com.android.library") + id("com.vanniktech.maven.publish") + id("org.jetbrains.kotlin.android") + kotlin("plugin.parcelize") +} + +group = property("pom.groupId") as String + +android { + resourcePrefix = "readium_" + + compileSdk = (property("android.compileSdk") as String).toInt() + + defaultConfig { + minSdk = (property("android.minSdk") as String).toInt() + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_1_8.toString() + allWarningsAsErrors = true + freeCompilerArgs = freeCompilerArgs + listOf( + "-opt-in=kotlin.RequiresOptIn", + "-opt-in=org.readium.r2.shared.InternalReadiumApi" + ) + } + + testOptions { + unitTests.isIncludeAndroidResources = true + } + + buildFeatures { + // FIXME: Look into whether we can remove this. + buildConfig = true + } + + buildTypes { + getByName("release") { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt")) + } + } +} + +kotlin { + explicitApi() +} + +mavenPublishing { + coordinates( + groupId = group.toString(), + artifactId = property("pom.artifactId") as String, + version = property("pom.version") as String + ) + + pom { + name.set(property("pom.artifactId") as String) + description.set("A toolkit for ebooks, audiobooks and comics written in Kotlin") + url.set("https://github.com/readium/kotlin-toolkit") + licenses { + license { + name.set("BSD-3-Clause license") + url.set("https://github.com/readium/kotlin-toolkit/blob/main/LICENSE") + } + } + developers { + developer { + id.set("aferditamuriqi") + name.set("Aferdita Muriqi") + email.set("aferdita.muriqi@gmail.com") + } + developer { + id.set("mickael-menu") + name.set("Mickaël Menu") + email.set("mickael.menu@gmail.com") + } + developer { + id.set("qnga") + name.set("Quentin Gliosca") + email.set("quentin.gliosca@gmail.com") + } + + developer { + id.set("username") + name.set("User Name") + url.set("https://github.com/username/") + } + } + scm { + url.set("https://github.com/readium/kotlin-toolkit") + connection.set("scm:git:github.com/readium/kotlin-toolkit.git") + developerConnection.set("scm:git:ssh://github.com/readium/kotlin-toolkit.git") + } + } + + publishToMavenCentral(SonatypeHost.S01) + signAllPublications() +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index cac7c68c14..f0436688ce 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,6 +4,14 @@ # any settings specified in this file. # For more details on how to configure your build environment visit # http://www.gradle.org/docs/current/userguide/build_environment.html + +pom.groupId=org.readium.kotlin-toolkit +pom.version=3.0.0-alpha.1 + +android.minSdk=21 +android.compileSdk=34 +android.targetSdk=34 + # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ecc21d3bb4..4102303856 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,9 @@ [versions] +kotlin = "1.9.22" +agp = "8.2.1" +gradle-maven-publish-plugin = "0.27.0" + accompanist = "0.32.0" androidx-activity = "1.8.2" @@ -45,11 +49,16 @@ joda-time = "2.12.6" jsoup = "1.17.2" junit = "4.13.2" -kotlin = "1.9.22" kotlinx-coroutines = "1.7.3" kotlinx-coroutines-test = "1.7.3" kotlinx-serialization-json = "1.6.2" +# Make sure to align with the Kotlin version. +# See https://github.com/google/ksp/releases +ksp = "1.9.22-1.0.16" + +ktlint = "11.5.1" + pdfium = "1.8.2" pdf-viewer = "2.8.2" #noinspection GradleDependency @@ -60,6 +69,7 @@ robolectric = "4.11.1" timber = "5.0.1" + [libraries] accompanist-themeadapter-material = { group = "com.google.accompanist", name = "accompanist-themeadapter-material", version.ref = "accompanist" } @@ -140,6 +150,15 @@ robolectric = { group = "org.robolectric", name = "robolectric", version.ref = " timber = { group = "com.jakewharton.timber", name = "timber", version.ref = "timber" } +plugin-android = { module = "com.android.tools.build:gradle", version.ref = "agp" } +plugin-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } +plugin-maven-publish = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "gradle-maven-publish-plugin" } + +[plugins] +kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } +dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } +ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" } +ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } [bundles] compose = ["androidx-compose-activity", "androidx-compose-animation", "androidx-compose-foundation", "androidx-compose-material", "androidx-compose-material3", "androidx-compose-material-icons", "androidx-compose-ui", "androidx-compose-ui-tooling"] @@ -151,4 +170,3 @@ media3 = ["androidx-media3-session", "androidx-media3-common", "androidx-media3- navigation = ["androidx-navigation-fragment", "androidx-navigation-ui"] room = ["androidx-room-runtime", "androidx-room-ktx"] test-frameworks = ["junit", "androidx-ext-junit", "androidx-expresso-core", "robolectric", "kotlin-junit", "assertj", "kotlinx-coroutines-test"] - diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 15de90249f..a595206642 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/readium/adapters/exoplayer/audio/build.gradle.kts b/readium/adapters/exoplayer/audio/build.gradle.kts index 93fd839bb3..d947f2002c 100644 --- a/readium/adapters/exoplayer/audio/build.gradle.kts +++ b/readium/adapters/exoplayer/audio/build.gradle.kts @@ -5,52 +5,14 @@ */ plugins { - id("com.android.library") - kotlin("android") - kotlin("plugin.parcelize") - kotlin("plugin.serialization") + id("readium.library-conventions") + alias(libs.plugins.kotlin.serialization) } android { - resourcePrefix = "readium_" - - compileSdk = 34 - - defaultConfig { - minSdk = 21 - targetSdk = 34 - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - kotlinOptions { - jvmTarget = JavaVersion.VERSION_17.toString() - freeCompilerArgs = freeCompilerArgs + listOf( - "-opt-in=kotlin.RequiresOptIn", - "-opt-in=org.readium.r2.shared.InternalReadiumApi" - ) - } - buildTypes { - getByName("release") { - isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android.txt")) - } - } - buildFeatures { - viewBinding = true - } namespace = "org.readium.adapter.exoplayer.audio" } -kotlin { - explicitApi() -} - -rootProject.ext["publish.artifactId"] = "readium-navigator-exoplayer-audio" -apply(from = "$rootDir/scripts/publish-module.gradle") - dependencies { api(project(":readium:readium-shared")) api(project(":readium:navigators:media:readium-navigator-media-audio")) diff --git a/readium/adapters/exoplayer/audio/gradle.properties b/readium/adapters/exoplayer/audio/gradle.properties new file mode 100644 index 0000000000..c36e342b0b --- /dev/null +++ b/readium/adapters/exoplayer/audio/gradle.properties @@ -0,0 +1 @@ +pom.artifactId=readium-adapter-exoplayer-audio diff --git a/readium/adapters/exoplayer/build.gradle.kts b/readium/adapters/exoplayer/build.gradle.kts index c36ab5a491..a6a00c2220 100644 --- a/readium/adapters/exoplayer/build.gradle.kts +++ b/readium/adapters/exoplayer/build.gradle.kts @@ -5,48 +5,13 @@ */ plugins { - id("com.android.library") - kotlin("android") - kotlin("plugin.parcelize") + id("readium.library-conventions") } android { - resourcePrefix = "readium_" - - compileSdk = 34 - - defaultConfig { - minSdk = 21 - targetSdk = 34 - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - kotlinOptions { - jvmTarget = JavaVersion.VERSION_17.toString() - freeCompilerArgs = freeCompilerArgs + listOf( - "-opt-in=kotlin.RequiresOptIn", - "-opt-in=org.readium.r2.shared.InternalReadiumApi" - ) - } - buildTypes { - getByName("release") { - isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android.txt")) - } - } namespace = "org.readium.adapter.exoplayer" } -kotlin { - explicitApi() -} - -rootProject.ext["publish.artifactId"] = "readium-adapter-exoplayer" -apply(from = "$rootDir/scripts/publish-module.gradle") - dependencies { api(project(":readium:adapters:exoplayer:readium-adapter-exoplayer-audio")) } diff --git a/readium/adapters/exoplayer/gradle.properties b/readium/adapters/exoplayer/gradle.properties new file mode 100644 index 0000000000..fcddf61c3f --- /dev/null +++ b/readium/adapters/exoplayer/gradle.properties @@ -0,0 +1 @@ +pom.artifactId=readium-adapter-exoplayer diff --git a/readium/adapters/pdfium/build.gradle.kts b/readium/adapters/pdfium/build.gradle.kts index de6e0c5a4e..96625ae489 100644 --- a/readium/adapters/pdfium/build.gradle.kts +++ b/readium/adapters/pdfium/build.gradle.kts @@ -5,48 +5,13 @@ */ plugins { - id("com.android.library") - kotlin("android") - kotlin("plugin.parcelize") + id("readium.library-conventions") } android { - resourcePrefix = "readium_" - - compileSdk = 34 - - defaultConfig { - minSdk = 21 - targetSdk = 34 - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - kotlinOptions { - jvmTarget = JavaVersion.VERSION_17.toString() - freeCompilerArgs = freeCompilerArgs + listOf( - "-opt-in=kotlin.RequiresOptIn", - "-opt-in=org.readium.r2.shared.InternalReadiumApi" - ) - } - buildTypes { - getByName("release") { - isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android.txt")) - } - } namespace = "org.readium.adapter.pdfium" } -kotlin { - explicitApi() -} - -rootProject.ext["publish.artifactId"] = "readium-adapter-pdfium" -apply(from = "$rootDir/scripts/publish-module.gradle") - dependencies { api(project(":readium:adapters:pdfium:readium-adapter-pdfium-document")) api(project(":readium:adapters:pdfium:readium-adapter-pdfium-navigator")) diff --git a/readium/adapters/pdfium/document/build.gradle.kts b/readium/adapters/pdfium/document/build.gradle.kts index c18cdbde30..e44ca05bef 100644 --- a/readium/adapters/pdfium/document/build.gradle.kts +++ b/readium/adapters/pdfium/document/build.gradle.kts @@ -5,51 +5,13 @@ */ plugins { - id("com.android.library") - kotlin("android") - kotlin("plugin.parcelize") + id("readium.library-conventions") } android { - resourcePrefix = "readium_" - - compileSdk = 34 - - defaultConfig { - minSdk = 21 - targetSdk = 34 - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - kotlinOptions { - jvmTarget = JavaVersion.VERSION_17.toString() - freeCompilerArgs = freeCompilerArgs + listOf( - "-opt-in=kotlin.RequiresOptIn", - "-opt-in=org.readium.r2.shared.InternalReadiumApi" - ) - } - buildTypes { - getByName("release") { - isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android.txt")) - } - } - buildFeatures { - viewBinding = true - } namespace = "org.readium.adapter.pdfium.document" } -kotlin { - explicitApi() -} - -rootProject.ext["publish.artifactId"] = "readium-adapter-pdfium-document" -apply(from = "$rootDir/scripts/publish-module.gradle") - dependencies { api(project(":readium:readium-shared")) diff --git a/readium/adapters/pdfium/document/gradle.properties b/readium/adapters/pdfium/document/gradle.properties new file mode 100644 index 0000000000..0a587d8a9f --- /dev/null +++ b/readium/adapters/pdfium/document/gradle.properties @@ -0,0 +1 @@ +pom.artifactId=readium-adapter-pdfium-document diff --git a/readium/adapters/pdfium/gradle.properties b/readium/adapters/pdfium/gradle.properties new file mode 100644 index 0000000000..cf57b2aea5 --- /dev/null +++ b/readium/adapters/pdfium/gradle.properties @@ -0,0 +1 @@ +pom.artifactId=readium-adapter-pdfium diff --git a/readium/adapters/pdfium/navigator/build.gradle.kts b/readium/adapters/pdfium/navigator/build.gradle.kts index 7afc1d3620..71e211cfc7 100644 --- a/readium/adapters/pdfium/navigator/build.gradle.kts +++ b/readium/adapters/pdfium/navigator/build.gradle.kts @@ -5,52 +5,18 @@ */ plugins { - id("com.android.library") - kotlin("android") - kotlin("plugin.parcelize") - kotlin("plugin.serialization") + id("readium.library-conventions") + alias(libs.plugins.kotlin.serialization) } android { - resourcePrefix = "readium_" - - compileSdk = 34 + namespace = "org.readium.adapter.pdfium.navigator" - defaultConfig { - minSdk = 21 - targetSdk = 34 - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - kotlinOptions { - jvmTarget = JavaVersion.VERSION_17.toString() - freeCompilerArgs = freeCompilerArgs + listOf( - "-opt-in=kotlin.RequiresOptIn", - "-opt-in=org.readium.r2.shared.InternalReadiumApi" - ) - } - buildTypes { - getByName("release") { - isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android.txt")) - } - } buildFeatures { viewBinding = true } - namespace = "org.readium.adapter.pdfium.navigator" } -kotlin { - explicitApi() -} - -rootProject.ext["publish.artifactId"] = "readium-adapter-pdfium-navigator" -apply(from = "$rootDir/scripts/publish-module.gradle") - dependencies { api(project(":readium:readium-shared")) api(project(":readium:readium-navigator")) diff --git a/readium/adapters/pdfium/navigator/gradle.properties b/readium/adapters/pdfium/navigator/gradle.properties new file mode 100644 index 0000000000..acbfdf6c29 --- /dev/null +++ b/readium/adapters/pdfium/navigator/gradle.properties @@ -0,0 +1 @@ +pom.artifactId=readium-adapter-pdfium-navigator diff --git a/readium/adapters/pspdfkit/build.gradle.kts b/readium/adapters/pspdfkit/build.gradle.kts index 30ba3d3e8b..74ee2ecda7 100644 --- a/readium/adapters/pspdfkit/build.gradle.kts +++ b/readium/adapters/pspdfkit/build.gradle.kts @@ -5,48 +5,13 @@ */ plugins { - id("com.android.library") - kotlin("android") - kotlin("plugin.parcelize") + id("readium.library-conventions") } android { - resourcePrefix = "readium_" - - compileSdk = 34 - - defaultConfig { - minSdk = 21 - targetSdk = 34 - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - kotlinOptions { - jvmTarget = JavaVersion.VERSION_17.toString() - freeCompilerArgs = freeCompilerArgs + listOf( - "-opt-in=kotlin.RequiresOptIn", - "-opt-in=org.readium.r2.shared.InternalReadiumApi" - ) - } - buildTypes { - getByName("release") { - isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android.txt")) - } - } namespace = "org.readium.adapter.pspdfkit" } -kotlin { - explicitApi() -} - -rootProject.ext["publish.artifactId"] = "readium-adapter-pspdfkit" -apply(from = "$rootDir/scripts/publish-module.gradle") - dependencies { api(project(":readium:adapters:pspdfkit:readium-adapter-pspdfkit-document")) api(project(":readium:adapters:pspdfkit:readium-adapter-pspdfkit-navigator")) diff --git a/readium/adapters/pspdfkit/document/build.gradle.kts b/readium/adapters/pspdfkit/document/build.gradle.kts index 84322e6426..96271e024c 100644 --- a/readium/adapters/pspdfkit/document/build.gradle.kts +++ b/readium/adapters/pspdfkit/document/build.gradle.kts @@ -5,51 +5,13 @@ */ plugins { - id("com.android.library") - kotlin("android") - kotlin("plugin.parcelize") + id("readium.library-conventions") } android { - resourcePrefix = "readium_" - - compileSdk = 34 - - defaultConfig { - minSdk = 21 - targetSdk = 34 - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - kotlinOptions { - jvmTarget = JavaVersion.VERSION_17.toString() - freeCompilerArgs = freeCompilerArgs + listOf( - "-opt-in=kotlin.RequiresOptIn", - "-opt-in=org.readium.r2.shared.InternalReadiumApi" - ) - } - buildTypes { - getByName("release") { - isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android.txt")) - } - } - buildFeatures { - viewBinding = true - } namespace = "org.readium.adapter.pspdfkit.document" } -kotlin { - explicitApi() -} - -rootProject.ext["publish.artifactId"] = "readium-adapter-pspdfkit-document" -apply(from = "$rootDir/scripts/publish-module.gradle") - dependencies { api(project(":readium:readium-shared")) diff --git a/readium/adapters/pspdfkit/document/gradle.properties b/readium/adapters/pspdfkit/document/gradle.properties new file mode 100644 index 0000000000..43f971bd88 --- /dev/null +++ b/readium/adapters/pspdfkit/document/gradle.properties @@ -0,0 +1 @@ +pom.artifactId=readium-adapter-pspdfkit-document diff --git a/readium/adapters/pspdfkit/gradle.properties b/readium/adapters/pspdfkit/gradle.properties new file mode 100644 index 0000000000..16b717ac36 --- /dev/null +++ b/readium/adapters/pspdfkit/gradle.properties @@ -0,0 +1 @@ +pom.artifactId=readium-adapter-pspdfkit diff --git a/readium/adapters/pspdfkit/navigator/build.gradle.kts b/readium/adapters/pspdfkit/navigator/build.gradle.kts index 98e163027d..7f062e44e7 100644 --- a/readium/adapters/pspdfkit/navigator/build.gradle.kts +++ b/readium/adapters/pspdfkit/navigator/build.gradle.kts @@ -5,52 +5,17 @@ */ plugins { - id("com.android.library") - kotlin("android") - kotlin("plugin.parcelize") - kotlin("plugin.serialization") + id("readium.library-conventions") + alias(libs.plugins.kotlin.serialization) } android { - resourcePrefix = "readium_" - - compileSdk = 34 - - defaultConfig { - minSdk = 21 - targetSdk = 34 - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - kotlinOptions { - jvmTarget = JavaVersion.VERSION_17.toString() - freeCompilerArgs = freeCompilerArgs + listOf( - "-opt-in=kotlin.RequiresOptIn", - "-opt-in=org.readium.r2.shared.InternalReadiumApi" - ) - } - buildTypes { - getByName("release") { - isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android.txt")) - } - } buildFeatures { viewBinding = true } namespace = "org.readium.adapter.pspdfkit.navigator" } -kotlin { - explicitApi() -} - -rootProject.ext["publish.artifactId"] = "readium-adapter-pspdfkit-navigator" -apply(from = "$rootDir/scripts/publish-module.gradle") - dependencies { api(project(":readium:readium-shared")) api(project(":readium:readium-navigator")) diff --git a/readium/adapters/pspdfkit/navigator/gradle.properties b/readium/adapters/pspdfkit/navigator/gradle.properties new file mode 100644 index 0000000000..d21b6e1da1 --- /dev/null +++ b/readium/adapters/pspdfkit/navigator/gradle.properties @@ -0,0 +1 @@ +pom.artifactId=readium-adapter-pspdfkit-navigator diff --git a/readium/lcp/build.gradle.kts b/readium/lcp/build.gradle.kts index 57da92b017..b165d4ab67 100644 --- a/readium/lcp/build.gradle.kts +++ b/readium/lcp/build.gradle.kts @@ -5,52 +5,14 @@ */ plugins { - id("com.android.library") - kotlin("android") - kotlin("plugin.parcelize") - id("com.google.devtools.ksp") + id("readium.library-conventions") + alias(libs.plugins.ksp) } android { - resourcePrefix = "readium_" - - compileSdk = 34 - defaultConfig { - minSdk = 21 - targetSdk = 34 - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - kotlinOptions { - jvmTarget = JavaVersion.VERSION_17.toString() - allWarningsAsErrors = true - freeCompilerArgs = freeCompilerArgs + listOf( - "-opt-in=kotlin.RequiresOptIn", - "-opt-in=org.readium.r2.shared.InternalReadiumApi" - ) - } - buildTypes { - getByName("release") { - isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android.txt")) - } - } - buildFeatures { - buildConfig = true - } namespace = "org.readium.r2.lcp" } -kotlin { - explicitApi() -} - -rootProject.ext["publish.artifactId"] = "readium-lcp" -apply(from = "$rootDir/scripts/publish-module.gradle") - dependencies { implementation(libs.kotlinx.coroutines.core) diff --git a/readium/lcp/gradle.properties b/readium/lcp/gradle.properties new file mode 100644 index 0000000000..1338f9e2f0 --- /dev/null +++ b/readium/lcp/gradle.properties @@ -0,0 +1 @@ +pom.artifactId=readium-lcp diff --git a/readium/navigator-media2/build.gradle.kts b/readium/navigator-media2/build.gradle.kts index 1bed109721..135ae68d67 100644 --- a/readium/navigator-media2/build.gradle.kts +++ b/readium/navigator-media2/build.gradle.kts @@ -5,51 +5,17 @@ */ plugins { - id("com.android.library") - kotlin("android") - kotlin("plugin.parcelize") + id("readium.library-conventions") } android { - resourcePrefix = "readium_" - - compileSdk = 34 + namespace = "org.readium.navigator.media2" - defaultConfig { - minSdk = 21 - targetSdk = 34 - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - kotlinOptions { - jvmTarget = JavaVersion.VERSION_17.toString() - freeCompilerArgs = freeCompilerArgs + listOf( - "-opt-in=kotlin.RequiresOptIn", - "-opt-in=org.readium.r2.shared.InternalReadiumApi" - ) - } - buildTypes { - getByName("release") { - isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android.txt")) - } - } buildFeatures { viewBinding = true } - namespace = "org.readium.navigator.media2" } -kotlin { - explicitApi() -} - -rootProject.ext["publish.artifactId"] = "readium-navigator-media2" -apply(from = "$rootDir/scripts/publish-module.gradle") - dependencies { api(project(":readium:readium-shared")) api(project(":readium:readium-navigator")) diff --git a/readium/navigator-media2/gradle.properties b/readium/navigator-media2/gradle.properties new file mode 100644 index 0000000000..ea48497441 --- /dev/null +++ b/readium/navigator-media2/gradle.properties @@ -0,0 +1 @@ +pom.artifactId=readium-navigator-media2 diff --git a/readium/navigator-media2/src/main/java/org/readium/navigator/media2/DefaultMetadataFactory.kt b/readium/navigator-media2/src/main/java/org/readium/navigator/media2/DefaultMetadataFactory.kt index 1e9311ce04..40ed10435a 100644 --- a/readium/navigator-media2/src/main/java/org/readium/navigator/media2/DefaultMetadataFactory.kt +++ b/readium/navigator-media2/src/main/java/org/readium/navigator/media2/DefaultMetadataFactory.kt @@ -1,3 +1,5 @@ +@file:Suppress("DEPRECATION") + package org.readium.navigator.media2 import android.graphics.Bitmap @@ -9,6 +11,7 @@ import kotlinx.coroutines.async import org.readium.r2.shared.publication.Publication import org.readium.r2.shared.publication.services.cover +@Suppress("DEPRECATION") @ExperimentalMedia2 internal class DefaultMetadataFactory(private val publication: Publication) : MediaMetadataFactory { diff --git a/readium/navigator-media2/src/main/java/org/readium/navigator/media2/MediaMetadataFactory.kt b/readium/navigator-media2/src/main/java/org/readium/navigator/media2/MediaMetadataFactory.kt index d378433196..0149ef1bba 100644 --- a/readium/navigator-media2/src/main/java/org/readium/navigator/media2/MediaMetadataFactory.kt +++ b/readium/navigator-media2/src/main/java/org/readium/navigator/media2/MediaMetadataFactory.kt @@ -1,3 +1,5 @@ +@file:Suppress("DEPRECATION") + package org.readium.navigator.media2 import androidx.media2.common.MediaMetadata diff --git a/readium/navigator-media2/src/main/java/org/readium/navigator/media2/MediaNavigator.kt b/readium/navigator-media2/src/main/java/org/readium/navigator/media2/MediaNavigator.kt index 9534a6eaf5..5c2c653f98 100644 --- a/readium/navigator-media2/src/main/java/org/readium/navigator/media2/MediaNavigator.kt +++ b/readium/navigator-media2/src/main/java/org/readium/navigator/media2/MediaNavigator.kt @@ -55,6 +55,7 @@ import timber.log.Timber * providing [create] with it. If you don't, ExoPlayer will be used, without cache. * You can build your own [SessionPlayer] based on [ExoPlayer] using [ExoPlayerDataSource]. */ +@ExperimentalMedia2 @Deprecated("Use the new AudioNavigator from the readium-navigator-media-audio module.") @OptIn(ExperimentalTime::class) public class MediaNavigator private constructor( @@ -383,16 +384,19 @@ public class MediaNavigator private constructor( return true } + @Suppress("UNUSED_PARAMETER") public fun goForward(animated: Boolean, completion: () -> Unit): Boolean { launchAndRun({ goForward() }, completion) return true } + @Suppress("UNUSED_PARAMETER") public fun goBackward(animated: Boolean, completion: () -> Unit): Boolean { launchAndRun({ goBackward() }, completion) return true } + @ExperimentalMedia2 public companion object { public suspend fun create( diff --git a/readium/navigator-media2/src/main/java/org/readium/navigator/media2/SessionPlayerCallback.kt b/readium/navigator-media2/src/main/java/org/readium/navigator/media2/SessionPlayerCallback.kt index b06d0d69ba..665004a43f 100644 --- a/readium/navigator-media2/src/main/java/org/readium/navigator/media2/SessionPlayerCallback.kt +++ b/readium/navigator-media2/src/main/java/org/readium/navigator/media2/SessionPlayerCallback.kt @@ -4,6 +4,8 @@ * available in the top-level LICENSE file of the project. */ +@file:Suppress("DEPRECATION") + package org.readium.navigator.media2 import androidx.media2.common.MediaItem diff --git a/readium/navigator-media2/src/main/java/org/readium/navigator/media2/SessionPlayerFacade.kt b/readium/navigator-media2/src/main/java/org/readium/navigator/media2/SessionPlayerFacade.kt index a8853c2e33..d768e7eff7 100644 --- a/readium/navigator-media2/src/main/java/org/readium/navigator/media2/SessionPlayerFacade.kt +++ b/readium/navigator-media2/src/main/java/org/readium/navigator/media2/SessionPlayerFacade.kt @@ -4,6 +4,8 @@ * available in the top-level LICENSE file of the project. */ +@file:Suppress("DEPRECATION") + package org.readium.navigator.media2 import android.app.PendingIntent diff --git a/readium/navigator-media2/src/main/java/org/readium/navigator/media2/SessionPlayerHelpers.kt b/readium/navigator-media2/src/main/java/org/readium/navigator/media2/SessionPlayerHelpers.kt index b8750c2fbe..62f319e04e 100644 --- a/readium/navigator-media2/src/main/java/org/readium/navigator/media2/SessionPlayerHelpers.kt +++ b/readium/navigator-media2/src/main/java/org/readium/navigator/media2/SessionPlayerHelpers.kt @@ -4,6 +4,8 @@ * available in the top-level LICENSE file of the project. */ +@file:Suppress("DEPRECATION") + package org.readium.navigator.media2 import androidx.media2.common.MediaItem diff --git a/readium/navigator/build.gradle.kts b/readium/navigator/build.gradle.kts index 3efe7385f0..a4598f1418 100644 --- a/readium/navigator/build.gradle.kts +++ b/readium/navigator/build.gradle.kts @@ -5,56 +5,18 @@ */ plugins { - id("com.android.library") - kotlin("android") - kotlin("plugin.parcelize") - kotlin("plugin.serialization") + id("readium.library-conventions") + alias(libs.plugins.kotlin.serialization) } android { - resourcePrefix = "readium_" - - compileSdk = 34 + namespace = "org.readium.r2.navigator" - defaultConfig { - minSdk = 21 - targetSdk = 34 - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - kotlinOptions { - jvmTarget = JavaVersion.VERSION_17.toString() - freeCompilerArgs = freeCompilerArgs + listOf( - "-opt-in=kotlin.RequiresOptIn", - "-opt-in=org.readium.r2.shared.InternalReadiumApi" - ) - } - testOptions { - unitTests.isIncludeAndroidResources = true - } - buildTypes { - getByName("release") { - isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android.txt")) - } - } buildFeatures { viewBinding = true - buildConfig = true } - namespace = "org.readium.r2.navigator" } -kotlin { - explicitApi() -} - -rootProject.ext["publish.artifactId"] = "readium-navigator" -apply(from = "$rootDir/scripts/publish-module.gradle") - dependencies { api(project(":readium:readium-shared")) diff --git a/readium/navigator/gradle.properties b/readium/navigator/gradle.properties new file mode 100644 index 0000000000..228ace6413 --- /dev/null +++ b/readium/navigator/gradle.properties @@ -0,0 +1 @@ +pom.artifactId=readium-navigator diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/Deprecated.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/Deprecated.kt index 62fbe79ddd..0f5af43f63 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/Deprecated.kt +++ b/readium/navigator/src/main/java/org/readium/r2/navigator/Deprecated.kt @@ -7,6 +7,8 @@ * LICENSE file present in the project repository where this source code is maintained. */ +@file:Suppress("UnusedReceiverParameter", "UnusedParameter") + package org.readium.r2.navigator import kotlin.time.Duration @@ -79,25 +81,3 @@ public interface MediaNavigator : Navigator { public interface Listener : Navigator.Listener } - -/** - * Moves to the left content portion (eg. page) relative to the reading progression direction. - */ -@Deprecated( - "Use a DirectionalNavigationAdapter or goFoward and goBackward.", - level = DeprecationLevel.ERROR -) -public fun VisualNavigator.goLeft(animated: Boolean = false, completion: () -> Unit = {}): Boolean { - throw NotImplementedError() -} - -/** - * Moves to the right content portion (eg. page) relative to the reading progression direction. - */ -@Deprecated( - "Use a DirectionalNavigationAdapter or goFoward and goBackward.", - level = DeprecationLevel.ERROR -) -public fun VisualNavigator.goRight(animated: Boolean = false, completion: () -> Unit = {}): Boolean { - throw NotImplementedError() -} diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/VisualNavigator.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/VisualNavigator.kt index 18c2796251..3b999299ce 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/VisualNavigator.kt +++ b/readium/navigator/src/main/java/org/readium/r2/navigator/VisualNavigator.kt @@ -121,24 +121,6 @@ public interface VisualNavigator : Navigator { level = DeprecationLevel.ERROR ) public val readingProgression: PublicationReadingProgression - - /** - * Moves to the next content portion (eg. page) in the reading progression direction. - */ - @Deprecated( - "Moved to OverflowableNavigator", - level = DeprecationLevel.ERROR - ) - public fun goForward(animated: Boolean = false, completion: () -> Unit = {}): Boolean - - /** - * Moves to the previous content portion (eg. page) in the reading progression direction. - */ - @Deprecated( - "Moved to OverflowableNavigator", - level = DeprecationLevel.ERROR - ) - public fun goBackward(animated: Boolean = false, completion: () -> Unit = {}): Boolean } /** @@ -179,10 +161,10 @@ public interface OverflowableNavigator : VisualNavigator { /** * Moves to the next content portion (eg. page) in the reading progression direction. */ - public override fun goForward(animated: Boolean, completion: () -> Unit): Boolean + public fun goForward(animated: Boolean = false, completion: () -> Unit = {}): Boolean /** * Moves to the previous content portion (eg. page) in the reading progression direction. */ - public override fun goBackward(animated: Boolean, completion: () -> Unit): Boolean + public fun goBackward(animated: Boolean = false, completion: () -> Unit = {}): Boolean } diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/epub/EpubNavigatorFragment.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/epub/EpubNavigatorFragment.kt index fa62e9aa54..62c2c700ec 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/epub/EpubNavigatorFragment.kt +++ b/readium/navigator/src/main/java/org/readium/r2/navigator/epub/EpubNavigatorFragment.kt @@ -353,7 +353,7 @@ public class EpubNavigatorFragment internal constructor( // TODO needs work, currently showing two resources for fxl, needs to understand which two resources, left & right, or only right etc. var doublePageLeft: Link? = null - var doublePageRight: Link? = null + var doublePageRight: Link? for ((index, link) in readingOrder.withIndex()) { val url = viewModel.urlTo(link) diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media/MediaService.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/media/MediaService.kt index 10647f8b42..2ffc585458 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media/MediaService.kt +++ b/readium/navigator/src/main/java/org/readium/r2/navigator/media/MediaService.kt @@ -4,6 +4,8 @@ * available in the top-level LICENSE file of the project. */ +@file:Suppress("DEPRECATION") + package org.readium.r2.navigator.media import android.app.Notification @@ -47,6 +49,7 @@ import timber.log.Timber */ @ExperimentalAudiobook @OptIn(ExperimentalCoroutinesApi::class) +@Deprecated("Use the new AudioNavigator from the readium-navigator-media-audio module.") public open class MediaService : MediaBrowserServiceCompat(), CoroutineScope by MainScope() { /** diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media/MediaSessionNavigator.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/media/MediaSessionNavigator.kt index 11cd4d0b5d..633bb67909 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media/MediaSessionNavigator.kt +++ b/readium/navigator/src/main/java/org/readium/r2/navigator/media/MediaSessionNavigator.kt @@ -4,6 +4,8 @@ * available in the top-level LICENSE file of the project. */ +@file:Suppress("DEPRECATION") + package org.readium.r2.navigator.media import android.media.session.PlaybackState @@ -18,6 +20,7 @@ import kotlin.time.Duration.Companion.seconds import kotlin.time.ExperimentalTime import kotlinx.coroutines.* import kotlinx.coroutines.flow.* +import org.readium.r2.navigator.ExperimentalAudiobook import org.readium.r2.navigator.MediaNavigator import org.readium.r2.navigator.extensions.normalizeLocator import org.readium.r2.navigator.extensions.sum @@ -45,7 +48,7 @@ private val skipBackwardInterval: Duration = 30.seconds * An implementation of [MediaNavigator] using an Android's MediaSession compatible media player. */ @Deprecated("Use the new AudioNavigator from the readium-navigator-media-audio module.") -@OptIn(ExperimentalTime::class) +@OptIn(ExperimentalTime::class, ExperimentalAudiobook::class) public class MediaSessionNavigator( public val publication: Publication, public val publicationId: PublicationId, @@ -208,6 +211,7 @@ public class MediaSessionNavigator( return go(locator, animated, completion) } + @Suppress("UNUSED_PARAMETER") public fun goForward(animated: Boolean = true, completion: () -> Unit = {}): Boolean { if (!isActive) return false @@ -216,6 +220,7 @@ public class MediaSessionNavigator( return true } + @Suppress("UNUSED_PARAMETER") public fun goBackward(animated: Boolean = true, completion: () -> Unit = {}): Boolean { if (!isActive) return false diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media/extensions/MediaControllerCompat.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/media/extensions/MediaControllerCompat.kt index 8bc24c7e1f..ec7723fe1f 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media/extensions/MediaControllerCompat.kt +++ b/readium/navigator/src/main/java/org/readium/r2/navigator/media/extensions/MediaControllerCompat.kt @@ -4,6 +4,8 @@ * available in the top-level LICENSE file of the project. */ +@file:Suppress("DEPRECATION") + package org.readium.r2.navigator.media.extensions import android.support.v4.media.session.MediaControllerCompat diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/media/extensions/MediaSessionCompat.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/media/extensions/MediaSessionCompat.kt index 0aec00990e..7ddee9864a 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/media/extensions/MediaSessionCompat.kt +++ b/readium/navigator/src/main/java/org/readium/r2/navigator/media/extensions/MediaSessionCompat.kt @@ -4,6 +4,8 @@ * available in the top-level LICENSE file of the project. */ +@file:Suppress("DEPRECATION") + package org.readium.r2.navigator.media.extensions import android.os.Bundle diff --git a/readium/navigators/media/audio/build.gradle.kts b/readium/navigators/media/audio/build.gradle.kts index fcd4d4b97e..70ab7a9c69 100644 --- a/readium/navigators/media/audio/build.gradle.kts +++ b/readium/navigators/media/audio/build.gradle.kts @@ -5,51 +5,17 @@ */ plugins { - id("com.android.library") - kotlin("android") - kotlin("plugin.parcelize") + id("readium.library-conventions") } android { - resourcePrefix = "readium_" - - compileSdk = 34 + namespace = "org.readium.navigators.media.audio" - defaultConfig { - minSdk = 21 - targetSdk = 34 - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - kotlinOptions { - jvmTarget = JavaVersion.VERSION_17.toString() - freeCompilerArgs = freeCompilerArgs + listOf( - "-opt-in=kotlin.RequiresOptIn", - "-opt-in=org.readium.r2.shared.InternalReadiumApi" - ) - } - buildTypes { - getByName("release") { - isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android.txt")) - } - } buildFeatures { viewBinding = true } - namespace = "org.readium.navigators.media.audio" } -kotlin { - explicitApi() -} - -rootProject.ext["publish.artifactId"] = "readium-navigator-media-audio" -apply(from = "$rootDir/scripts/publish-module.gradle") - dependencies { api(project(":readium:navigators:media:readium-navigator-media-common")) diff --git a/readium/navigators/media/audio/gradle.properties b/readium/navigators/media/audio/gradle.properties new file mode 100644 index 0000000000..92e1397687 --- /dev/null +++ b/readium/navigators/media/audio/gradle.properties @@ -0,0 +1 @@ +pom.artifactId=readium-navigator-media-audio diff --git a/readium/navigators/media/build.gradle.kts b/readium/navigators/media/build.gradle.kts index 290194c510..f33e8a5669 100644 --- a/readium/navigators/media/build.gradle.kts +++ b/readium/navigators/media/build.gradle.kts @@ -5,48 +5,13 @@ */ plugins { - id("com.android.library") - kotlin("android") - kotlin("plugin.parcelize") + id("readium.library-conventions") } android { - resourcePrefix = "readium_" - - compileSdk = 34 - - defaultConfig { - minSdk = 21 - targetSdk = 34 - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - kotlinOptions { - jvmTarget = JavaVersion.VERSION_17.toString() - freeCompilerArgs = freeCompilerArgs + listOf( - "-opt-in=kotlin.RequiresOptIn", - "-opt-in=org.readium.r2.shared.InternalReadiumApi" - ) - } - buildTypes { - getByName("release") { - isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android.txt")) - } - } namespace = "org.readium.navigator.media" } -kotlin { - explicitApi() -} - -rootProject.ext["publish.artifactId"] = "readium-navigator-media" -apply(from = "$rootDir/scripts/publish-module.gradle") - dependencies { api(project(":readium:navigators:media:readium-navigator-media-common")) api(project(":readium:navigators:media:readium-navigator-media-audio")) diff --git a/readium/navigators/media/common/build.gradle.kts b/readium/navigators/media/common/build.gradle.kts index de55505f49..54259812a7 100644 --- a/readium/navigators/media/common/build.gradle.kts +++ b/readium/navigators/media/common/build.gradle.kts @@ -5,51 +5,13 @@ */ plugins { - id("com.android.library") - kotlin("android") - kotlin("plugin.parcelize") + id("readium.library-conventions") } android { - resourcePrefix = "readium_" - - compileSdk = 34 - - defaultConfig { - minSdk = 21 - targetSdk = 34 - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - kotlinOptions { - jvmTarget = JavaVersion.VERSION_17.toString() - freeCompilerArgs = freeCompilerArgs + listOf( - "-opt-in=kotlin.RequiresOptIn", - "-opt-in=org.readium.r2.shared.InternalReadiumApi" - ) - } - buildTypes { - getByName("release") { - isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android.txt")) - } - } - buildFeatures { - viewBinding = true - } namespace = "org.readium.navigators.media.common" } -kotlin { - explicitApi() -} - -rootProject.ext["publish.artifactId"] = "readium-navigator-media-common" -apply(from = "$rootDir/scripts/publish-module.gradle") - dependencies { api(project(":readium:readium-shared")) api(project(":readium:readium-navigator")) diff --git a/readium/navigators/media/common/gradle.properties b/readium/navigators/media/common/gradle.properties new file mode 100644 index 0000000000..516c3ca246 --- /dev/null +++ b/readium/navigators/media/common/gradle.properties @@ -0,0 +1 @@ +pom.artifactId=readium-navigator-media-common diff --git a/readium/navigators/media/gradle.properties b/readium/navigators/media/gradle.properties new file mode 100644 index 0000000000..fe1195ef28 --- /dev/null +++ b/readium/navigators/media/gradle.properties @@ -0,0 +1 @@ +pom.artifactId=readium-navigator-media diff --git a/readium/navigators/media/tts/build.gradle.kts b/readium/navigators/media/tts/build.gradle.kts index 9e234ea5fc..dbec6e0724 100644 --- a/readium/navigators/media/tts/build.gradle.kts +++ b/readium/navigators/media/tts/build.gradle.kts @@ -5,52 +5,14 @@ */ plugins { - id("com.android.library") - kotlin("android") - kotlin("plugin.parcelize") - kotlin("plugin.serialization") + id("readium.library-conventions") + alias(libs.plugins.kotlin.serialization) } android { - resourcePrefix = "readium_" - - compileSdk = 34 - - defaultConfig { - minSdk = 21 - targetSdk = 34 - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - kotlinOptions { - jvmTarget = JavaVersion.VERSION_17.toString() - freeCompilerArgs = freeCompilerArgs + listOf( - "-opt-in=kotlin.RequiresOptIn", - "-opt-in=org.readium.r2.shared.InternalReadiumApi" - ) - } - buildTypes { - getByName("release") { - isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android.txt")) - } - } - buildFeatures { - viewBinding = true - } namespace = "org.readium.navigators.media.tts" } -kotlin { - explicitApi() -} - -rootProject.ext["publish.artifactId"] = "readium-navigator-media-tts" -apply(from = "$rootDir/scripts/publish-module.gradle") - dependencies { api(project(":readium:navigators:media:readium-navigator-media-common")) diff --git a/readium/navigators/media/tts/gradle.properties b/readium/navigators/media/tts/gradle.properties new file mode 100644 index 0000000000..6672fc5651 --- /dev/null +++ b/readium/navigators/media/tts/gradle.properties @@ -0,0 +1 @@ +pom.artifactId=readium-navigator-media-tts diff --git a/readium/opds/build.gradle.kts b/readium/opds/build.gradle.kts index cdaf0d7949..a890b23341 100644 --- a/readium/opds/build.gradle.kts +++ b/readium/opds/build.gradle.kts @@ -5,50 +5,13 @@ */ plugins { - id("com.android.library") - kotlin("android") - kotlin("plugin.parcelize") + id("readium.library-conventions") } android { - resourcePrefix = "readium_" - - compileSdk = 34 - defaultConfig { - minSdk = 21 - targetSdk = 34 - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - kotlinOptions { - jvmTarget = JavaVersion.VERSION_17.toString() - freeCompilerArgs = freeCompilerArgs + listOf( - "-opt-in=kotlin.RequiresOptIn", - "-opt-in=org.readium.r2.shared.InternalReadiumApi" - ) - } - testOptions { - unitTests.isIncludeAndroidResources = true - } - buildTypes { - getByName("release") { - isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android.txt")) - } - } namespace = "org.readium.r2.opds" } -kotlin { - explicitApi() -} - -rootProject.ext["publish.artifactId"] = "readium-opds" -apply(from = "$rootDir/scripts/publish-module.gradle") - dependencies { api(project(":readium:readium-shared")) diff --git a/readium/opds/gradle.properties b/readium/opds/gradle.properties new file mode 100644 index 0000000000..4ad1a85ca1 --- /dev/null +++ b/readium/opds/gradle.properties @@ -0,0 +1 @@ +pom.artifactId=readium-opds diff --git a/readium/shared/build.gradle.kts b/readium/shared/build.gradle.kts index 8282274403..13533ca1d0 100644 --- a/readium/shared/build.gradle.kts +++ b/readium/shared/build.gradle.kts @@ -5,54 +5,14 @@ */ plugins { - id("com.android.library") - kotlin("android") - kotlin("plugin.parcelize") - kotlin("plugin.serialization") + id("readium.library-conventions") + alias(libs.plugins.kotlin.serialization) } android { - resourcePrefix = "readium_" - - compileSdk = 34 - defaultConfig { - minSdk = 21 - targetSdk = 34 - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - kotlinOptions { - allWarningsAsErrors = true - freeCompilerArgs = freeCompilerArgs + listOf( - "-opt-in=kotlin.RequiresOptIn", - "-opt-in=org.readium.r2.shared.InternalReadiumApi" - ) - } - testOptions { - unitTests.isIncludeAndroidResources = true - } - buildTypes { - getByName("release") { - isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android.txt")) - } - } - buildFeatures { - buildConfig = true - } namespace = "org.readium.r2.shared" } -kotlin { - explicitApi() -} - -rootProject.ext["publish.artifactId"] = "readium-shared" -apply(from = "$rootDir/scripts/publish-module.gradle") - dependencies { implementation(libs.androidx.appcompat) implementation(libs.androidx.browser) diff --git a/readium/shared/gradle.properties b/readium/shared/gradle.properties new file mode 100644 index 0000000000..0337d05120 --- /dev/null +++ b/readium/shared/gradle.properties @@ -0,0 +1 @@ +pom.artifactId=readium-shared diff --git a/readium/streamer/build.gradle.kts b/readium/streamer/build.gradle.kts index bec32e78df..f846c14e48 100644 --- a/readium/streamer/build.gradle.kts +++ b/readium/streamer/build.gradle.kts @@ -5,50 +5,13 @@ */ plugins { - id("com.android.library") - kotlin("android") - kotlin("plugin.parcelize") + id("readium.library-conventions") } android { - resourcePrefix = "readium_" - - compileSdk = 34 - defaultConfig { - minSdk = 21 - targetSdk = 34 - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - testOptions { - unitTests.isIncludeAndroidResources = true - } - kotlinOptions { - allWarningsAsErrors = true - freeCompilerArgs = freeCompilerArgs + listOf( - "-opt-in=kotlin.RequiresOptIn", - "-opt-in=org.readium.r2.shared.InternalReadiumApi" - ) - } - buildTypes { - getByName("release") { - isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android.txt")) - } - } namespace = "org.readium.r2.streamer" } -kotlin { - explicitApi() -} - -rootProject.ext["publish.artifactId"] = "readium-streamer" -apply(from = "$rootDir/scripts/publish-module.gradle") - dependencies { api(project(":readium:readium-shared")) diff --git a/readium/streamer/gradle.properties b/readium/streamer/gradle.properties new file mode 100644 index 0000000000..de54cac099 --- /dev/null +++ b/readium/streamer/gradle.properties @@ -0,0 +1 @@ +pom.artifactId=readium-streamer diff --git a/scripts/publish-module.gradle b/scripts/publish-module.gradle deleted file mode 100644 index 7c044790fc..0000000000 --- a/scripts/publish-module.gradle +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2022 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. - */ - -apply plugin: 'maven-publish' -apply plugin: 'signing' -apply plugin: 'org.jetbrains.dokka' - -task androidSourcesJar(type: Jar) { - archiveClassifier.set('sources') - if (project.plugins.findPlugin("com.android.library")) { - // // For Android libraries - from android.sourceSets.main.java.srcDirs - from android.sourceSets.main.kotlin.srcDirs - } else { - // For pure Kotlin libraries - from sourceSets.main.java.srcDirs - from sourceSets.main.kotlin.srcDirs - } -} - -task javadocJar(type: Jar, dependsOn: dokkaJavadoc) { - archiveClassifier.set('javadoc') - from dokkaJavadoc.outputDirectory -} - -artifacts { - archives androidSourcesJar - archives javadocJar -} - -group = rootProject.ext["publish.groupId"] -version = rootProject.ext["publish.version"] - -afterEvaluate { - publishing { - publications { - release(MavenPublication) { - groupId rootProject.ext["publish.groupId"] - artifactId rootProject.ext["publish.artifactId"] - version rootProject.ext["publish.version"] - - if (project.plugins.findPlugin("com.android.library")) { - from components.release - } else { - from components.java - } - - artifact androidSourcesJar - artifact javadocJar - - pom { - name = rootProject.ext["publish.artifactId"] - description = 'A toolkit for ebooks, audiobooks and comics written in Kotlin' - url = 'https://github.com/readium/kotlin-toolkit' - licenses { - license { - name = 'BSD-3-Clause license' - url = 'https://github.com/readium/kotlin-toolkit/blob/main/LICENSE' - } - } - developers { - developer { - id = 'aferditamuriqi' - name = 'Aferdita Muriqi' - email = 'aferdita.muriqi@gmail.com' - } - developer { - id = 'mickael-menu' - name = 'Mickaël Menu' - email = 'mickael.menu@gmail.com' - } - developer { - id = 'qnga' - name = 'Quentin Gliosca' - email = 'quentin.gliosca@gmail.com' - } - } - scm { - connection = 'scm:git:github.com/readium/kotlin-toolkit.git' - developerConnection = 'scm:git:ssh://github.com/readium/kotlin-toolkit.git' - url = 'https://github.com/readium/kotlin-toolkit' - } - } - } - } - } -} - -signing { - useInMemoryPgpKeys( - rootProject.ext["signing.keyId"], - rootProject.ext["signing.key"], - rootProject.ext["signing.password"], - ) - sign publishing.publications -} diff --git a/scripts/publish-root.gradle b/scripts/publish-root.gradle deleted file mode 100644 index 37b028bd15..0000000000 --- a/scripts/publish-root.gradle +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2022 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. - */ - -// Inspired by https://getstream.io/blog/publishing-libraries-to-mavencentral-2021/ - -// Create variables with empty default values -ext["ossrhUsername"] = '' -ext["ossrhPassword"] = '' -ext["sonatypeStagingProfileId"] = '' -ext["signing.keyId"] = '' -ext["signing.password"] = '' -ext["signing.key"] = '' - -File secretPropsFile = project.rootProject.file('local.properties') -if (secretPropsFile.exists()) { - // Read local.properties file first if it exists - Properties p = new Properties() - new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) } - p.each { name, value -> ext[name] = value } -} else { - // Use system environment variables - ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME') - ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD') - ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID') - ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID') - ext["signing.password"] = System.getenv('SIGNING_PASSWORD') - ext["signing.key"] = System.getenv('SIGNING_KEY') -} - -// Set up Sonatype repository -nexusPublishing { - repositories { - sonatype { - stagingProfileId = sonatypeStagingProfileId - username = ossrhUsername - password = ossrhPassword - - nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) - snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) - } - } -} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 7fa3925861..e7220de428 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -4,32 +4,6 @@ * available in the top-level LICENSE file of the project. */ -pluginManagement { - repositories { - gradlePluginPortal() - google() - mavenLocal() - mavenCentral() - maven(url = "https://jcenter.bintray.com") - maven(url = "https://s3.amazonaws.com/repo.commonsware.com") - } - - // Setting the plugin versions here doesn't work with AGP Upgrade Assistant, but we need - // it to integrate Readium in submodules. - // See https://github.com/readium/kotlin-toolkit/pull/97 - plugins { - id("com.android.application") version ("8.2.1") - id("com.android.library") version ("8.2.1") - id("io.github.gradle-nexus.publish-plugin") version ("1.3.0") - id("org.jetbrains.dokka") version ("1.9.10") - id("org.jetbrains.kotlin.android") version ("1.9.22") - id("org.jetbrains.kotlin.plugin.serialization") version ("1.9.22") - id("org.jlleitschuh.gradle.ktlint") version ("11.5.1") - // Make sure to align with the Kotlin version. - // See https://github.com/google/ksp/releases - id("com.google.devtools.ksp") version ("1.9.22-1.0.16") - } -} dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { @@ -100,6 +74,4 @@ include(":readium:streamer") project(":readium:streamer") .name = "readium-streamer" -if (System.getenv("JITPACK") == null) { - include("test-app") -} +include("test-app") diff --git a/test-app/build.gradle.kts b/test-app/build.gradle.kts index b2269b539e..f4fcbc9989 100644 --- a/test-app/build.gradle.kts +++ b/test-app/build.gradle.kts @@ -7,8 +7,8 @@ plugins { id("com.android.application") kotlin("android") - id("com.google.devtools.ksp") kotlin("plugin.parcelize") + alias(libs.plugins.ksp) } android { @@ -20,6 +20,7 @@ android { applicationId = "org.readium.r2reader" versionName = "3.0.0-alpha.1" + versionCode = 300000 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" ndk.abiFilters.add("armeabi-v7a") @@ -28,11 +29,11 @@ android { ndk.abiFilters.add("x86_64") } compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 } kotlinOptions { - jvmTarget = JavaVersion.VERSION_17.toString() + jvmTarget = JavaVersion.VERSION_1_8.toString() freeCompilerArgs = freeCompilerArgs + "-opt-in=kotlin.RequiresOptIn" } composeOptions { diff --git a/test-app/src/main/java/org/readium/r2/testapp/reader/VisualReaderFragment.kt b/test-app/src/main/java/org/readium/r2/testapp/reader/VisualReaderFragment.kt index 7b30482096..a7ae5e5d5c 100644 --- a/test-app/src/main/java/org/readium/r2/testapp/reader/VisualReaderFragment.kt +++ b/test-app/src/main/java/org/readium/r2/testapp/reader/VisualReaderFragment.kt @@ -211,8 +211,6 @@ abstract class VisualReaderFragment : BaseReaderFragment() { * Setup text-to-speech observers, if available. */ private suspend fun setupTts(scope: CoroutineScope) { - val activity = requireActivity() - model.tts?.apply { events .onEach { event ->