diff --git a/build.gradle.kts b/build.gradle.kts index c396e5d..ffb844d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,8 +3,12 @@ buildscript { repositories { google() + mavenCentral() maven("https://plugins.gradle.org/m2/") } + dependencies{ + classpath("com.android.tools.build:gradle:7.1.3") + } } allprojects { diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts deleted file mode 100644 index aa772a7..0000000 --- a/buildSrc/build.gradle.kts +++ /dev/null @@ -1,22 +0,0 @@ -plugins { - `kotlin-dsl` -} - -repositories { - mavenCentral() - jcenter() - google() - maven("https://plugins.gradle.org/m2/") -} - - -dependencies{ - implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10") - implementation("com.android.tools.build:gradle:7.1.1") - implementation("com.google.dagger:hilt-android-gradle-plugin:2.40.5") - implementation("org.jlleitschuh.gradle:ktlint-gradle:9.2.1") - - /* Depend on the default Gradle API's since we want to build a custom plugin */ - implementation(gradleApi()) - implementation(localGroovy()) -} \ No newline at end of file diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/AppModule.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/AppModule.properties deleted file mode 100644 index 1c8207a..0000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/AppModule.properties +++ /dev/null @@ -1 +0,0 @@ -implementation-class=gradle.plugins.AppModule \ No newline at end of file diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/CommonModule.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/CommonModule.properties deleted file mode 100644 index bb7e60b..0000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/CommonModule.properties +++ /dev/null @@ -1 +0,0 @@ -implementation-class=gradle.plugins.CommonModule \ No newline at end of file diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/FeatureModule.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/FeatureModule.properties deleted file mode 100644 index 54e499d..0000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/FeatureModule.properties +++ /dev/null @@ -1 +0,0 @@ -implementation-class=gradle.plugins.FeatureModule \ No newline at end of file diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/KotlinModule.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/KotlinModule.properties deleted file mode 100644 index 1f074e4..0000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/KotlinModule.properties +++ /dev/null @@ -1 +0,0 @@ -implementation-class=gradle.plugins.KotlinModule \ No newline at end of file diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 5e53d11..6579f0d 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -12,4 +12,4 @@ dependencies { UnitTesting.list.forEach(::testImplementation) DevDependencies.debugList.forEach(::debugImplementation) DevDependencies.list.forEach(::implementation) -} \ No newline at end of file +} diff --git a/data/build.gradle.kts b/data/build.gradle.kts index 203063d..fd0302b 100644 --- a/data/build.gradle.kts +++ b/data/build.gradle.kts @@ -1,25 +1,5 @@ plugins { - id(BuildPlugins.ANDROID_LIBRARY_PLUGIN) - id(BuildPlugins.KOTLIN_ANDROID_PLUGIN) - id(BuildPlugins.KOTLIN_KAPT) - id(BuildPlugins.DAGGER_HILT) -} - -android { - compileSdk = 31 - - defaultConfig { - minSdk = (AppVersions.MIN_SDK) - targetSdk = (AppVersions.TARGET_SDK) - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - - buildTypes { - getByName("release") { - isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") - } - } + id("DataModule") } // Required for annotation processing plugins like Dagger @@ -29,24 +9,6 @@ kapt { } dependencies { - implementation(project(":common")) - implementation(project(":domain")) - - Lib.Kotlin.androidList.forEach(::implementation) - Lib.Networking.ktorList.forEach(::implementation) - /*DI*/ - implementation(Lib.Di.hilt) - implementation(Lib.Di.hiltNavigationCompose) - implementation(Lib.Di.hiltViewModel) - kapt(Lib.Di.hiltCompiler) - kapt(Lib.Di.hiltAndroidCompiler) - - // Room - implementation(Lib.Room.roomKtx) - implementation(Lib.Room.roomRuntime) - add("kapt", Lib.Room.roomCompiler) - testImplementation(Lib.Room.testing) - UnitTesting.list.forEach(::testImplementation) DevDependencies.debugList.forEach(::debugImplementation) DevDependencies.list.forEach(::implementation) diff --git a/dependencies/build.gradle.kts b/dependencies/build.gradle.kts new file mode 100644 index 0000000..fcd6784 --- /dev/null +++ b/dependencies/build.gradle.kts @@ -0,0 +1,46 @@ +plugins { + `kotlin-dsl` + `java-gradle-plugin` +} + +repositories { + mavenCentral() + google() + maven("https://plugins.gradle.org/m2/") +} + +gradlePlugin { + plugins { + register("appModule") { + id = "AppModule" + implementationClass = "gradle.plugins.AppModule" + } + register("commonModule") { + id = "CommonModule" + implementationClass = "gradle.plugins.CommonModule" + } + register("dataModule") { + id = "DataModule" + implementationClass = "gradle.plugins.DataModule" + } + register("featureModule") { + id = "FeatureModule" + implementationClass = "gradle.plugins.FeatureModule" + } + register("kotlinModule") { + id = "KotlinModule" + implementationClass = "gradle.plugins.KotlinModule" + } + } +} + +dependencies { + /* Depend on the default Gradle API's since we want to build a custom plugin */ + implementation(gradleApi()) + implementation(localGroovy()) + + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10") + implementation("com.android.tools.build:gradle:7.1.3") +// implementation("com.google.dagger:hilt-android-gradle-plugin:2.40.5") +// implementation("org.jlleitschuh.gradle:ktlint-gradle:9.2.1") +} diff --git a/dependencies/settings.gradle.kts b/dependencies/settings.gradle.kts new file mode 100644 index 0000000..e69de29 diff --git a/buildSrc/src/main/kotlin/AppVersions.kt b/dependencies/src/main/kotlin/AppVersions.kt similarity index 100% rename from buildSrc/src/main/kotlin/AppVersions.kt rename to dependencies/src/main/kotlin/AppVersions.kt diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/dependencies/src/main/kotlin/Dependencies.kt similarity index 100% rename from buildSrc/src/main/kotlin/Dependencies.kt rename to dependencies/src/main/kotlin/Dependencies.kt diff --git a/buildSrc/src/main/kotlin/Extensions.kt b/dependencies/src/main/kotlin/Extensions.kt similarity index 100% rename from buildSrc/src/main/kotlin/Extensions.kt rename to dependencies/src/main/kotlin/Extensions.kt diff --git a/buildSrc/src/main/kotlin/gradle/plugins/AppModule.kt b/dependencies/src/main/kotlin/gradle/plugins/AppModule.kt similarity index 99% rename from buildSrc/src/main/kotlin/gradle/plugins/AppModule.kt rename to dependencies/src/main/kotlin/gradle/plugins/AppModule.kt index 18752d4..2ef4c66 100644 --- a/buildSrc/src/main/kotlin/gradle/plugins/AppModule.kt +++ b/dependencies/src/main/kotlin/gradle/plugins/AppModule.kt @@ -34,7 +34,6 @@ class AppModule : BaseAndroidPlugin() { ":data", ":domain", ":common", - ) ) diff --git a/buildSrc/src/main/kotlin/gradle/plugins/BasePlugins.kt b/dependencies/src/main/kotlin/gradle/plugins/BasePlugins.kt similarity index 91% rename from buildSrc/src/main/kotlin/gradle/plugins/BasePlugins.kt rename to dependencies/src/main/kotlin/gradle/plugins/BasePlugins.kt index 0a6ffd4..4c169c6 100644 --- a/buildSrc/src/main/kotlin/gradle/plugins/BasePlugins.kt +++ b/dependencies/src/main/kotlin/gradle/plugins/BasePlugins.kt @@ -1,6 +1,7 @@ package gradle.plugins -import com.android.build.gradle.* +import com.android.build.gradle.AppPlugin +import com.android.build.gradle.LibraryPlugin import implementationDependenciesFrom import org.gradle.api.Plugin import org.gradle.api.Project diff --git a/buildSrc/src/main/kotlin/gradle/plugins/CommonModule.kt b/dependencies/src/main/kotlin/gradle/plugins/CommonModule.kt similarity index 100% rename from buildSrc/src/main/kotlin/gradle/plugins/CommonModule.kt rename to dependencies/src/main/kotlin/gradle/plugins/CommonModule.kt diff --git a/dependencies/src/main/kotlin/gradle/plugins/DataModule.kt b/dependencies/src/main/kotlin/gradle/plugins/DataModule.kt new file mode 100644 index 0000000..27afc9b --- /dev/null +++ b/dependencies/src/main/kotlin/gradle/plugins/DataModule.kt @@ -0,0 +1,47 @@ +package gradle.plugins + +import annotationProcessors +import com.android.build.gradle.LibraryExtension +import implementationDependenciesFrom +import implementationProjectsFrom +import org.gradle.api.Project +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.getByType + +class DataModule : BaseAndroidPlugin() { + override fun apply(project: Project) { + appPlugins(project) + super.apply(project) + + dependencies(project) + } + + private fun dependencies(project: Project) { + project.implementationProjectsFrom( + listOf( + ":domain", + ":common" + ) + ) + + project.implementationDependenciesFrom( + roomImplDeps + hiltImplDeps + Lib.Kotlin.androidList + Lib.Kotlin.kotlinList + Lib.Networking.ktorList + ) + + project.annotationProcessors( + hiltKapt + listOf(Lib.Room.roomCompiler) + ) + + project.extensions.getByType().apply { + configureAndroidLibraryBlock(project) + } + } + + private fun appPlugins(project: Project) { + project.apply(plugin = BuildPlugins.KOTLIN_ANDROID_PLUGIN) + project.apply(plugin = BuildPlugins.ANDROID_LIBRARY_PLUGIN) + project.apply(plugin = BuildPlugins.KOTLIN_KAPT) + project.apply(plugin = BuildPlugins.DAGGER_HILT) + project.apply(plugin = BuildPlugins.ktLint) + } +} diff --git a/buildSrc/src/main/kotlin/gradle/plugins/Extensions.kt b/dependencies/src/main/kotlin/gradle/plugins/Extensions.kt similarity index 100% rename from buildSrc/src/main/kotlin/gradle/plugins/Extensions.kt rename to dependencies/src/main/kotlin/gradle/plugins/Extensions.kt diff --git a/buildSrc/src/main/kotlin/gradle/plugins/FeatureModule.kt b/dependencies/src/main/kotlin/gradle/plugins/FeatureModule.kt similarity index 100% rename from buildSrc/src/main/kotlin/gradle/plugins/FeatureModule.kt rename to dependencies/src/main/kotlin/gradle/plugins/FeatureModule.kt diff --git a/buildSrc/src/main/kotlin/gradle/plugins/KotlinModule.kt b/dependencies/src/main/kotlin/gradle/plugins/KotlinModule.kt similarity index 100% rename from buildSrc/src/main/kotlin/gradle/plugins/KotlinModule.kt rename to dependencies/src/main/kotlin/gradle/plugins/KotlinModule.kt diff --git a/settings.gradle.kts b/settings.gradle.kts index b1311e2..24d8796 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,5 +1,6 @@ // Root module include(":app") +includeBuild("dependencies") // Feature modules include(":ui-onboarding")