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
21 changes: 21 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,27 @@ jobs:
with:
token: ${{ secrets.STREAM_PUBLIC_BOT_TOKEN }}
ref: develop
fetch-depth: 0

- name: Verify main is merged into develop
run: |
git fetch origin main

# Check if main is fully merged into develop (i.e., main is an ancestor of develop)
if ! git merge-base --is-ancestor origin/main HEAD; then
echo "❌ Error: main branch has commits not in develop!"
echo ""
echo "This usually means someone pushed directly into main or a previous release pushed
echo "main but failed to push develop. You need to merge main into develop:"
echo ""
echo " git checkout develop"
echo " git merge origin/main"
echo " git push origin develop"
echo ""
echo "After fixing this, you can retry the release."
exit 1
fi
echo "✅ main is fully merged into develop"

- name: Bump version
id: bump
Expand Down
7 changes: 7 additions & 0 deletions plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ gradlePlugin {
description = "Convention plugin for Stream Android application modules"
tags = listOf("android", "application", "convention", "stream", "kotlin")
}
create("javaLibrary") {
id = "io.getstream.java.library"
implementationClass = "io.getstream.android.JavaLibraryConventionPlugin"
displayName = "Stream Java Library Convention Plugin"
description = "Convention plugin for Stream Java/Kotlin JVM library modules"
tags = listOf("java", "library", "convention", "stream", "kotlin")
}
}
}

Expand Down
84 changes: 84 additions & 0 deletions plugin/src/main/kotlin/io/getstream/android/BaseConfiguration.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* 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 com.android.build.api.dsl.CommonExtension
import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.api.plugins.AppliedPlugin
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.api.tasks.testing.Test
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.kotlin.dsl.getByType
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

private val javaVersion = JavaVersion.VERSION_11
private val jvmTargetVersion = JvmTarget.JVM_11

internal inline fun <reified Ext : CommonExtension<*, *, *, *, *, *>> Project.configureAndroid() {
val commonExtension = extensions.getByType<Ext>()

commonExtension.apply {
compileOptions {
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}

testOptions {
unitTests {
isIncludeAndroidResources = true
isReturnDefaultValues = true
all(Test::configureTestLogging)
}
}
}

tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = javaVersion.toString()
targetCompatibility = javaVersion.toString()
}
}

internal fun Project.configureJava() {
tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = javaVersion.toString()
targetCompatibility = javaVersion.toString()
}

tasks.withType<Test>().configureEach(Test::configureTestLogging)
}

private fun Test.configureTestLogging() = testLogging {
events("failed")
showExceptions = true
showCauses = true
showStackTraces = true
exceptionFormat = TestExceptionFormat.FULL
}

internal fun Project.configureKotlin() {
val configure = { _: AppliedPlugin ->
tasks.withType<KotlinCompile>().configureEach {
compilerOptions { jvmTarget.set(jvmTargetVersion) }
}
}

// Configure the Kotlin plugin that is applied, if any
pluginManager.withPlugin("org.jetbrains.kotlin.android", configure)
pluginManager.withPlugin("org.jetbrains.kotlin.jvm", configure)
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,17 @@
package io.getstream.android

import com.android.build.api.dsl.ApplicationExtension
import com.android.build.api.dsl.CommonExtension
import com.android.build.api.dsl.LibraryExtension
import org.gradle.api.JavaVersion
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension

class AndroidApplicationConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
pluginManager.apply("com.android.application")

configureAndroid<ApplicationExtension>()
configureKotlin()
}
}
}
Expand All @@ -44,48 +37,18 @@ class AndroidLibraryConventionPlugin : Plugin<Project> {
pluginManager.apply("com.android.library")

configureAndroid<LibraryExtension>()
configureKotlin()
}
}
}

private val javaVersion = JavaVersion.VERSION_11
private val jvmTargetVersion = JvmTarget.JVM_11

private inline fun <reified Ext : CommonExtension<*, *, *, *, *, *>> Project.configureAndroid() {
val commonExtension = extensions.getByType(Ext::class.java)

commonExtension.apply {
compileOptions {
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}

testOptions {
unitTests {
isIncludeAndroidResources = true
isReturnDefaultValues = true
all {
it.testLogging {
events("failed")
showExceptions = true
showCauses = true
showStackTraces = true
exceptionFormat = TestExceptionFormat.FULL
}
}
}
}
}

tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = javaVersion.toString()
targetCompatibility = javaVersion.toString()
}
class JavaLibraryConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
pluginManager.apply("java-library")

// Configure the Kotlin plugin if it is applied
pluginManager.withPlugin("org.jetbrains.kotlin.android") {
extensions.configure<KotlinAndroidProjectExtension> {
compilerOptions { jvmTarget.set(jvmTargetVersion) }
configureJava()
configureKotlin()
}
}
}
Loading