Skip to content

Commit 7564f19

Browse files
authored
Fix Maven Central publishing and refactor Gradle configurations (readium#452)
1 parent 361d2d4 commit 7564f19

File tree

63 files changed

+270
-948
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+270
-948
lines changed

.github/workflows/publish.yml

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# Inspired by https://getstream.io/blog/publishing-libraries-to-mavencentral-2021/
21
name: Publish
32

43
on:
@@ -13,30 +12,17 @@ jobs:
1312
steps:
1413
- name: Checkout
1514
uses: actions/checkout@v3
16-
with:
17-
ref: develop
1815
- name: Set up JDK 17
1916
uses: actions/setup-java@v3
2017
with:
2118
distribution: adopt
2219
java-version: 17
2320

24-
# Builds the release artifacts of the library
25-
- name: Release build
26-
run: ./gradlew assembleRelease
27-
28-
# Generates other artifacts (javadocJar is optional)
29-
- name: Source jar and dokka
30-
run: ./gradlew androidSourcesJar javadocJar
31-
32-
# Runs upload, and then closes & releases the repository
3321
- name: Publish to Maven Central
34-
run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository
22+
run: ./gradlew publishToMavenCentral --no-configuration-cache
3523
env:
36-
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
37-
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
38-
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
39-
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
40-
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
41-
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
42-
24+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
25+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }}
26+
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
27+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
28+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,9 @@ docs/index.md
8585
docs/package-list
8686
site/
8787
androidTestResultsUserPreferences.xml
88+
89+
# Custom Git patch enabling LCP in the Test App
90+
lcp.patch
91+
92+
# direnv file containing Maven Central secrets
93+
.envrc

build.gradle.kts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,15 @@
77
import org.jetbrains.dokka.gradle.DokkaTaskPartial
88

99
plugins {
10-
id("com.android.application") apply false
11-
id("com.android.library") apply false
12-
id("io.github.gradle-nexus.publish-plugin") apply true
13-
id("org.jetbrains.dokka") apply true
14-
id("org.jetbrains.kotlin.android") apply false
15-
id("com.google.devtools.ksp") apply false
16-
id("org.jlleitschuh.gradle.ktlint") apply true
17-
}
18-
19-
apply(from = "$rootDir/scripts/publish-root.gradle")
20-
21-
ext {
22-
set("publish.groupId", "org.readium.kotlin-toolkit")
23-
set("publish.version", "3.0.0-alpha.1")
10+
alias(libs.plugins.dokka)
11+
alias(libs.plugins.ktlint)
2412
}
2513

2614
subprojects {
2715
apply(plugin = "org.jlleitschuh.gradle.ktlint")
2816

2917
ktlint {
3018
android.set(true)
31-
disabledRules.add("no-wildcard-imports")
32-
disabledRules.add("max-line-length")
3319
}
3420
}
3521

buildSrc/build.gradle.kts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright 2024 Readium Foundation. All rights reserved.
3+
* Use of this source code is governed by the BSD-style license
4+
* available in the top-level LICENSE file of the project.
5+
*/
6+
7+
plugins {
8+
`kotlin-dsl`
9+
}
10+
11+
repositories {
12+
gradlePluginPortal()
13+
google()
14+
mavenCentral()
15+
}
16+
17+
dependencies {
18+
implementation(libs.plugin.android)
19+
implementation(libs.plugin.kotlin)
20+
implementation(libs.plugin.maven.publish)
21+
}

