Skip to content

Commit 8f9cd70

Browse files
committed
Fix Maven Central publishing and refactor Gradle configurations
1 parent ee9e097 commit 8f9cd70

39 files changed

+233
-636
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: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,11 @@ lint/reports/
8282
docs/readium
8383
docs/index.md
8484
docs/package-list
85-
site/
85+
site/
86+
androidTestResultsUserPreferences.xml
87+
88+
# Custom Git patch enabling LCP in the Test App
89+
lcp.patch
90+
91+
# direnv file containing Maven Central secrets
92+
.envrc

.idea/kotlinc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ A [Test App](test-app) demonstrates how to integrate the Readium Kotlin toolkit
2121

2222
| Readium | Android min SDK | Android compile SDK | Kotlin compiler | Gradle |
2323
|---------|-----------------|---------------------|-----------------|--------|
24-
| latest | 21 | 33 | 1.9.0 | 8.6.0 |
24+
| latest | 21 | 33 | 1.9.24 | 8.6.0 |
2525
| 2.3.0 | 21 | 33 | 1.7.10 | 6.9.3 |
2626

2727
## Setting Up Readium

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", "2.4.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: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
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+
freeCompilerArgs = freeCompilerArgs + listOf(
31+
"-opt-in=kotlin.RequiresOptIn",
32+
"-opt-in=org.readium.r2.shared.InternalReadiumApi"
33+
)
34+
}
35+
36+
testOptions {
37+
unitTests.isIncludeAndroidResources = true
38+
}
39+
40+
buildFeatures {
41+
// FIXME: Look into whether we can remove this.
42+
buildConfig = true
43+
}
44+
45+
buildTypes {
46+
getByName("release") {
47+
isMinifyEnabled = false
48+
proguardFiles(getDefaultProguardFile("proguard-android.txt"))
49+
}
50+
}
51+
}
52+
53+
mavenPublishing {
54+
coordinates(
55+
groupId = group.toString(),
56+
artifactId = property("pom.artifactId") as String,
57+
version = property("pom.version") as String
58+
)
59+
60+
pom {
61+
name.set(property("pom.artifactId") as String)
62+
description.set("A toolkit for ebooks, audiobooks and comics written in Kotlin")
63+
url.set("https://github.com/readium/kotlin-toolkit")
64+
licenses {
65+
license {
66+
name.set("BSD-3-Clause license")
67+
url.set("https://github.com/readium/kotlin-toolkit/blob/main/LICENSE")
68+
}
69+
}
70+
developers {
71+
developer {
72+
id.set("aferditamuriqi")
73+
name.set("Aferdita Muriqi")
74+
email.set("[email protected]")
75+
}
76+
developer {
77+
id.set("mickael-menu")
78+
name.set("Mickaël Menu")
79+
email.set("[email protected]")
80+
}
81+
developer {
82+
id.set("qnga")
83+
name.set("Quentin Gliosca")
84+
email.set("[email protected]")
85+
}
86+
87+
developer {
88+
id.set("username")
89+
name.set("User Name")
90+
url.set("https://github.com/username/")
91+
}
92+
}
93+
scm {
94+
url.set("https://github.com/readium/kotlin-toolkit")
95+
connection.set("scm:git:github.com/readium/kotlin-toolkit.git")
96+
developerConnection.set("scm:git:ssh://github.com/readium/kotlin-toolkit.git")
97+
}
98+
}
99+
100+
publishToMavenCentral(SonatypeHost.S01)
101+
signAllPublications()
102+
}

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=2.4.2
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: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
[versions]
22

3-
androidx-activity = "1.7.2"
3+
kotlin = "1.9.24"
4+
agp = "8.2.2"
5+
gradle-maven-publish-plugin = "0.27.0"
6+
7+
accompanist = "0.32.0"
8+
9+
androidx-activity = "1.8.2"
410
androidx-appcompat = "1.6.1"
511
androidx-browser = "1.5.0"
612
androidx-cardview = "1.0.0"
7-
androidx-compose-compiler = "1.5.0"
13+
androidx-compose-compiler = "1.5.14"
814
androidx-compose-animation = "1.4.3"
915
androidx-compose-foundation = "1.4.3"
1016
androidx-compose-material = "1.4.3"
@@ -42,10 +48,15 @@ joda-time = "2.12.5"
4248
jsoup = "1.16.1"
4349
junit = "4.13.2"
4450

45-
kotlin = "1.9.0"
46-
kotlinx-coroutines = "1.7.2"
47-
kotlinx-coroutines-test = "1.7.2"
48-
kotlinx-serialization-json = "1.5.1"
51+
kotlinx-coroutines = "1.7.3"
52+
kotlinx-coroutines-test = "1.7.3"
53+
kotlinx-serialization-json = "1.6.2"
54+
55+
# Make sure to align with the Kotlin version.
56+
# See https://github.com/google/ksp/releases
57+
ksp = "1.9.24-1.0.20"
58+
59+
ktlint = "11.5.1"
4960

5061
pdfium = "1.8.2"
5162
pdf-viewer = "2.8.2"
@@ -56,6 +67,7 @@ robolectric = "4.10.3"
5667

5768
timber = "5.0.1"
5869

70+
5971
[libraries]
6072
androidx-activity-ktx = { group = "androidx.activity", name = "activity-ktx", version.ref = "androidx-activity" }
6173
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidx-appcompat" }
@@ -134,6 +146,15 @@ robolectric = { group = "org.robolectric", name = "robolectric", version.ref = "
134146

135147
timber = { group = "com.jakewharton.timber", name = "timber", version.ref = "timber" }
136148

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

138159
[bundles]
139160
compose = ["androidx-compose-activity", "androidx-compose-animation", "androidx-compose-foundation", "androidx-compose-material", "androidx-compose-material3", "androidx-compose-material-icons", "androidx-compose-theme-adapter", "androidx-compose-ui", "androidx-compose-ui-tooling"]
@@ -145,4 +166,3 @@ media3 = ["androidx-media3-session", "androidx-media3-common", "androidx-media3-
145166
navigation = ["androidx-navigation-fragment", "androidx-navigation-ui"]
146167
room = ["androidx-room-runtime", "androidx-room-ktx"]
147168
test-frameworks = ["junit", "androidx-ext-junit", "androidx-expresso-core", "robolectric", "kotlin-junit", "assertj", "kotlinx-coroutines-test"]
148-

0 commit comments

Comments
 (0)