Skip to content

Commit f3b2655

Browse files
authored
Merge pull request #933 from danysantiago/main
Update to Hilt 2.48 and use the KSP version
2 parents 3f22248 + c908f98 commit f3b2655

File tree

12 files changed

+66
-40
lines changed

12 files changed

+66
-40
lines changed

.github/ci-gradle.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ org.gradle.parallel=true
1919
org.gradle.workers.max=2
2020

2121
kotlin.incremental=false
22-
kotlin.compiler.execution.strategy=in-process
2322

2423
# Controls KotlinOptions.allWarningsAsErrors.
2524
# This value used in CI and is currently set to false.

app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,6 @@ dependencies {
130130
testImplementation(libs.accompanist.testharness)
131131
testImplementation(libs.work.testing)
132132
testImplementation(kotlin("test"))
133-
kaptTest(libs.hilt.compiler)
133+
kspTest(libs.hilt.compiler)
134134

135135
}

build-logic/convention/src/main/kotlin/AndroidHiltConventionPlugin.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,15 @@ class AndroidHiltConventionPlugin : Plugin<Project> {
2323
override fun apply(target: Project) {
2424
with(target) {
2525
with(pluginManager) {
26+
apply("com.google.devtools.ksp")
2627
apply("dagger.hilt.android.plugin")
27-
// KAPT must go last to avoid build warnings.
28-
// See: https://stackoverflow.com/questions/70550883/warning-the-following-options-were-not-recognized-by-any-processor-dagger-f
29-
apply("org.jetbrains.kotlin.kapt")
3028
}
3129

3230
dependencies {
3331
"implementation"(libs.findLibrary("hilt.android").get())
34-
"kapt"(libs.findLibrary("hilt.compiler").get())
35-
"kaptAndroidTest"(libs.findLibrary("hilt.compiler").get())
36-
"kaptTest"(libs.findLibrary("hilt.compiler").get())
32+
"ksp"(libs.findLibrary("hilt.compiler").get())
33+
"kspAndroidTest"(libs.findLibrary("hilt.compiler").get())
34+
"kspTest"(libs.findLibrary("hilt.compiler").get())
3735
}
3836

3937
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright 2023 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
plugins {
18+
alias(libs.plugins.nowinandroid.android.library)
19+
alias(libs.plugins.protobuf)
20+
}
21+
22+
android {
23+
namespace = "com.google.samples.apps.nowinandroid.core.datastore.proto"
24+
}
25+
26+
// Setup protobuf configuration, generating lite Java and Kotlin classes
27+
protobuf {
28+
protoc {
29+
artifact = libs.protobuf.protoc.get().toString()
30+
}
31+
generateProtoTasks {
32+
all().forEach { task ->
33+
task.builtins {
34+
register("java") {
35+
option("lite")
36+
}
37+
register("kotlin") {
38+
option("lite")
39+
}
40+
}
41+
}
42+
}
43+
}
44+
45+
androidComponents.beforeVariants {
46+
android.sourceSets.register(it.name) {
47+
val buildDir = layout.buildDirectory.get().asFile
48+
java.srcDir(buildDir.resolve("generated/source/proto/${it.name}/java"))
49+
kotlin.srcDir(buildDir.resolve("generated/source/proto/${it.name}/kotlin"))
50+
}
51+
}
52+
53+
dependencies {
54+
implementation(libs.protobuf.kotlin.lite)
55+
}

core/datastore/src/main/proto/com/google/samples/apps/nowinandroid/data/dark_theme_config.proto renamed to core/datastore-proto/src/main/proto/com/google/samples/apps/nowinandroid/data/dark_theme_config.proto

File renamed without changes.

core/datastore/src/main/proto/com/google/samples/apps/nowinandroid/data/theme_brand.proto renamed to core/datastore-proto/src/main/proto/com/google/samples/apps/nowinandroid/data/theme_brand.proto

File renamed without changes.

core/datastore/src/main/proto/com/google/samples/apps/nowinandroid/data/user_preferences.proto renamed to core/datastore-proto/src/main/proto/com/google/samples/apps/nowinandroid/data/user_preferences.proto

File renamed without changes.

core/datastore/build.gradle.kts

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ plugins {
1818
alias(libs.plugins.nowinandroid.android.library)
1919
alias(libs.plugins.nowinandroid.android.library.jacoco)
2020
alias(libs.plugins.nowinandroid.android.hilt)
21-
alias(libs.plugins.protobuf)
2221
}
2322

2423
android {
@@ -33,34 +32,8 @@ android {
3332
}
3433
}
3534

36-
// Setup protobuf configuration, generating lite Java and Kotlin classes
37-
protobuf {
38-
protoc {
39-
artifact = libs.protobuf.protoc.get().toString()
40-
}
41-
generateProtoTasks {
42-
all().forEach { task ->
43-
task.builtins {
44-
register("java") {
45-
option("lite")
46-
}
47-
register("kotlin") {
48-
option("lite")
49-
}
50-
}
51-
}
52-
}
53-
}
54-
55-
androidComponents.beforeVariants {
56-
android.sourceSets.register(it.name) {
57-
val buildDir = layout.buildDirectory.get().asFile
58-
java.srcDir(buildDir.resolve("generated/source/proto/${it.name}/java"))
59-
kotlin.srcDir(buildDir.resolve("generated/source/proto/${it.name}/kotlin"))
60-
}
61-
}
62-
6335
dependencies {
36+
api(projects.core.datastoreProto)
6437
implementation(projects.core.common)
6538
implementation(projects.core.model)
6639
implementation(libs.androidx.dataStore.core)

core/domain/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
plugins {
1717
alias(libs.plugins.nowinandroid.android.library)
1818
alias(libs.plugins.nowinandroid.android.library.jacoco)
19-
kotlin("kapt")
19+
id("com.google.devtools.ksp")
2020
}
2121

2222
android {
@@ -30,7 +30,7 @@ dependencies {
3030
implementation(libs.kotlinx.coroutines.android)
3131
implementation(libs.kotlinx.datetime)
3232

33-
kapt(libs.hilt.compiler)
33+
ksp(libs.hilt.compiler)
3434

3535
testImplementation(projects.core.testing)
3636
}

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ gmsPlugin = "4.4.0"
3737
googleOss = "17.0.1"
3838
googleOssPlugin = "0.10.6"
3939
hilt = "2.48.1"
40-
hiltExt = "1.0.0"
40+
hiltExt = "1.1.0"
4141
jacoco = "0.8.7"
4242
junit4 = "4.13.2"
4343
kotlin = "1.9.10"

0 commit comments

Comments
 (0)