buildSrc/settings.gradle.kts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright 2024 Readium Foundation. All rights reserved.
3+
* Use of this source code is governed by the BSD-style license
4+
* available in the top-level LICENSE file of the project.
5+
*/
6+
7+
dependencyResolutionManagement {
8+
versionCatalogs {
9+
create("libs") {
10+
from(files("../gradle/libs.versions.toml"))
11+
}
12+
}
13+
}
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import com.vanniktech.maven.publish.SonatypeHost
2+
3+
plugins {
4+
// FIXME: For now, we cannot use the versions catalog in precompiled scripts: https://github.com/gradle/gradle/issues/15383
5+
id("com.android.library")
6+
id("com.vanniktech.maven.publish")
7+
id("org.jetbrains.kotlin.android")
8+
kotlin("plugin.parcelize")
9+
}
10+
11+
group = property("pom.groupId") as String
12+
13+
android {
14+
resourcePrefix = "readium_"
15+
16+
compileSdk = (property("android.compileSdk") as String).toInt()
17+
18+
defaultConfig {
19+
minSdk = (property("android.minSdk") as String).toInt()
20+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
21+
}
22+
23+
compileOptions {
24+
sourceCompatibility = JavaVersion.VERSION_1_8
25+
targetCompatibility = JavaVersion.VERSION_1_8
26+
}
27+
28+
kotlinOptions {
29+
jvmTarget = JavaVersion.VERSION_1_8.toString()
30+
allWarningsAsErrors = true
31+
freeCompilerArgs = freeCompilerArgs + listOf(
32+
"-opt-in=kotlin.RequiresOptIn",
33+
"-opt-in=org.readium.r2.shared.InternalReadiumApi"
34+
)
35+
}
36+
37+
testOptions {
38+
unitTests.isIncludeAndroidResources = true
39+
}
40+
41+
buildFeatures {
42+
// FIXME: Look into whether we can remove this.
43+
buildConfig = true
44+
}
45+
46+
buildTypes {
47+
getByName("release") {
48+
isMinifyEnabled = false
49+
proguardFiles(getDefaultProguardFile("proguard-android.txt"))
50+
}
51+
}
52+
}
53+
54+
kotlin {
55+
explicitApi()
56+
}
57+
58+
mavenPublishing {
59+
coordinates(
60+
groupId = group.toString(),
61+
artifactId = property("pom.artifactId") as String,
62+
version = property("pom.version") as String
63+
)
64+
65+
pom {
66+
name.set(property("pom.artifactId") as String)
67+
description.set("A toolkit for ebooks, audiobooks and comics written in Kotlin")
68+
url.set("https://github.com/readium/kotlin-toolkit")
69+
licenses {
70+
license {
71+
name.set("BSD-3-Clause license")
72+
url.set("https://github.com/readium/kotlin-toolkit/blob/main/LICENSE")
73+
}
74+
}
75+
developers {
76+
developer {
77+
id.set("aferditamuriqi")
78+
name.set("Aferdita Muriqi")
79+
email.set("aferdita.muriqi@gmail.com")
80+
}
81+
developer {
82+
id.set("mickael-menu")
83+
name.set("Mickaël Menu")
84+
email.set("mickael.menu@gmail.com")
85+
}
86+
developer {
87+
id.set("qnga")
88+
name.set("Quentin Gliosca")
89+
email.set("quentin.gliosca@gmail.com")
90+
}
91+
92+
developer {
93+
id.set("username")
94+
name.set("User Name")
95+
url.set("https://github.com/username/")
96+
}
97+
}
98+
scm {
99+
url.set("https://github.com/readium/kotlin-toolkit")
100+
connection.set("scm:git:github.com/readium/kotlin-toolkit.git")
101+
developerConnection.set("scm:git:ssh://github.com/readium/kotlin-toolkit.git")
102+
}
103+
}
104+
105+
publishToMavenCentral(SonatypeHost.S01)
106+
signAllPublications()
107+
}

gradle.properties

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44
# any settings specified in this file.
55
# For more details on how to configure your build environment visit
66
# http://www.gradle.org/docs/current/userguide/build_environment.html
7+
8+
pom.groupId=org.readium.kotlin-toolkit
9+
pom.version=3.0.0-alpha.1
10+
11+
android.minSdk=21
12+
android.compileSdk=34
13+
android.targetSdk=34
14+
715
# Specifies the JVM arguments used for the daemon process.
816
# The setting is particularly useful for tweaking memory settings.
917
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8

gradle/libs.versions.toml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
[versions]
22

