Skip to content

Commit

Permalink
Merge pull request #375 from splendo/gitlive/kotlin-1.8.21-gradle-8
Browse files Browse the repository at this point in the history
Upgrade to Kotlin 1.9.20 & gradle 8
  • Loading branch information
nbransby authored Dec 11, 2023
2 parents f748d61 + c04da65 commit 30c8665
Show file tree
Hide file tree
Showing 146 changed files with 2,550 additions and 1,183 deletions.
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/increase-api-coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ assignees: ''

---

| Library | Class | Member | Platforms |
| :-----------------| :------------------------ | :----------------------------------- | :---------------------- |
| e.g auth | e.g FirebaseAuth | e.g signInWithGithub | e.g Android, iOS |
| Library | Class | Member | Platforms |
|:---------|:-----------------|:---------------------|:-----------------|
| e.g auth | e.g FirebaseAuth | e.g signInWithGithub | e.g Android, iOS |
30 changes: 30 additions & 0 deletions .github/actions/setup_test_action/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: 'Setup Tests'
description: 'Prepares to run tests on Firebase emulator'

runs:
using: "composite"
steps:
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'
cache: gradle
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '21.x'
- name: Upgrade packages
shell: bash
run: npm update
- name: Gradle cache
uses: gradle/gradle-build-action@v2
- name: Grant execute permission for gradlew
shell: bash
run: chmod +x gradlew
- name: Install Firebase tools
shell: bash
run: npm install -g firebase-tools
- name: Start Firebase emulator
shell: bash
run: "firebase emulators:start --config=./test/firebase.json &"
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ env:

jobs:
build:
runs-on: macos-latest
runs-on: macos-13
steps:
- uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
java-version: '17'
- uses: gradle/gradle-build-action@v2
- name: Setup versions
run: ./gradlew :updateVersions
Expand Down
120 changes: 71 additions & 49 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,71 +8,31 @@ on:
branches: [ master ]

jobs:
build:
runs-on: macos-latest
build-android:
runs-on: macos-13
strategy:
matrix:
api-level: [ 29 ]
api-level: [ 34 ]
steps:
- uses: actions/checkout@v3
- name: Cocoapods cache
uses: actions/cache@v3
id: cocoapods-cache
with:
path: |
~/.cocoapods
~/Library/Caches/CocoaPods
*/build/cocoapods
*/build/classes
key: cocoapods-cache
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
cache: gradle
- name: Gradle cache
uses: gradle/gradle-build-action@v2
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Install Firebase tools
run: npm install -g firebase-tools
- name: Start Firebase emulator
run: "firebase emulators:start --config=./test/firebase.json &"
- name: Assemble
run: ./gradlew assemble
- name: Run JS Tests
run: ./gradlew cleanTest jsLegacyTest
- name: Upload JS test artifact
uses: actions/upload-artifact@v3
if: failure()
with:
name: "JS Test Report HTML"
path: |
**/build/reports/tests/jsLegacyTest/
**/build/reports/tests/jsLegacyBrowserTest/
**/build/reports/tests/jsLegacyNodeTest/
- name: Run iOS Tests
run: ./gradlew cleanTest iosX64Test
- name: Upload iOS test artifact
uses: actions/upload-artifact@v3
if: failure()
with:
name: "iOS Test Report HTML"
path: "**/build/reports/tests/iosX64Test/"
- name: Setup test environment
uses: ./.github/actions/setup_test_action
- name: AVD cache
uses: actions/cache@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}
key: avd-${{ matrix.api-level }}-${{ runner.os }}-${{ runner.arch }}
- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
arch: x86_64
target: google_apis
avd-name: pixel6_API${{ matrix.api-level }}
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
Expand All @@ -81,6 +41,9 @@ jobs:
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
arch: x86_64
target: google_apis
avd-name: pixel6_API${{ matrix.api-level }}
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
Expand All @@ -91,3 +54,62 @@ jobs:
with:
name: "Android Test Report HTML"
path: "**/build/reports/androidTests/"
- name: Upload Firebase Debug Log
uses: actions/upload-artifact@v3
if: failure()
with:
name: "Firebase Debug Log"
path: "**/firebase-debug.log"
build-js:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup test environment
uses: ./.github/actions/setup_test_action
- name: Run JS Tests
run: ./gradlew cleanTest jsTest
- name: Upload JS test artifact
uses: actions/upload-artifact@v3
if: failure()
with:
name: "JS Test Report HTML"
path: |
**/build/reports/tests/jsTest/
**/build/reports/tests/jsBrowserTest/
**/build/reports/tests/jsNodeTest/
- name: Upload Firebase Debug Log
uses: actions/upload-artifact@v3
if: failure()
with:
name: "Firebase Debug Log"
path: "**/firebase-debug.log"
build-ios:
runs-on: macos-13
steps:
- uses: actions/checkout@v3
- name: Cocoapods cache
uses: actions/cache@v3
id: cocoapods-cache
with:
path: |
~/.cocoapods
~/Library/Caches/CocoaPods
*/build/cocoapods
*/build/classes
key: cocoapods-cache
- name: Setup test environment
uses: ./.github/actions/setup_test_action
- name: Run iOS Tests
run: ./gradlew cleanTest iosX64Test
- name: Upload iOS test artifact
uses: actions/upload-artifact@v3
if: failure()
with:
name: "iOS Test Report HTML"
path: "**/build/reports/tests/iosX64Test/"
- name: Upload Firebase Debug Log
uses: actions/upload-artifact@v3
if: failure()
with:
name: "Firebase Debug Log"
path: "**/firebase-debug.log"
12 changes: 2 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,9 @@
local.properties
/**/*.iml
*.iml
firebase-app/src/nativeInterop/cinterop/modules/
firebase-functions/src/nativeInterop/cinterop/modules/
firebase-auth/src/nativeInterop/cinterop/modules/
firebase-firestore/src/nativeInterop/cinterop/modules/
firebase-database/src/nativeInterop/cinterop/modules/
Firebase*.zip
/Firebase
/.DS_Store
.DS_Store
*.log


