Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ jobs:
uses: actions/checkout@v4
with:
token: ${{ secrets.github-token }}
ref: develop
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't necessarily want to checkout from develop when publishing a snapshot.


- name: Bump version
id: bump
Expand Down
63 changes: 49 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,18 @@ configurations to ensure consistency across Stream's Android libraries and appli
> **Note:** These plugins are designed specifically for Stream's projects and workflows. They aren't
> intended for general-purpose use and may include Stream-specific configurations and conventions.

## Overview

This repository contains reusable Gradle convention plugins that encapsulate common build logic,
dependencies, and configurations used across Stream's Android projects.

## Available Plugins

- **`io.getstream.project`** - Root project configuration (apply to root `build.gradle.kts`)
- **`io.getstream.android.library`** - For Android library modules
- **`io.getstream.android.application`** - For Android application modules
- **`io.getstream.android.test`** - For Android test modules
- **`io.getstream.java.library`** - For Java/Kotlin JVM library modules
- **`io.getstream.android.library`** - Android library modules
- **`io.getstream.android.application`** - Android application modules
- **`io.getstream.android.test`** - Android test modules
- **`io.getstream.java.library`** - Java/Kotlin JVM library modules
- **`io.getstream.java.platform`** - Java/Kotlin JVM platform modules

## Usage

### 1. Root Project Configuration
### Root Project Setup

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

Expand Down Expand Up @@ -55,22 +51,61 @@ streamProject {
// Additional Sonar coverage exclusion patterns for file paths (default: empty)
sonarCoverageExclusions = listOf("**/io/getstream/some/package/**")
}

