A fully functional Android app built entirely with Kotlin and Jetpack Compose
Prep work for JVM alternatives to modules/plugins
Simon Marquis4f8f08380fb3
diff --git a/build-logic/convention/build.gradle.kts b/build-logic/convention/build.gradle.ktsindex aa0e615ad..cf351846e 100644--- a/build-logic/convention/build.gradle.kts+++ b/build-logic/convention/build.gradle.kts@@ -110,5 +110,9 @@ gradlePlugin {id = "nowinandroid.jvm.library"implementationClass = "JvmLibraryConventionPlugin"}+ register("jvmHilt") {+ id = "nowinandroid.jvm.hilt"+ implementationClass = "JvmHiltConventionPlugin"+ }}}diff --git a/build-logic/convention/src/main/kotlin/AndroidHiltConventionPlugin.kt b/build-logic/convention/src/main/kotlin/AndroidHiltConventionPlugin.ktindex fcb4f823e..c4fd1b3d0 100644--- a/build-logic/convention/src/main/kotlin/AndroidHiltConventionPlugin.kt+++ b/build-logic/convention/src/main/kotlin/AndroidHiltConventionPlugin.kt@@ -14,25 +14,14 @@* limitations under the License.*/-import com.google.samples.apps.nowinandroid.libs-import org.gradle.api.Plugin-import org.gradle.api.Project-import org.gradle.kotlin.dsl.dependencies+import org.gradle.api.artifacts.VersionCatalog+import org.gradle.kotlin.dsl.DependencyHandlerScope-class AndroidHiltConventionPlugin : Plugin<Project> {- override fun apply(target: Project) {- with(target) {- with(pluginManager) {- apply("com.google.devtools.ksp")- apply("dagger.hilt.android.plugin")- }-- dependencies {- "implementation"(libs.findLibrary("hilt.android").get())- "ksp"(libs.findLibrary("hilt.compiler").get())- }-- }+class AndroidHiltConventionPlugin : HiltConventionPlugin() {+ override val basePluginId = "dagger.hilt.android.plugin"+ override fun DependencyHandlerScope.additionalDependencies(libs: VersionCatalog) {+ "implementation"(libs.findLibrary("hilt.android").get())+ "kspAndroidTest"(libs.findLibrary("hilt.compiler").get())+ "kspTest"(libs.findLibrary("hilt.compiler").get())}-}diff --git a/build-logic/convention/src/main/kotlin/HiltConventionPlugin.kt b/build-logic/convention/src/main/kotlin/HiltConventionPlugin.ktnew file mode 100644index 000000000..1a596d87f--- /dev/null+++ b/build-logic/convention/src/main/kotlin/HiltConventionPlugin.kt@@ -0,0 +1,39 @@+/*+ * 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.+ * You may obtain a copy of the License at+ *+ * https://www.apache.org/licenses/LICENSE-2.0+ *+ * 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.+ */++import com.google.samples.apps.nowinandroid.libs+import org.gradle.api.Plugin+import org.gradle.api.Project+import org.gradle.api.artifacts.VersionCatalog+import org.gradle.kotlin.dsl.DependencyHandlerScope+import org.gradle.kotlin.dsl.dependencies++abstract class HiltConventionPlugin : Plugin<Project> {+ open val basePluginId: String? = null+ protected abstract fun DependencyHandlerScope.additionalDependencies(libs: VersionCatalog)+ override fun apply(target: Project) {+ with(target) {+ with(pluginManager) {+ basePluginId?.let(::apply)+ apply("com.google.devtools.ksp")+ }+ dependencies {+ "ksp"(libs.findLibrary("hilt.compiler").get())+ additionalDependencies(libs)+ }+ }+ }+}diff --git a/build-logic/convention/src/main/kotlin/JvmHiltConventionPlugin.kt b/build-logic/convention/src/main/kotlin/JvmHiltConventionPlugin.ktnew file mode 100644index 000000000..be4c9a61d--- /dev/null+++ b/build-logic/convention/src/main/kotlin/JvmHiltConventionPlugin.kt@@ -0,0 +1,24 @@+/*+ * 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.+ * You may obtain a copy of the License at+ *+ * https://www.apache.org/licenses/LICENSE-2.0+ *+ * 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.+ */++import org.gradle.api.artifacts.VersionCatalog+import org.gradle.kotlin.dsl.DependencyHandlerScope++class JvmHiltConventionPlugin : HiltConventionPlugin() {+ override fun DependencyHandlerScope.additionalDependencies(libs: VersionCatalog) {+ "implementation"(libs.findLibrary("hilt.core").get())+ }+}\ No newline at end of filediff --git a/core/datastore/build.gradle.kts b/core/datastore/build.gradle.ktsindex 34ea5ee78..725396ac4 100644--- a/core/datastore/build.gradle.kts+++ b/core/datastore/build.gradle.kts@@ -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/gradle/libs.versions.toml b/gradle/libs.versions.tomlindex 795510bce..9a1e92e84 100644--- a/gradle/libs.versions.toml+++ b/gradle/libs.versions.toml@@ -79,7 +79,8 @@ androidx-compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "uandroidx-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-viewModelCompose = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-compose", version.ref = "androidxLifecycle" }@@ -109,10 +110,13 @@ google-oss-licenses-plugin = { group = "com.google.android.gms", name = "oss-lichilt-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-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" }