Skip to content

Commit 7e85a31

Browse files
authored
Add publishing configuration to plugins (#5)
* Remove hardcoded develop ref from release workflow on snapshot publishing * Add publishing configuration to plugins
1 parent 54d4646 commit 7e85a31

File tree

10 files changed

+346
-30
lines changed

10 files changed

+346
-30
lines changed

.github/workflows/release.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ jobs:
4747
uses: actions/checkout@v4
4848
with:
4949
token: ${{ secrets.github-token }}
50-
ref: develop
5150

5251
- name: Bump version
5352
id: bump

README.md

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,18 @@ configurations to ensure consistency across Stream's Android libraries and appli
66
> **Note:** These plugins are designed specifically for Stream's projects and workflows. They aren't
77
> intended for general-purpose use and may include Stream-specific configurations and conventions.
88
9-
## Overview
10-
11-
This repository contains reusable Gradle convention plugins that encapsulate common build logic,
12-
dependencies, and configurations used across Stream's Android projects.
13-
149
## Available Plugins
1510

1611
- **`io.getstream.project`** - Root project configuration (apply to root `build.gradle.kts`)
17-
- **`io.getstream.android.library`** - For Android library modules
18-
- **`io.getstream.android.application`** - For Android application modules
19-
- **`io.getstream.android.test`** - For Android test modules
20-
- **`io.getstream.java.library`** - For Java/Kotlin JVM library modules
12+
- **`io.getstream.android.library`** - Android library modules
13+
- **`io.getstream.android.application`** - Android application modules
14+
- **`io.getstream.android.test`** - Android test modules
15+
- **`io.getstream.java.library`** - Java/Kotlin JVM library modules
16+
- **`io.getstream.java.platform`** - Java/Kotlin JVM platform modules
2117

2218
## Usage
2319

24-
### 1. Root Project Configuration
20+
### Root Project Setup
2521

2622
Apply the root plugin in your root `build.gradle.kts`:
2723

@@ -55,22 +51,61 @@ streamProject {
5551
// Additional Sonar coverage exclusion patterns for file paths (default: empty)
5652
sonarCoverageExclusions = listOf("**/io/getstream/some/package/**")
5753
}
54+
55+
publishing {
56+
// Required: Description for all published artifacts
57+
description = "Magical Stream SDK"
58+
59+
// Optional: Override artifact IDs for specific modules
60+
moduleArtifactIdOverrides = mapOf(
61+
"my-module" to "custom-artifact-id"
62+
)
63+
}
5864
}
5965
```
6066

61-
### 2. Module Configuration
67+
### Module Setup
6268

6369
Apply the appropriate plugin to each module:
6470

6571
```kotlin
6672
plugins {
6773
id("io.getstream.android.library")
68-
// or id("io.getstream.android.application")
69-
// or id("io.getstream.android.test")
70-
// or id("io.getstream.java.library")
74+
// or: id("io.getstream.android.application")
75+
// or: id("io.getstream.android.test")
76+
// or: id("io.getstream.java.library")
77+
// or: id("io.getstream.java.platform")
7178
}
7279
```
7380

81+
Library and platform plugins automatically configure Maven publishing.
82+
83+
## Versioning
84+
85+
Version is read from the project version. Can be set, for example, by adding it to
86+
`gradle.properties`:
87+
88+
```properties
89+
version=1.0.0
90+
```
91+
92+
All published modules use this version. For snapshot builds, set the `SNAPSHOT` environment
93+
variable:
94+
95+
```bash
96+
SNAPSHOT=true ./gradlew publish
97+
```
98+
99+
This produces timestamped snapshot versions: `1.0.0-yyyyMMddHHmm-SNAPSHOT`
100+
101+
## Publishing
102+
103+
Published artifacts use:
104+
105+
- **Group ID**: `io.getstream`
106+
- **Artifact ID**: Module name (or override via `moduleArtifactIdOverrides`)
107+
- **Version**: From `gradle.properties`
108+
74109
## License
75110

76111
See [LICENSE](LICENSE) file for details.

gradle/libs.versions.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,23 @@ agp = "8.11.1"
33
kotlin = "2.0.21"
44
detekt = "1.23.8"
55
spotless = "8.0.0"
6-
kotlinDokka = "2.0.0"
6+
kotlinDokka = "1.9.20"
77
mavenPublish = "0.34.0"
88
sonarqube = "6.0.1.5171"
99
kover = "0.9.3"
1010

1111
[libraries]
1212
android-gradle-plugin = { group = "com.android.tools.build", name = "gradle", version.ref = "agp" }
13+
dokka-gradle-plugin = { group = "org.jetbrains.dokka", name = "dokka-gradle-plugin", version.ref = "kotlinDokka" }
1314
kotlin-gradle-plugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }
15+
kover-gradle-plugin = { group = "org.jetbrains.kotlinx", name = "kover-gradle-plugin", version.ref = "kover" }
16+
maven-publish-gradle-plugin = { group = "com.vanniktech", name = "gradle-maven-publish-plugin", version.ref = "mavenPublish" }
1417
spotless-gradle-plugin = { group = "com.diffplug.spotless", name = "spotless-plugin-gradle", version.ref = "spotless" }
1518
sonarqube-gradle-plugin = { group = "org.sonarsource.scanner.gradle", name = "sonarqube-gradle-plugin", version.ref = "sonarqube" }
16-
kover-gradle-plugin = { group = "org.jetbrains.kotlinx", name = "kover-gradle-plugin", version.ref = "kover" }
1719

1820
[plugins]
1921
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
20-
dokka = { id = "org.jetbrains.dokka-javadoc", version.ref = "kotlinDokka" }
22+
dokka = { id = "org.jetbrains.dokka", version.ref = "kotlinDokka" }
2123
maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "mavenPublish" }
2224
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
2325
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }

plugin/build.gradle.kts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ dependencies {
2323
compileOnly(gradleKotlinDsl())
2424
compileOnly(libs.android.gradle.plugin)
2525
compileOnly(libs.kotlin.gradle.plugin)
26-
implementation(libs.spotless.gradle.plugin)
27-
implementation(libs.sonarqube.gradle.plugin)
26+
implementation(libs.dokka.gradle.plugin)
2827
implementation(libs.kover.gradle.plugin)
28+
implementation(libs.maven.publish.gradle.plugin)
29+
implementation(libs.sonarqube.gradle.plugin)
30+
implementation(libs.spotless.gradle.plugin)
2931
}
3032

3133
val repoId = "GetStream/stream-build-conventions-android"
@@ -72,12 +74,19 @@ gradlePlugin {
7274
description = "Convention plugin for Stream Java/Kotlin JVM library modules"
7375
tags = listOf("java", "library", "convention", "stream", "kotlin")
7476
}
77+
create("javaPlatform") {
78+
id = "io.getstream.java.platform"
79+
implementationClass = "io.getstream.android.JavaPlatformConventionPlugin"
80+
displayName = "Stream Java Platform Convention Plugin"
81+
description = "Convention plugin for Stream Java/Kotlin JVM platform modules"
82+
tags = listOf("java", "platform", "convention", "stream", "kotlin")
83+
}
7584
}
7685
}
7786

7887
mavenPublishing {
7988
publishToMavenCentral(automaticRelease = true)
80-
configure(GradlePlugin(javadocJar = JavadocJar.Javadoc(), sourcesJar = true))
89+
configure(GradlePlugin(javadocJar = JavadocJar.Dokka("dokkaJavadoc"), sourcesJar = true))
8190

8291
pom {
8392
name.set("Stream Build Conventions")
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright (c) 2014-2025 Stream.io Inc. All rights reserved.
3+
*
4+
* Licensed under the Stream License;
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://github.com/GetStream/stream-build-conventions-android/blob/main/LICENSE
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.getstream.android
17+
18+
import org.gradle.api.Task
19+
import org.gradle.api.tasks.TaskContainer
20+
import org.gradle.kotlin.dsl.named
21+
import org.gradle.kotlin.dsl.register
22+
23+
internal inline fun <reified T : Task> TaskContainer.findOrRegister(
24+
name: String,
25+
noinline configuration: T.() -> Unit,
26+
) = findByName(name)?.let { named<T>(name) } ?: register<T>(name, configuration)

plugin/src/main/kotlin/io/getstream/android/StreamConventionExtensions.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package io.getstream.android
1717

1818
import io.getstream.android.coverage.CoverageOptions
19+
import io.getstream.android.publishing.PublishingOptions
1920
import io.getstream.android.spotless.SpotlessOptions
2021
import javax.inject.Inject
2122
import org.gradle.api.Action
@@ -50,6 +51,12 @@ constructor(project: Project, objects: ObjectFactory) {
5051

5152
/** Configure code coverage */
5253
fun coverage(action: Action<CoverageOptions>) = action.execute(coverage)
54+
55+
/** Publishing configuration */
56+
val publishing: PublishingOptions = objects.newInstance<PublishingOptions>()
57+
58+
/** Configure publishing */
59+
fun publishing(action: Action<PublishingOptions>) = action.execute(publishing)
5360
}
5461

5562
internal fun Project.createProjectExtension(): StreamProjectExtension =

plugin/src/main/kotlin/io/getstream/android/StreamConventionPlugins.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import com.android.build.api.dsl.LibraryExtension
2020
import com.android.build.api.dsl.TestExtension
2121
import io.getstream.android.coverage.configureCoverageModule
2222
import io.getstream.android.coverage.configureCoverageRoot
23+
import io.getstream.android.publishing.configurePublishing
2324
import io.getstream.android.spotless.configureSpotless
2425
import org.gradle.api.Plugin
2526
import org.gradle.api.Project
@@ -63,6 +64,7 @@ class AndroidLibraryConventionPlugin : Plugin<Project> {
6364
configureKotlin()
6465
configureSpotless()
6566
configureCoverageModule()
67+
configurePublishing()
6668
}
6769
}
6870
}
@@ -88,6 +90,20 @@ class JavaLibraryConventionPlugin : Plugin<Project> {
8890
configureKotlin()
8991
configureSpotless()
9092
configureCoverageModule()
93+
configurePublishing()
94+
}
95+
}
96+
}
97+
98+
class JavaPlatformConventionPlugin : Plugin<Project> {
99+
override fun apply(target: Project) {
100+
with(target) {
101+
pluginManager.apply("java-platform")
102+
103+
configureJava()
104+
configureKotlin()
105+
configureSpotless()
106+
configurePublishing()
91107
}
92108
}
93109
}

0 commit comments

Comments
 (0)