publishing {
// Required: Description for all published artifacts
description = "Magical Stream SDK"

// Optional: Override artifact IDs for specific modules
moduleArtifactIdOverrides = mapOf(
"my-module" to "custom-artifact-id"
)
}
}
```

### 2. Module Configuration
### Module Setup

Apply the appropriate plugin to each module:

```kotlin
plugins {
id("io.getstream.android.library")
// or id("io.getstream.android.application")
// or id("io.getstream.android.test")
// or id("io.getstream.java.library")
// or: id("io.getstream.android.application")
// or: id("io.getstream.android.test")
// or: id("io.getstream.java.library")
// or: id("io.getstream.java.platform")
}
```

Library and platform plugins automatically configure Maven publishing.

## Versioning

Version is read from the project version. Can be set, for example, by adding it to
`gradle.properties`:

```properties
version=1.0.0
```

All published modules use this version. For snapshot builds, set the `SNAPSHOT` environment
variable:

```bash
SNAPSHOT=true ./gradlew publish
```

This produces timestamped snapshot versions: `1.0.0-yyyyMMddHHmm-SNAPSHOT`

## Publishing

Published artifacts use:

- **Group ID**: `io.getstream`
- **Artifact ID**: Module name (or override via `moduleArtifactIdOverrides`)
- **Version**: From `gradle.properties`

## License

See [LICENSE](LICENSE) file for details.
8 changes: 5 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@ agp = "8.11.1"
kotlin = "2.0.21"
detekt = "1.23.8"
spotless = "8.0.0"
kotlinDokka = "2.0.0"
kotlinDokka = "1.9.20"
Copy link
Collaborator Author

@gpunto gpunto Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Downgrading for the time being, because I don't want to bundle all the changes for the migration to the publishing configuration with the changes needed for migrating to Dokka v2 in products. I'll do the upgrade later.

mavenPublish = "0.34.0"
sonarqube = "6.0.1.5171"
kover = "0.9.3"

[libraries]
android-gradle-plugin = { group = "com.android.tools.build", name = "gradle", version.ref = "agp" }
dokka-gradle-plugin = { group = "org.jetbrains.dokka", name = "dokka-gradle-plugin", version.ref = "kotlinDokka" }
kotlin-gradle-plugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }
kover-gradle-plugin = { group = "org.jetbrains.kotlinx", name = "kover-gradle-plugin", version.ref = "kover" }
maven-publish-gradle-plugin = { group = "com.vanniktech", name = "gradle-maven-publish-plugin", version.ref = "mavenPublish" }
spotless-gradle-plugin = { group = "com.diffplug.spotless", name = "spotless-plugin-gradle", version.ref = "spotless" }
sonarqube-gradle-plugin = { group = "org.sonarsource.scanner.gradle", name = "sonarqube-gradle-plugin", version.ref = "sonarqube" }
kover-gradle-plugin = { group = "org.jetbrains.kotlinx", name = "kover-gradle-plugin", version.ref = "kover" }

[plugins]
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
dokka = { id = "org.jetbrains.dokka-javadoc", version.ref = "kotlinDokka" }
dokka = { id = "org.jetbrains.dokka", version.ref = "kotlinDokka" }
maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "mavenPublish" }
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
15 changes: 12 additions & 3 deletions plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ dependencies {
compileOnly(gradleKotlinDsl())
compileOnly(libs.android.gradle.plugin)
compileOnly(libs.kotlin.gradle.plugin)
implementation(libs.spotless.gradle.plugin)
implementation(libs.sonarqube.gradle.plugin)
implementation(libs.dokka.gradle.plugin)
implementation(libs.kover.gradle.plugin)
implementation(libs.maven.publish.gradle.plugin)
implementation(libs.sonarqube.gradle.plugin)
implementation(libs.spotless.gradle.plugin)
}

val repoId = "GetStream/stream-build-conventions-android"
Expand Down Expand Up @@ -72,12 +74,19 @@ gradlePlugin {
description = "Convention plugin for Stream Java/Kotlin JVM library modules"
tags = listOf("java", "library", "convention", "stream", "kotlin")
}
create("javaPlatform") {
id = "io.getstream.java.platform"
implementationClass = "io.getstream.android.JavaPlatformConventionPlugin"
displayName = "Stream Java Platform Convention Plugin"
description = "Convention plugin for Stream Java/Kotlin JVM platform modules"
tags = listOf("java", "platform", "convention", "stream", "kotlin")
}
}
}

mavenPublishing {
publishToMavenCentral(automaticRelease = true)
configure(GradlePlugin(javadocJar = JavadocJar.Javadoc(), sourcesJar = true))
configure(GradlePlugin(javadocJar = JavadocJar.Dokka("dokkaJavadoc"), sourcesJar = true))

pom {
name.set("Stream Build Conventions")
Expand Down
26 changes: 26 additions & 0 deletions plugin/src/main/kotlin/io/getstream/android/GradleUtils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2014-2025 Stream.io Inc. All rights reserved.
*
* Licensed under the Stream License;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://github.com/GetStream/stream-build-conventions-android/blob/main/LICENSE
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.getstream.android

import org.gradle.api.Task
import org.gradle.api.tasks.TaskContainer
import org.gradle.kotlin.dsl.named
import org.gradle.kotlin.dsl.register

internal inline fun <reified T : Task> TaskContainer.findOrRegister(
name: String,
noinline configuration: T.() -> Unit,
) = findByName(name)?.let { named<T>(name) } ?: register<T>(name, configuration)
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package io.getstream.android

import io.getstream.android.coverage.CoverageOptions
import io.getstream.android.publishing.PublishingOptions
import io.getstream.android.spotless.SpotlessOptions
import javax.inject.Inject
import org.gradle.api.Action
Expand Down Expand Up @@ -50,6 +51,12 @@ constructor(project: Project, objects: ObjectFactory) {

/** Configure code coverage */
fun coverage(action: Action<CoverageOptions>) = action.execute(coverage)

/** Publishing configuration */
val publishing: PublishingOptions = objects.newInstance<PublishingOptions>()

/** Configure publishing */
fun publishing(action: Action<PublishingOptions>) = action.execute(publishing)
}

internal fun Project.createProjectExtension(): StreamProjectExtension =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.android.build.api.dsl.LibraryExtension
import com.android.build.api.dsl.TestExtension
import io.getstream.android.coverage.configureCoverageModule
import io.getstream.android.coverage.configureCoverageRoot
import io.getstream.android.publishing.configurePublishing
import io.getstream.android.spotless.configureSpotless
import org.gradle.api.Plugin
import org.gradle.api.Project
Expand Down Expand Up @@ -63,6 +64,7 @@ class AndroidLibraryConventionPlugin : Plugin<Project> {
configureKotlin()
configureSpotless()
configureCoverageModule()
configurePublishing()
}
}
}
Expand All @@ -88,6 +90,20 @@ class JavaLibraryConventionPlugin : Plugin<Project> {
configureKotlin()
configureSpotless()
configureCoverageModule()
configurePublishing()
}
}
}

class JavaPlatformConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
pluginManager.apply("java-platform")

configureJava()
configureKotlin()
configureSpotless()
configurePublishing()
}
}
}
Loading
Loading