Skip to content

Commit

Permalink
Merge pull request #142 from khoi-nguyen-2359/use-ksp
Browse files Browse the repository at this point in the history
Replace kapt with ksp
  • Loading branch information
khoi-nguyen-2359 authored Aug 29, 2024
2 parents 31cc16d + 16d5f80 commit eebe2e9
Show file tree
Hide file tree
Showing 185 changed files with 1,544 additions and 7,366 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/develop_pr_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ jobs:
steps:
- name: Checkout the code
uses: actions/checkout@v2
- name: Set up JDK 11
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17

- name: Make local.properties
env:
MAPBOX_DEV_TOKEN: sk.eyJ1IjoiYWtob2k5MCIsImEiOiJjbGUwMjNxa3AwNDEzM3Fyejh6b2ZrNGw3In0.mSo-Z30lqYW4K2Ime0z62g
run: echo -e "mapbox.downloads.token=$MAPBOX_DEV_TOKEN" > local.properties

- name: Build Debug APK
run: bash ./gradlew :app:assembleDebug
run: bash ./gradlew :app:assembleDebug --stacktrace

- name: Run unit tests
run: bash ./gradlew testDebugUnitTest
4 changes: 2 additions & 2 deletions .github/workflows/publish_on_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ jobs:
- name: Checkout The Code
uses: actions/checkout@v2

- name: Set up JDK 11
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17

- name: Generate Files for Release Bundle
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release_pr_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ jobs:
steps:
- name: Checkout The Code
uses: actions/checkout@v2
- name: Set up JDK 11
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17

- name: Generate Files for Release Bundle
env:
Expand Down
29 changes: 4 additions & 25 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
alias libs.plugins.ksp
id 'kotlin-parcelize'
id 'com.google.gms.google-services'
id 'com.google.firebase.crashlytics'
id 'com.google.firebase.firebase-perf'
id "build-time-tracker"
}