3+
kotlin = "1.9.22"
4+
agp = "8.2.1"
5+
gradle-maven-publish-plugin = "0.27.0"
6+
37
accompanist = "0.32.0"
48

59
androidx-activity = "1.8.2"
@@ -45,11 +49,16 @@ joda-time = "2.12.6"
4549
jsoup = "1.17.2"
4650
junit = "4.13.2"
4751

48-
kotlin = "1.9.22"
4952
kotlinx-coroutines = "1.7.3"
5053
kotlinx-coroutines-test = "1.7.3"
5154
kotlinx-serialization-json = "1.6.2"
5255

56+
# Make sure to align with the Kotlin version.
57+
# See https://github.com/google/ksp/releases
58+
ksp = "1.9.22-1.0.16"
59+
60+
ktlint = "11.5.1"
61+
5362
pdfium = "1.8.2"
5463
pdf-viewer = "2.8.2"
5564
#noinspection GradleDependency
@@ -60,6 +69,7 @@ robolectric = "4.11.1"
6069

6170
timber = "5.0.1"
6271

72+
6373
[libraries]
6474
accompanist-themeadapter-material = { group = "com.google.accompanist", name = "accompanist-themeadapter-material", version.ref = "accompanist" }
6575

@@ -140,6 +150,15 @@ robolectric = { group = "org.robolectric", name = "robolectric", version.ref = "
140150

141151
timber = { group = "com.jakewharton.timber", name = "timber", version.ref = "timber" }
142152

153+
plugin-android = { module = "com.android.tools.build:gradle", version.ref = "agp" }
154+
plugin-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
155+
plugin-maven-publish = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "gradle-maven-publish-plugin" }
156+
157+
[plugins]
158+
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
159+
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
160+
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" }
161+
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
143162

144163
[bundles]
145164
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-
151170
navigation = ["androidx-navigation-fragment", "androidx-navigation-ui"]
152171
room = ["androidx-room-runtime", "androidx-room-ktx"]
153172
test-frameworks = ["junit", "androidx-ext-junit", "androidx-expresso-core", "robolectric", "kotlin-junit", "assertj", "kotlinx-coroutines-test"]
154-
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

readium/adapters/exoplayer/audio/build.gradle.kts

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,52 +5,14 @@
55
*/
66

77
plugins {
8-
id("com.android.library")
9-
kotlin("android")
10-
kotlin("plugin.parcelize")
11-
kotlin("plugin.serialization")
8+
id("readium.library-conventions")
9+
alias(libs.plugins.kotlin.serialization)
1210
}
1311

1412
android {
15-
resourcePrefix = "readium_"
16-
17-
compileSdk = 34
18-
19-
defaultConfig {
20-
minSdk = 21
21-
targetSdk = 34
22-
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
23-
}
24-
compileOptions {
25-
sourceCompatibility = JavaVersion.VERSION_17
26-
targetCompatibility = JavaVersion.VERSION_17
27-
}
28-
kotlinOptions {
29-
jvmTarget = JavaVersion.VERSION_17.toString()
30-
freeCompilerArgs = freeCompilerArgs + listOf(
31-
"-opt-in=kotlin.RequiresOptIn",
32-
"-opt-in=org.readium.r2.shared.InternalReadiumApi"
33-
)
34-
}
35-
buildTypes {
36-
getByName("release") {
37-
isMinifyEnabled = false
38-
proguardFiles(getDefaultProguardFile("proguard-android.txt"))
39-
}
40-
}
41-
buildFeatures {
42-
viewBinding = true
43-
}
4413
namespace = "org.readium.adapter.exoplayer.audio"
4514
}
4615

47-
kotlin {
48-
explicitApi()
49-
}
50-
51-
rootProject.ext["publish.artifactId"] = "readium-navigator-exoplayer-audio"
52-
apply(from = "$rootDir/scripts/publish-module.gradle")
53-
5416
dependencies {
5517
api(project(":readium:readium-shared"))
5618
api(project(":readium:navigators:media:readium-navigator-media-audio"))

0 commit comments

Comments
 (0)