/**/nativeInterop/cinterop/Cartfile.resolved
/**/nativeInterop/cinterop/Carthage/
/kotlin-js-store/
/kotlin-js-store/yarn.lock
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ The Firebase Kotlin SDK uses Kotlin serialization to read and write custom class

```groovy
plugins {
kotlin("multiplatform") version "1.8.20" // or kotlin("jvm") or any other kotlin plugin
kotlin("plugin.serialization") version "1.8.20"
kotlin("multiplatform") version "1.8.21" // or kotlin("jvm") or any other kotlin plugin
kotlin("plugin.serialization") version "1.8.21"
}
```

Expand Down Expand Up @@ -161,17 +161,17 @@ To reduce boilerplate, default arguments are used in the places where the Fireba
UserProfileChangeRequest profileUpdates = new UserProfileChangeRequest.Builder()
.setDisplayName("Jane Q. User")
.setPhotoUri(Uri.parse("https://example.com/jane-q-user/profile.jpg"))
.build();
.build()

user.updateProfile(profileUpdates)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
Log.d(TAG, "User profile updated.");
Log.d(TAG, "User profile updated.")
}
}
});
})

//...becomes...

Expand Down
52 changes: 30 additions & 22 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask

repositories {
google()
mavenCentral()
}

plugins {
kotlin("multiplatform") version "1.8.20" apply false
kotlin("native.cocoapods") version "1.8.20" apply false
kotlin("multiplatform") apply false
kotlin("native.cocoapods") apply false
id("base")
id("com.github.ben-manes.versions") version "0.42.0"
}
Expand All @@ -23,17 +24,17 @@ buildscript {
}
}
dependencies {
classpath("com.android.tools.build:gradle:7.2.2")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.20-RC")
classpath("com.android.tools.build:gradle:${project.extra["gradlePluginVersion"]}")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${project.extra["kotlinVersion"]}")
classpath("com.adarshr:gradle-test-logger-plugin:3.2.0")
}
}

