Skip to content

Commit

Permalink
Fix Maven Central publishing and refactor Gradle configurations (read…
Browse files Browse the repository at this point in the history
  • Loading branch information
mickael-menu authored Jan 23, 2024
1 parent 361d2d4 commit 7564f19
Show file tree
Hide file tree
Showing 63 changed files with 270 additions and 948 deletions.
26 changes: 6 additions & 20 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Inspired by https://getstream.io/blog/publishing-libraries-to-mavencentral-2021/
name: Publish

on:
Expand All @@ -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 }}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 2 additions & 16 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,15 @@
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 {
apply(plugin = "org.jlleitschuh.gradle.ktlint")

ktlint {
android.set(true)
disabledRules.add("no-wildcard-imports")
disabledRules.add("max-line-length")
}
}

Expand Down
21 changes: 21 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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)
}
13 changes: 13 additions & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -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"))
}
}
}
107 changes: 107 additions & 0 deletions buildSrc/src/main/kotlin/readium.library-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -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()
}
8 changes: 8 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 20 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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" }

Expand Down Expand Up @@ -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"]
Expand All @@ -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"]

2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
42 changes: 2 additions & 40 deletions readium/adapters/exoplayer/audio/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
1 change: 1 addition & 0 deletions readium/adapters/exoplayer/audio/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pom.artifactId=readium-adapter-exoplayer-audio
Loading

0 comments on commit 7564f19

Please sign in to comment.