Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Gradle Plugin for configuring Hilt in different modules #5

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ plugins {
id 'org.jetbrains.kotlin.android'
id "org.jlleitschuh.gradle.ktlint"
// Hilt doesn't supports KSP yet
id 'kotlin-kapt'
id 'com.google.dagger.hilt.android'
id("com.google.devtools.ksp")
id 'com.raghav.hiltplugin'
}

android {
Expand Down Expand Up @@ -101,11 +100,7 @@ dependencies {
implementation("com.squareup.retrofit2:converter-moshi:$retrofit_version")
implementation "com.squareup.okhttp3:okhttp:$okhttp_version"

// Hilt
def hilt_version = "2.47"
def hilt_navigation_compose = "1.0.0"
implementation "com.google.dagger:hilt-android:$hilt_version"
kapt "com.google.dagger:hilt-compiler:$hilt_version"
implementation "androidx.hilt:hilt-navigation-compose:$hilt_navigation_compose"

// Testing coroutines
Expand Down Expand Up @@ -135,7 +130,3 @@ dependencies {
androidTestImplementation "com.google.truth:truth:1.1.4"

}

kapt {
correctErrorTypes true
}
17 changes: 17 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
plugins {
`kotlin-dsl`
}

repositories {
mavenCentral()
}

gradlePlugin {
plugins {
create("HiltPlugin") {
id = "com.raghav.hiltplugin"
implementationClass = "HiltPlugin"
version = "1.0.0"
}
}
}
12 changes: 12 additions & 0 deletions buildSrc/src/main/java/HiltPlugin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import org.gradle.api.Plugin
import org.gradle.api.Project

class HiltPlugin : Plugin<Project> {

override fun apply(target: Project) {
target.plugins.apply("com.google.dagger.hilt.android")
target.plugins.apply("kotlin-kapt")
target.dependencies.add("implementation", "com.google.dagger:hilt-android:2.47")
target.dependencies.add("kapt", "com.google.dagger:hilt-compiler:2.47")
}
}
11 changes: 1 addition & 10 deletions data/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ plugins {
id 'org.jetbrains.kotlin.android'
id "org.jlleitschuh.gradle.ktlint"
id("com.google.devtools.ksp")
id "kotlin-kapt"
id 'com.google.dagger.hilt.android'
id 'com.raghav.hiltplugin'
}

android {
Expand Down Expand Up @@ -67,10 +66,6 @@ dependencies {
implementation "com.squareup.okhttp3:okhttp:5.0.0-alpha.2"
implementation "com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.2"

// Hilt
implementation "com.google.dagger:hilt-android:2.47"
kapt "com.google.dagger:hilt-compiler:2.47"

// Room
implementation "androidx.room:room-runtime:2.5.1"
ksp "androidx.room:room-compiler:2.5.1"
Expand All @@ -91,7 +86,3 @@ dependencies {

androidTestImplementation "androidx.arch.core:core-testing:2.1.0"
}

kapt {
correctErrorTypes true
}
Loading