val targetSdkVersion by extra(32)
val minSdkVersion by extra(19)
val compileSdkVersion by extra(34)
val minSdkVersion by extra(23)

tasks {
val updateVersions by registering {
register("updateVersions") {
dependsOn(
"firebase-app:updateVersion", "firebase-app:updateDependencyVersion",
"firebase-auth:updateVersion", "firebase-auth:updateDependencyVersion",
Expand All @@ -52,7 +53,7 @@ tasks {
subprojects {

group = "dev.gitlive"

apply(plugin = "com.adarshr.test-logger")

repositories {
Expand Down Expand Up @@ -88,11 +89,11 @@ subprojects {

if (skipPublishing) return@tasks

val updateVersion by registering(Exec::class) {
register<Exec>("updateVersion") {
commandLine("npm", "--allow-same-version", "--prefix", projectDir, "version", "${project.property("${project.name}.version")}")
}

val updateDependencyVersion by registering(Copy::class) {
register<Copy>("updateDependencyVersion") {
mustRunAfter("updateVersion")
val from = file("package.json")
from.writeText(
Expand All @@ -106,28 +107,30 @@ subprojects {

afterEvaluate {

val coroutinesVersion: String by project
val firebaseBoMVersion: String by project

dependencies {
"commonMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
"androidMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.6.4")
"androidMainImplementation"(platform("com.google.firebase:firebase-bom:32.3.1"))
"commonMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
"androidMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$coroutinesVersion")
"androidMainImplementation"(platform("com.google.firebase:firebase-bom:$firebaseBoMVersion"))
"commonTestImplementation"(kotlin("test-common"))
"commonTestImplementation"(kotlin("test-annotations-common"))
"commonTestImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
"commonTestImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4")
if (this@afterEvaluate.name != "firebase-crashlytics") {
"jvmMainApi"("dev.gitlive:firebase-java-sdk:0.1.2")
"jvmMainApi"("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.6.0") {
"jvmMainApi"("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$coroutinesVersion") {
exclude("com.google.android.gms")
}
"jsTestImplementation"(kotlin("test-js"))
"jvmTestImplementation"(kotlin("test-junit"))
"jvmTestImplementation"("junit:junit:4.13.2")
}
"androidAndroidTestImplementation"(kotlin("test-junit"))
"androidAndroidTestImplementation"("junit:junit:4.13.2")
"androidAndroidTestImplementation"("androidx.test:core:1.4.0")
"androidAndroidTestImplementation"("androidx.test.ext:junit:1.1.3")
"androidAndroidTestImplementation"("androidx.test:runner:1.4.0")
"androidInstrumentedTestImplementation"(kotlin("test-junit"))
"androidUnitTestImplementation"(kotlin("test-junit"))
"androidInstrumentedTestImplementation"("junit:junit:4.13.2")
"androidInstrumentedTestImplementation"("androidx.test:core:1.5.0")
"androidInstrumentedTestImplementation"("androidx.test.ext:junit:1.1.5")
"androidInstrumentedTestImplementation"("androidx.test:runner:1.5.2")
}
}

Expand All @@ -145,6 +148,7 @@ subprojects {
repositories {
maven {
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2")

credentials {
username = project.findProperty("sonatypeUsername") as String? ?: System.getenv("sonatypeUsername")
password = project.findProperty("sonatypePassword") as String? ?: System.getenv("sonatypePassword")
Expand Down Expand Up @@ -193,12 +197,16 @@ subprojects {
}

}

tasks.withType(AbstractPublishToMaven::class.java).configureEach {
dependsOn(tasks.withType(Sign::class.java))
}
}

tasks.withType<com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask> {

fun isNonStable(version: String): Boolean {
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) }
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.uppercase(java.util.Locale.ENGLISH).contains(it) }
val versionMatch = "^[0-9,.v-]+(-r)?$".toRegex().matches(version)

return (stableKeyword || versionMatch).not()
Expand Down
Loading

0 comments on commit 30c8665

Please sign in to comment.