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

Composite build pt-ii #49

Draft
wants to merge 2 commits into
base: composite_builds
Choose a base branch
from
Draft
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
4 changes: 4 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
22 changes: 0 additions & 22 deletions buildSrc/build.gradle.kts

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ dependencies {
UnitTesting.list.forEach(::testImplementation)
DevDependencies.debugList.forEach(::debugImplementation)
DevDependencies.list.forEach(::implementation)
}
}
40 changes: 1 addition & 39 deletions data/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand Down
46 changes: 46 additions & 0 deletions dependencies/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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")
}
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class AppModule : BaseAndroidPlugin() {
":data",
":domain",
":common",

)
)

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
47 changes: 47 additions & 0 deletions dependencies/src/main/kotlin/gradle/plugins/DataModule.kt
Original file line number Diff line number Diff line change
@@ -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<LibraryExtension>().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)
}
}
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Root module
include(":app")
includeBuild("dependencies")

// Feature modules
include(":ui-onboarding")
Expand Down