diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 47b8af943..9c6989f67 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -20,8 +20,8 @@ plugins { alias(libs.plugins.nowinandroid.android.application.compose) alias(libs.plugins.nowinandroid.android.application.flavors) alias(libs.plugins.nowinandroid.android.application.jacoco) - alias(libs.plugins.nowinandroid.android.hilt) alias(libs.plugins.nowinandroid.android.application.firebase) + alias(libs.plugins.nowinandroid.hilt) id("com.google.android.gms.oss-licenses-plugin") alias(libs.plugins.baselineprofile) alias(libs.plugins.roborazzi) diff --git a/build-logic/convention/build.gradle.kts b/build-logic/convention/build.gradle.kts index dc478a829..c735fa4a0 100644 --- a/build-logic/convention/build.gradle.kts +++ b/build-logic/convention/build.gradle.kts @@ -89,9 +89,9 @@ gradlePlugin { id = "nowinandroid.android.test" implementationClass = "AndroidTestConventionPlugin" } - register("androidHilt") { - id = "nowinandroid.android.hilt" - implementationClass = "AndroidHiltConventionPlugin" + register("hilt") { + id = "nowinandroid.hilt" + implementationClass = "HiltConventionPlugin" } register("androidRoom") { id = "nowinandroid.android.room" diff --git a/build-logic/convention/src/main/kotlin/AndroidFeatureConventionPlugin.kt b/build-logic/convention/src/main/kotlin/AndroidFeatureConventionPlugin.kt index 024ec4fe0..9110e7fa3 100644 --- a/build-logic/convention/src/main/kotlin/AndroidFeatureConventionPlugin.kt +++ b/build-logic/convention/src/main/kotlin/AndroidFeatureConventionPlugin.kt @@ -27,7 +27,7 @@ class AndroidFeatureConventionPlugin : Plugin { with(target) { pluginManager.apply { apply("nowinandroid.android.library") - apply("nowinandroid.android.hilt") + apply("nowinandroid.hilt") } extensions.configure { testOptions.animationsDisabled = true diff --git a/build-logic/convention/src/main/kotlin/AndroidHiltConventionPlugin.kt b/build-logic/convention/src/main/kotlin/HiltConventionPlugin.kt similarity index 55% rename from build-logic/convention/src/main/kotlin/AndroidHiltConventionPlugin.kt rename to build-logic/convention/src/main/kotlin/HiltConventionPlugin.kt index fcb4f823e..a8228e5af 100644 --- a/build-logic/convention/src/main/kotlin/AndroidHiltConventionPlugin.kt +++ b/build-logic/convention/src/main/kotlin/HiltConventionPlugin.kt @@ -1,5 +1,5 @@ /* - * Copyright 2022 The Android Open Source Project + * Copyright 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,25 +14,28 @@ * limitations under the License. */ +import com.android.build.gradle.api.AndroidBasePlugin import com.google.samples.apps.nowinandroid.libs import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.kotlin.dsl.dependencies -class AndroidHiltConventionPlugin : Plugin { +class HiltConventionPlugin : Plugin { override fun apply(target: Project) { with(target) { - with(pluginManager) { - apply("com.google.devtools.ksp") - apply("dagger.hilt.android.plugin") - } - + pluginManager.apply("com.google.devtools.ksp") dependencies { - "implementation"(libs.findLibrary("hilt.android").get()) - "ksp"(libs.findLibrary("hilt.compiler").get()) + add("ksp", libs.findLibrary("hilt.compiler").get()) + add("implementation", libs.findLibrary("hilt.core").get()) } + /** Add support for Android modules, based on [AndroidBasePlugin] */ + pluginManager.withPlugin("com.android.base") { + pluginManager.apply("dagger.hilt.android.plugin") + dependencies { + add("implementation", libs.findLibrary("hilt.android").get()) + } + } } } - } diff --git a/core/analytics/build.gradle.kts b/core/analytics/build.gradle.kts index 023574e6f..72f7620b0 100644 --- a/core/analytics/build.gradle.kts +++ b/core/analytics/build.gradle.kts @@ -16,7 +16,7 @@ plugins { alias(libs.plugins.nowinandroid.android.library) alias(libs.plugins.nowinandroid.android.library.compose) - alias(libs.plugins.nowinandroid.android.hilt) + alias(libs.plugins.nowinandroid.hilt) } android { diff --git a/core/common/build.gradle.kts b/core/common/build.gradle.kts index 51ae627dc..f1aa9771c 100644 --- a/core/common/build.gradle.kts +++ b/core/common/build.gradle.kts @@ -14,16 +14,12 @@ * limitations under the License. */ plugins { - alias(libs.plugins.nowinandroid.android.library) - alias(libs.plugins.nowinandroid.android.library.jacoco) - alias(libs.plugins.nowinandroid.android.hilt) -} - -android { - namespace = "com.google.samples.apps.nowinandroid.core.common" + alias(libs.plugins.nowinandroid.jvm.library) + alias(libs.plugins.nowinandroid.hilt) } dependencies { + implementation(libs.kotlinx.coroutines.core) testImplementation(libs.kotlinx.coroutines.test) testImplementation(libs.turbine) } \ No newline at end of file diff --git a/core/common/src/main/AndroidManifest.xml b/core/common/src/main/AndroidManifest.xml deleted file mode 100644 index 51d0cfc2e..000000000 --- a/core/common/src/main/AndroidManifest.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - \ No newline at end of file diff --git a/core/data-test/build.gradle.kts b/core/data-test/build.gradle.kts index b166df288..420c34a57 100644 --- a/core/data-test/build.gradle.kts +++ b/core/data-test/build.gradle.kts @@ -15,7 +15,7 @@ */ plugins { alias(libs.plugins.nowinandroid.android.library) - alias(libs.plugins.nowinandroid.android.hilt) + alias(libs.plugins.nowinandroid.hilt) } android { diff --git a/core/data/build.gradle.kts b/core/data/build.gradle.kts index 142637ff9..83c268aab 100644 --- a/core/data/build.gradle.kts +++ b/core/data/build.gradle.kts @@ -16,7 +16,7 @@ plugins { alias(libs.plugins.nowinandroid.android.library) alias(libs.plugins.nowinandroid.android.library.jacoco) - alias(libs.plugins.nowinandroid.android.hilt) + alias(libs.plugins.nowinandroid.hilt) id("kotlinx-serialization") } diff --git a/core/database/build.gradle.kts b/core/database/build.gradle.kts index a9e38ead7..8bab355b4 100644 --- a/core/database/build.gradle.kts +++ b/core/database/build.gradle.kts @@ -17,8 +17,8 @@ plugins { alias(libs.plugins.nowinandroid.android.library) alias(libs.plugins.nowinandroid.android.library.jacoco) - alias(libs.plugins.nowinandroid.android.hilt) alias(libs.plugins.nowinandroid.android.room) + alias(libs.plugins.nowinandroid.hilt) } android { diff --git a/core/datastore-test/build.gradle.kts b/core/datastore-test/build.gradle.kts index 53e5e2c0c..375b1d3d8 100644 --- a/core/datastore-test/build.gradle.kts +++ b/core/datastore-test/build.gradle.kts @@ -15,7 +15,7 @@ */ plugins { alias(libs.plugins.nowinandroid.android.library) - alias(libs.plugins.nowinandroid.android.hilt) + alias(libs.plugins.nowinandroid.hilt) } android { diff --git a/core/datastore/build.gradle.kts b/core/datastore/build.gradle.kts index 34ea5ee78..b17bf6abd 100644 --- a/core/datastore/build.gradle.kts +++ b/core/datastore/build.gradle.kts @@ -17,7 +17,7 @@ plugins { alias(libs.plugins.nowinandroid.android.library) alias(libs.plugins.nowinandroid.android.library.jacoco) - alias(libs.plugins.nowinandroid.android.hilt) + alias(libs.plugins.nowinandroid.hilt) } android { @@ -33,7 +33,7 @@ android { } dependencies { - api(libs.androidx.dataStore.core) + api(libs.androidx.dataStore) api(projects.core.datastoreProto) api(projects.core.model) diff --git a/core/network/build.gradle.kts b/core/network/build.gradle.kts index 689a99e73..d12482a56 100644 --- a/core/network/build.gradle.kts +++ b/core/network/build.gradle.kts @@ -17,7 +17,7 @@ plugins { alias(libs.plugins.nowinandroid.android.library) alias(libs.plugins.nowinandroid.android.library.jacoco) - alias(libs.plugins.nowinandroid.android.hilt) + alias(libs.plugins.nowinandroid.hilt) id("kotlinx-serialization") id("com.google.android.libraries.mapsplatform.secrets-gradle-plugin") } diff --git a/core/notifications/build.gradle.kts b/core/notifications/build.gradle.kts index 92871b72b..34393049b 100644 --- a/core/notifications/build.gradle.kts +++ b/core/notifications/build.gradle.kts @@ -15,7 +15,7 @@ */ plugins { alias(libs.plugins.nowinandroid.android.library) - alias(libs.plugins.nowinandroid.android.hilt) + alias(libs.plugins.nowinandroid.hilt) } android { @@ -28,5 +28,4 @@ dependencies { implementation(projects.core.common) compileOnly(platform(libs.androidx.compose.bom)) - compileOnly(libs.androidx.compose.runtime) } diff --git a/core/notifications/src/main/kotlin/com/google/samples/apps/nowinandroid/core/notifications/SystemTrayNotifier.kt b/core/notifications/src/main/kotlin/com/google/samples/apps/nowinandroid/core/notifications/SystemTrayNotifier.kt index 1c9e7ab63..5da88102a 100644 --- a/core/notifications/src/main/kotlin/com/google/samples/apps/nowinandroid/core/notifications/SystemTrayNotifier.kt +++ b/core/notifications/src/main/kotlin/com/google/samples/apps/nowinandroid/core/notifications/SystemTrayNotifier.kt @@ -65,9 +65,7 @@ internal class SystemTrayNotifier @Inject constructor( val newsNotifications = truncatedNewsResources.map { newsResource -> createNewsNotification { - setSmallIcon( - com.google.samples.apps.nowinandroid.core.common.R.drawable.core_common_ic_nia_notification, - ) + setSmallIcon(R.drawable.core_notifications_ic_nia_notification) .setContentTitle(newsResource.title) .setContentText(newsResource.content) .setContentIntent(newsPendingIntent(newsResource)) @@ -82,9 +80,7 @@ internal class SystemTrayNotifier @Inject constructor( ) setContentTitle(title) .setContentText(title) - .setSmallIcon( - com.google.samples.apps.nowinandroid.core.common.R.drawable.core_common_ic_nia_notification, - ) + .setSmallIcon(R.drawable.core_notifications_ic_nia_notification) // Build summary info into InboxStyle template. .setStyle(newsNotificationStyle(truncatedNewsResources, title)) .setGroup(NEWS_NOTIFICATION_GROUP) diff --git a/core/common/src/main/res/drawable-anydpi-v24/core_common_ic_nia_notification.xml b/core/notifications/src/main/res/drawable-anydpi-v24/core_notifications_ic_nia_notification.xml similarity index 100% rename from core/common/src/main/res/drawable-anydpi-v24/core_common_ic_nia_notification.xml rename to core/notifications/src/main/res/drawable-anydpi-v24/core_notifications_ic_nia_notification.xml diff --git a/core/common/src/main/res/drawable-hdpi/core_common_ic_nia_notification.png b/core/notifications/src/main/res/drawable-hdpi/core_notifications_ic_nia_notification.png similarity index 100% rename from core/common/src/main/res/drawable-hdpi/core_common_ic_nia_notification.png rename to core/notifications/src/main/res/drawable-hdpi/core_notifications_ic_nia_notification.png diff --git a/core/common/src/main/res/drawable-mdpi/core_common_ic_nia_notification.png b/core/notifications/src/main/res/drawable-mdpi/core_notifications_ic_nia_notification.png similarity index 100% rename from core/common/src/main/res/drawable-mdpi/core_common_ic_nia_notification.png rename to core/notifications/src/main/res/drawable-mdpi/core_notifications_ic_nia_notification.png diff --git a/core/common/src/main/res/drawable-xhdpi/core_common_ic_nia_notification.png b/core/notifications/src/main/res/drawable-xhdpi/core_notifications_ic_nia_notification.png similarity index 100% rename from core/common/src/main/res/drawable-xhdpi/core_common_ic_nia_notification.png rename to core/notifications/src/main/res/drawable-xhdpi/core_notifications_ic_nia_notification.png diff --git a/core/common/src/main/res/drawable-xxhdpi/core_common_ic_nia_notification.png b/core/notifications/src/main/res/drawable-xxhdpi/core_notifications_ic_nia_notification.png similarity index 100% rename from core/common/src/main/res/drawable-xxhdpi/core_common_ic_nia_notification.png rename to core/notifications/src/main/res/drawable-xxhdpi/core_notifications_ic_nia_notification.png diff --git a/core/screenshot-testing/build.gradle.kts b/core/screenshot-testing/build.gradle.kts index 1b816fc67..794416ba9 100644 --- a/core/screenshot-testing/build.gradle.kts +++ b/core/screenshot-testing/build.gradle.kts @@ -16,7 +16,7 @@ plugins { alias(libs.plugins.nowinandroid.android.library) alias(libs.plugins.nowinandroid.android.library.compose) - alias(libs.plugins.nowinandroid.android.hilt) + alias(libs.plugins.nowinandroid.hilt) } android { diff --git a/core/testing/build.gradle.kts b/core/testing/build.gradle.kts index 90f2405a4..01696d5e8 100644 --- a/core/testing/build.gradle.kts +++ b/core/testing/build.gradle.kts @@ -15,7 +15,7 @@ */ plugins { alias(libs.plugins.nowinandroid.android.library) - alias(libs.plugins.nowinandroid.android.hilt) + alias(libs.plugins.nowinandroid.hilt) } android { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 530123c8c..cc44b5003 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -89,7 +89,8 @@ androidx-compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "u androidx-compose-ui-util = { group = "androidx.compose.ui", name = "ui-util" } androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "androidxCore" } androidx-core-splashscreen = { group = "androidx.core", name = "core-splashscreen", version.ref = "androidxCoreSplashscreen" } -androidx-dataStore-core = { group = "androidx.datastore", name = "datastore", version.ref = "androidxDataStore" } +androidx-dataStore = { group = "androidx.datastore", name = "datastore", version.ref = "androidxDataStore" } +androidx-dataStore-core = { group = "androidx.datastore", name = "datastore-core", version.ref = "androidxDataStore" } androidx-hilt-navigation-compose = { group = "androidx.hilt", name = "hilt-navigation-compose", version.ref = "androidxHiltNavigationCompose" } androidx-lifecycle-runtimeCompose = { group = "androidx.lifecycle", name = "lifecycle-runtime-compose", version.ref = "androidxLifecycle" } androidx-lifecycle-runtimeTesting = { group = "androidx.lifecycle", name = "lifecycle-runtime-testing", version.ref = "androidxLifecycle" } @@ -121,11 +122,14 @@ google-oss-licenses = { group = "com.google.android.gms", name = "play-services- google-oss-licenses-plugin = { group = "com.google.android.gms", name = "oss-licenses-plugin", version.ref = "googleOssPlugin" } hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt" } hilt-android-testing = { group = "com.google.dagger", name = "hilt-android-testing", version.ref = "hilt" } -hilt-compiler = { group = "com.google.dagger", name = "hilt-android-compiler", version.ref = "hilt" } +hilt-compiler = { group = "com.google.dagger", name = "hilt-compiler", version.ref = "hilt" } +hilt-core = { group = "com.google.dagger", name = "hilt-core", version.ref = "hilt" } hilt-ext-compiler = { group = "androidx.hilt", name = "hilt-compiler", version.ref = "hiltExt" } hilt-ext-work = { group = "androidx.hilt", name = "hilt-work", version.ref = "hiltExt" } javax-inject = { module = "javax.inject:javax.inject", version = "1" } kotlin-stdlib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-jdk8", version.ref = "kotlin" } +kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "kotlinxCoroutines" } +kotlinx-coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "kotlinxCoroutines" } kotlinx-coroutines-guava = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-guava", version.ref = "kotlinxCoroutines" } kotlinx-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "kotlinxCoroutines" } kotlinx-datetime = { group = "org.jetbrains.kotlinx", name = "kotlinx-datetime", version.ref = "kotlinxDatetime" } @@ -183,11 +187,11 @@ nowinandroid-android-application-firebase = { id = "nowinandroid.android.applica nowinandroid-android-application-flavors = { id = "nowinandroid.android.application.flavors", version = "unspecified" } nowinandroid-android-application-jacoco = { id = "nowinandroid.android.application.jacoco", version = "unspecified" } nowinandroid-android-feature = { id = "nowinandroid.android.feature", version = "unspecified" } -nowinandroid-android-hilt = { id = "nowinandroid.android.hilt", version = "unspecified" } nowinandroid-android-library = { id = "nowinandroid.android.library", version = "unspecified" } nowinandroid-android-library-compose = { id = "nowinandroid.android.library.compose", version = "unspecified" } nowinandroid-android-library-jacoco = { id = "nowinandroid.android.library.jacoco", version = "unspecified" } nowinandroid-android-lint = { id = "nowinandroid.android.lint", version = "unspecified" } nowinandroid-android-room = { id = "nowinandroid.android.room", version = "unspecified" } nowinandroid-android-test = { id = "nowinandroid.android.test", version = "unspecified" } +nowinandroid-hilt = { id = "nowinandroid.hilt", version = "unspecified" } nowinandroid-jvm-library = { id = "nowinandroid.jvm.library", version = "unspecified" } diff --git a/sync/sync-test/build.gradle.kts b/sync/sync-test/build.gradle.kts index 0fac2cf83..fd9af1882 100644 --- a/sync/sync-test/build.gradle.kts +++ b/sync/sync-test/build.gradle.kts @@ -15,7 +15,7 @@ */ plugins { alias(libs.plugins.nowinandroid.android.library) - alias(libs.plugins.nowinandroid.android.hilt) + alias(libs.plugins.nowinandroid.hilt) } android { diff --git a/sync/work/build.gradle.kts b/sync/work/build.gradle.kts index 7e61c7389..7b4b55a18 100644 --- a/sync/work/build.gradle.kts +++ b/sync/work/build.gradle.kts @@ -16,7 +16,7 @@ plugins { alias(libs.plugins.nowinandroid.android.library) alias(libs.plugins.nowinandroid.android.library.jacoco) - alias(libs.plugins.nowinandroid.android.hilt) + alias(libs.plugins.nowinandroid.hilt) } android { @@ -34,6 +34,7 @@ dependencies { implementation(libs.hilt.ext.work) implementation(projects.core.analytics) implementation(projects.core.data) + implementation(projects.core.notifications) prodImplementation(libs.firebase.cloud.messaging) prodImplementation(platform(libs.firebase.bom)) diff --git a/sync/work/src/main/kotlin/com/google/samples/apps/nowinandroid/sync/initializers/SyncWorkHelpers.kt b/sync/work/src/main/kotlin/com/google/samples/apps/nowinandroid/sync/initializers/SyncWorkHelpers.kt index 843510aaf..6c4a29373 100644 --- a/sync/work/src/main/kotlin/com/google/samples/apps/nowinandroid/sync/initializers/SyncWorkHelpers.kt +++ b/sync/work/src/main/kotlin/com/google/samples/apps/nowinandroid/sync/initializers/SyncWorkHelpers.kt @@ -71,7 +71,7 @@ private fun Context.syncWorkNotification(): Notification { SYNC_NOTIFICATION_CHANNEL_ID, ) .setSmallIcon( - com.google.samples.apps.nowinandroid.core.common.R.drawable.core_common_ic_nia_notification, + com.google.samples.apps.nowinandroid.core.notifications.R.drawable.core_notifications_ic_nia_notification, ) .setContentTitle(getString(R.string.sync_work_notification_title)) .setPriority(NotificationCompat.PRIORITY_DEFAULT) diff --git a/ui-test-hilt-manifest/build.gradle.kts b/ui-test-hilt-manifest/build.gradle.kts index f41482814..3f084c6df 100644 --- a/ui-test-hilt-manifest/build.gradle.kts +++ b/ui-test-hilt-manifest/build.gradle.kts @@ -15,7 +15,7 @@ */ plugins { alias(libs.plugins.nowinandroid.android.library) - alias(libs.plugins.nowinandroid.android.hilt) + alias(libs.plugins.nowinandroid.hilt) } android {