Skip to content

Commit

Permalink
Merge pull request #90 from skydoves/fix/hilt-databinding
Browse files Browse the repository at this point in the history
Fix hilt couldn't resolve generated classes from databinding
  • Loading branch information
skydoves authored Oct 7, 2023
2 parents fa8066f + 7cf1c82 commit 4534f7d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import com.android.build.gradle.internal.tasks.databinding.DataBindingGenBaseClassesTask
import com.skydoves.pokedex.Configuration
import org.gradle.configurationcache.extensions.capitalized
import org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompileTool

@Suppress("DSL_SCOPE_VIOLATION")
plugins {
id(libs.plugins.android.application.get().pluginId)
id(libs.plugins.kotlin.android.get().pluginId)
id(libs.plugins.kotlin.kapt.get().pluginId)
id(libs.plugins.ksp.get().pluginId)
id(libs.plugins.kotlin.parcelize.get().pluginId)
id(libs.plugins.hilt.plugin.get().pluginId)
Expand Down Expand Up @@ -78,6 +82,20 @@ android {
}
}

androidComponents {
onVariants(selector().all()) { variant ->
afterEvaluate {
val dataBindingTask =
project.tasks.findByName("dataBindingGenBaseClasses" + variant.name.capitalized()) as? DataBindingGenBaseClassesTask
if (dataBindingTask != null) {
project.tasks.getByName("ksp" + variant.name.capitalized() + "Kotlin") {
(this as AbstractKotlinCompileTool<*>).setSource(dataBindingTask.sourceOutFolder)
}
}
}
}
}

dependencies {
// modules
implementation(projects.coreData)
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ android-application = { id = "com.android.application", version.ref = "agp" }
android-library = { id = "com.android.library", version.ref = "agp" }
android-test = { id = "com.android.test", version.ref = "agp" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
Expand Down

0 comments on commit 4534f7d

Please sign in to comment.