android {
namespace 'akio.apps.myrun'
compileSdkVersion project.compileSdk
compileSdk project.compileSdk

defaultConfig {
applicationId project.appId
Expand Down Expand Up @@ -79,6 +78,7 @@ android {
buildFeatures {
viewBinding true
compose true
buildConfig true
}

composeOptions {
Expand Down Expand Up @@ -131,7 +131,7 @@ dependencies {

implementation(libs.dagger)
implementation(libs.anvil.annotations)
kapt(libs.daggercompiler)
ksp(libs.daggercompiler)

implementation(libs.androidx.core)
implementation(libs.androidx.appcompat)
Expand Down Expand Up @@ -162,24 +162,3 @@ dependencies {
testImplementation(libs.turbine)
testImplementation(libs.kotlinx.coroutinestest)
}

buildtimetracker {
reporters {
csv {
output "build/times.csv"
append true
header true
}

summary {
ordered false
threshold 500
barstyle "unicode"
shortenTaskNames false
}

csvSummary {
csv "build/times.csv"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package akio.apps.myrun.feature.configurator

import akio.apps.myrun.BuildConfig
import akio.apps.myrun.R
import akio.apps.myrun.feature.core.AppNotificationChannel
import android.annotation.SuppressLint
import android.app.Notification
import android.app.PendingIntent
import android.content.Context
Expand All @@ -17,11 +16,8 @@ object ConfiguratorFacade {
"akio.apps.myrun.feature.configurator.ConfiguratorActivity"
private val NOTIFICATION_ID = AppNotificationChannel.Debug.nextNotificationStaticId()

@SuppressLint("MissingPermission")
fun notifyInDebugMode(context: Context) {
if (BuildConfig.BUILD_TYPE != "debug") {
return
}

val notMan = NotificationManagerCompat.from(context)
val activityClass = try {
Class.forName(CONFIGURATOR_ACTIVITY_NAME)
Expand All @@ -41,7 +37,7 @@ object ConfiguratorFacade {
.setDefaults(Notification.DEFAULT_ALL)
.setOngoing(true)
.setContentIntent(pendingIntent)
.setSmallIcon(R.drawable.ic_run_circle)
.setSmallIcon(akio.apps.myrun.feature.core.R.drawable.ic_run_circle)
.build()

notMan.notify(NOTIFICATION_ID, notification)
Expand Down
10 changes: 6 additions & 4 deletions app/src/main/java/akio/apps/myrun/MyRunApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ class MyRunApp :
}

private fun initPlacesSdk() {
Places.initialize(applicationContext, getString(R.string.google_direction_api_key))
Places.initialize(
applicationContext,
getString(akio.apps.myrun.data.location.R.string.google_direction_api_key)
)
}

override fun onStart(owner: LifecycleOwner) {
Expand Down Expand Up @@ -123,16 +126,15 @@ class MyRunApp :
.setMinimumLoggingLevel(android.util.Log.DEBUG)
.build()
} else {
Configuration.Builder()
.setMinimumLoggingLevel(android.util.Log.ERROR)
.build()
Configuration.Builder().build()
}
}

override fun onMapsSdkInitialized(renderer: MapsInitializer.Renderer) {
when (renderer) {
MapsInitializer.Renderer.LATEST ->
Timber.d("MapsDemo", "The latest version of the renderer is used.")

MapsInitializer.Renderer.LEGACY ->
Timber.d("MapsDemo", "The legacy version of the renderer is used.")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package akio.apps.myrun.feature.main.ui

import akio.apps.myrun.R
import akio.apps.myrun.data.activity.api.model.BaseActivityModel
import akio.apps.myrun.feature.activity.R
import akio.apps.myrun.feature.core.ktx.px2dp
import akio.apps.myrun.feature.core.navigation.HomeTabNavDestination
import akio.apps.myrun.feature.core.ui.AppColors
Expand All @@ -13,6 +13,7 @@ import akio.apps.myrun.feature.feed.ui.ActivityFeedComposable
import akio.apps.myrun.feature.main.HomeTabViewModel
import akio.apps.myrun.feature.main.di.DaggerHomeTabComponent
import akio.apps.myrun.feature.userstats.ui.CurrentUserStatsComposable
import android.annotation.SuppressLint
import android.app.Application
import androidx.annotation.StringRes
import androidx.compose.animation.EnterTransition
Expand Down Expand Up @@ -151,6 +152,7 @@ private fun rememberViewModel(): HomeTabViewModel {
}
}

@SuppressLint("UnrememberedMutableState")
@Composable
private fun rememberFabState(currentTabEntry: NavBackStackEntry?): HomeTabFabState {
val systemBarBottomDp = WindowInsets.systemBars.getBottom(LocalDensity.current).px2dp.dp
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/akio/apps/myrun/log/MyDebugTree.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package akio.apps.myrun.log
import akio.apps.myrun.MyRunApp
import akio.apps.myrun.R
import akio.apps.myrun.feature.core.AppNotificationChannel
import android.annotation.SuppressLint
import android.util.Log
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
Expand All @@ -29,12 +30,13 @@ class MyDebugTree(private val application: MyRunApp) : Timber.DebugTree() {
FirebaseCrashlytics.getInstance().sendUnsentReports()
}

@SuppressLint("MissingPermission")
private fun notifyExceptionReport(cause: Throwable) {
val stackTrace = cause.stackTraceToString()
val notification = NotificationCompat.Builder(application, AppNotificationChannel.Debug.id)
.setContentTitle("A ${cause::class.simpleName} was recorded.")
.setContentText(stackTrace)
.setSmallIcon(R.drawable.ic_run_circle)
.setSmallIcon(akio.apps.myrun.feature.core.R.drawable.ic_run_circle)
.build()
NotificationManagerCompat.from(application)
.notify(System.currentTimeMillis().toInt(), notification)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package akio.apps.myrun.feature.configurator

import android.content.Context

object ConfiguratorFacade {
@Suppress("UNUSED_PARAMETER")
fun notifyInDebugMode(context: Context) {
// not enabled in release build
}
}
4 changes: 2 additions & 2 deletions app_versions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ project.ext {
versionCode = 2_04_01
appId = "akio.apps.myrun"
minSdk = 21
targetSdk = 33
compileSdk = 33
targetSdk = 34
compileSdk = 34
}
5 changes: 3 additions & 2 deletions base/di/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'kotlin-kapt'
alias libs.plugins.ksp
}

android {
Expand All @@ -11,6 +11,7 @@ android {
defaultConfig {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
minSdk project.minSdk
}

buildTypes {
Expand All @@ -34,7 +35,7 @@ dependencies {
implementation(libs.kotlinx.coroutines.core)

implementation(libs.dagger)
kapt(libs.daggercompiler)
ksp(libs.daggercompiler)

implementation(libs.timber)
}
5 changes: 3 additions & 2 deletions base/firebase/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'kotlin-kapt'
alias libs.plugins.ksp
}

android {
Expand All @@ -11,6 +11,7 @@ android {
defaultConfig {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
minSdk project.minSdk
}

buildTypes {
Expand All @@ -35,7 +36,7 @@ dependencies {
implementation(libs.kotlinx.coroutines.core)

implementation(libs.dagger)
kapt(libs.daggercompiler)
ksp(libs.daggercompiler)

implementation platform(libs.firebase.bom)
implementation(libs.bundles.firebase.data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import java.io.ByteArrayOutputStream
import kotlinx.coroutines.tasks.await

object FirebaseStorageUtils {
suspend fun uploadBitmap(
private suspend fun uploadBitmap(
storageRef: StorageReference,
storeName: String,
bitmap: Bitmap,
Expand Down
6 changes: 0 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ buildscript {
repositories {
google()
mavenCentral()
//noinspection JcenterRepositoryObsolete
jcenter()
}

dependencies {
Expand All @@ -16,18 +14,14 @@ buildscript {
classpath(libs.playservices.plugin)
classpath(libs.firebase.crashlytics.plugin)
classpath(libs.firebase.perf.plugin)
classpath(libs.buildtimetracker)
classpath(libs.kotlinserialization.plugin)
classpath(libs.anvil.plugin)
}
}

allprojects {
repositories {
google()
mavenCentral()
//noinspection JcenterRepositoryObsolete
jcenter()

maven {
url 'https://api.mapbox.com/downloads/v2/releases/maven'
Expand Down
15 changes: 11 additions & 4 deletions data/activity/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'kotlin-kapt'
id 'kotlinx-serialization'
id 'com.squareup.anvil'
alias libs.plugins.ksp
alias libs.plugins.anvil
}

android {
Expand Down Expand Up @@ -34,6 +34,13 @@ android {
}
}

anvil {
useKsp(
true, // contributesAndFactoryGeneration
true // componentMerging
)
}

dependencies {
implementation(project(":data:api"))
implementation(project(":base:di"))
Expand All @@ -45,10 +52,10 @@ dependencies {
implementation(libs.kotlinx.coroutines.core)
implementation(libs.kotlinx.coroutines.play.services)

implementation(libs.tcxzpot)
implementation(project(":libs:routeparser"))

implementation(libs.dagger)
kapt(libs.daggercompiler)
ksp(libs.daggercompiler)

implementation(libs.playservices.map)
implementation(libs.googlemaps.androidutils)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import akio.apps.myrun.data.activity.api.ActivityTcxFileWriter
import android.app.Application
import com.squareup.anvil.annotations.MergeComponent
import dagger.BindsInstance
import dagger.Component
import javax.inject.Singleton

abstract class ActivityDataScope private constructor()
Expand All @@ -22,7 +21,7 @@ interface ActivityDataComponent {
fun activityRepository(): ActivityRepository
fun activityTcxFileWriter(): ActivityTcxFileWriter

@Component.Factory
@MergeComponent.Factory
interface Factory {
fun create(@BindsInstance application: Application): ActivityDataComponent
}
Expand Down
Loading

0 comments on commit eebe2e9

Please sign in to comment.