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

RFC - Move to CompositeBuilds from buildSrc (WIP) #37

Open
wants to merge 6 commits into
base: baseproject
Choose a base branch
from
Open
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
132 changes: 1 addition & 131 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,105 +1,5 @@
// Manifest version information!

plugins {
id(BuildPlugins.ANDROID_APPLICATION_PLUGIN)
id(BuildPlugins.KOTLIN_ANDROID_PLUGIN)
id(BuildPlugins.KOTLIN_PARCELABLE_PLUGIN)
id(BuildPlugins.KOTLIN_KAPT)
id(BuildPlugins.DAGGER_HILT)
id(BuildPlugins.ktLint)
}

// def preDexEnabled = "true" == System.getProperty("pre-dex", "true")

android {
compileSdk = (AppVersions.COMPILE_SDK)

defaultConfig {
applicationId = (AppVersions.APPLICATION_ID)
minSdk = (AppVersions.MIN_SDK)
targetSdk = (AppVersions.TARGET_SDK)
versionCode = AppVersions.versionCode
versionName = AppVersions.versionName
testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true

javaCompileOptions {
annotationProcessorOptions {
arguments += mapOf(
"room.schemaLocation" to "$projectDir/schemas",
"room.incremental" to "true",
"room.expandProjection" to "true"
)
}
}
}

signingConfigs {

getByName("debug") {
keyAlias = "praxis-debug"
keyPassword = "utherNiC"
storeFile = file("keystore/praxis-debug.jks")
storePassword = "uRgeSCIt"
}

create("release") {
keyAlias = "praxis-release"
keyPassword = "ITHOmptI"
storeFile = file("keystore/praxis-release.jks")
storePassword = "PoTHatHR"
}

}
buildTypes {
getByName("release") {
isDebuggable = false
versionNameSuffix = "-release"

isMinifyEnabled = true
isShrinkResources = true

proguardFiles(
getDefaultProguardFile("proguard-android.txt"), "proguard-common.txt",
"proguard-specific.txt"
)
signingConfig = signingConfigs.getByName("release")
}
getByName("debug") {
isDebuggable = true
versionNameSuffix = "-debug"
applicationIdSuffix = ".debug"
signingConfig = signingConfigs.getByName("debug")
}
}

buildFeatures {
dataBinding = true
}

buildFeatures {
compose = true
}

composeOptions {
kotlinCompilerExtensionVersion = Lib.Androidx.composeVersion
}

packagingOptions {
resources.excludes.add("META-INF/LICENSE.txt")
resources.excludes.add("META-INF/NOTICE.txt")
resources.excludes.add("LICENSE.txt")
resources.excludes.add( "/META-INF/{AL2.0,LGPL2.1}")
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = "1.8"
}
id("AppModule")
}

// Required for annotation processing plugins like Dagger
Expand All @@ -108,7 +8,6 @@ kapt {
correctErrorTypes = true
}


hilt {
// The Hilt configuration option 'enableTransformForLocalTests'
// is no longer necessary when com.android.tools.build:gradle:4.2.0+ is used.
Expand All @@ -122,36 +21,7 @@ hilt {
}

dependencies {


Lib.Androidx.list.forEach(::api)
Lib.Androidx.Compose.list.forEach(::api)
Lib.ThirdParty.list.forEach(::api)
Lib.Accompanist.list.forEach(::api)
Lib.Google.list.forEach(::api)
Lib.Kotlin.list.forEach(::api)

api(project(":ui-onboarding"))
api(project(":ui-authentication"))
api(project(":navigator"))
api(project(":data"))
api(project(":domain"))
api(project(":common"))
api(project(":commonui"))

/*DI*/
api(Lib.Di.hilt)
api(Lib.Di.hiltNavigationCompose)
api(Lib.Di.viewmodel)
kapt(Lib.Di.hiltCompiler)
kapt(Lib.Di.hiltAndroidCompiler)

// Room
api(Lib.Room.roomKtx)
api(Lib.Room.roomRuntime)
add("kapt", Lib.Room.roomCompiler)
testApi(Lib.Room.testing)

UnitTesting.list.forEach(::testApi)
DevDependencies.debugList.forEach(::debugApi)
DevDependencies.list.forEach(::api)
Expand Down
11 changes: 0 additions & 11 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,6 @@ buildscript {
google()
maven("https://plugins.gradle.org/m2/")
}
dependencies {
classpath(BuildPlugins.TOOLS_BUILD_GRADLE)
classpath(BuildPlugins.SAFE_ARGS_GRADLE_PLUGIN)
classpath(BuildPlugins.DAGGER_HILT_PLUGIN)
classpath(BuildPlugins.KOTLIN_GRADLE_PLUGIN)
classpath(kotlin("serialization", version = Lib.Kotlin.KOTLIN_VERSION))
classpath(BuildPlugins.KTLINT_GRADLE_PLUGIN)
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
Expand Down
21 changes: 18 additions & 3 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
plugins {
`kotlin-dsl`
}

repositories {
mavenCentral()
jcenter()
google()
maven("https://plugins.gradle.org/m2/")
}

plugins {
`kotlin-dsl`
}

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())
}
3 changes: 2 additions & 1 deletion buildSrc/src/main/kotlin/AppVersions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ object AppVersions {
const val versionCode = versionMajor * 10000 + versionMinor * 100 + versionPatch
const val versionName = "$versionMajor.$versionMinor.$versionPatch"

const val COMPILE_SDK = 31
const val COMPILE_SDK = "android-31"
const val BUILD_TOOLS = "31.0.0"
const val MIN_SDK = 21
const val TARGET_SDK = 31
const val APPLICATION_ID = "com.mutualmobile.praxis"
Expand Down
24 changes: 8 additions & 16 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
/** This file contains versions of all the dependencies used in the module */

object BuildPlugins {
private const val TOOLS_BUILD = "7.1.0"
private const val KT_LINT = "9.2.1"
private const val SAFE_ARGS = "2.3.5"

const val TOOLS_BUILD_GRADLE = "com.android.tools.build:gradle:${TOOLS_BUILD}"
const val KTLINT_GRADLE_PLUGIN = "org.jlleitschuh.gradle:ktlint-gradle:${KT_LINT}"
const val SAFE_ARGS_GRADLE_PLUGIN =
"androidx.navigation:navigation-safe-args-gradle-plugin:${SAFE_ARGS}"
const val DAGGER_HILT_PLUGIN = "com.google.dagger:hilt-android-gradle-plugin:2.38.1"
const val KOTLIN_GRADLE_PLUGIN = "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
const val ANDROID_APPLICATION_PLUGIN = "com.android.application"
const val ANDROID_LIBRARY_PLUGIN = "com.android.library"
const val KOTLIN_ANDROID_PLUGIN = "kotlin-android"
const val KOTLIN_PARCELABLE_PLUGIN = "kotlin-parcelize"
const val KOTLIN_KAPT = "kotlin-kapt"
const val DAGGER_HILT = "dagger.hilt.android.plugin"
const val ktLint = "org.jlleitschuh.gradle.ktlint"
const val SAFE_ARGS_KOTLIN = "androidx.navigation.safeargs.kotlin"
const val JAVA_LIB = "java-library"
const val KOTLIN_JVM = "org.jetbrains.kotlin.jvm"
}

object Lib {
Expand All @@ -29,11 +18,13 @@ object Lib {
private const val KTX_CORE = "androidx.core:core-ktx:${KTX_CORE_VERSION}"
private const val DATE_TIME = "org.jetbrains.kotlinx:kotlinx-datetime:0.3.2"

private const val COROUTINES = "org.jetbrains.kotlinx:kotlinx-coroutines-core:${KOTLIN_VERSION}"
const val COROUTINES = "org.jetbrains.kotlinx:kotlinx-coroutines-core:${KOTLIN_VERSION}"
private const val COROUTINES_ANDROID =
"org.jetbrains.kotlinx:kotlinx-coroutines-android:${KOTLIN_VERSION}"

val list = listOf(KT_STD, KTX_CORE, DATE_TIME, COROUTINES, COROUTINES_ANDROID)
val kotlinList = listOf(KT_STD, KTX_CORE, DATE_TIME, COROUTINES)
val androidList = kotlinList + listOf(COROUTINES_ANDROID)

}

object Google {
Expand Down Expand Up @@ -96,7 +87,7 @@ object Lib {
const val hilt = "com.google.dagger:hilt-android:${DAGGER_VERSION}"
const val hiltAndroidCompiler = "com.google.dagger:hilt-android-compiler:${DAGGER_VERSION}"

const val viewmodel = "androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03"
const val hiltViewModel = "androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03"
const val hiltCompiler = "androidx.hilt:hilt-compiler:1.0.0"
const val hiltNavigationCompose = "androidx.hilt:hilt-navigation-compose:1.0.0-rc01"
}
Expand All @@ -105,6 +96,7 @@ object Lib {
private const val PAGING_VERSION = "3.1.0"
const val PAGING_3 = "androidx.paging:paging-runtime:${PAGING_VERSION}"
const val PAGING_COMPOSE = "androidx.paging:paging-compose:1.0.0-alpha14"
const val PAGING_COMMON = "androidx.paging:paging-common-ktx:${PAGING_VERSION}"
}

object Room {
Expand Down
89 changes: 89 additions & 0 deletions buildSrc/src/main/kotlin/Extensions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import org.gradle.api.Project
import org.gradle.api.artifacts.dsl.DependencyHandler
import org.gradle.api.artifacts.dsl.RepositoryHandler
import org.gradle.api.artifacts.repositories.MavenArtifactRepository
import org.gradle.kotlin.dsl.ScriptHandlerScope
import org.gradle.kotlin.dsl.maven

fun RepositoryHandler.maven(repoUrl: String): MavenArtifactRepository {
return maven(repoUrl)
}

fun Project.repositoriesFrom(listOfRepos: Collection<String>): Project =
also {

repositories.run {
listOfRepos.forEach { repo ->
maven(repo)
}
}
}

fun Project.implementationDependenciesFrom(listOfDeps: Collection<String>): Project =
also {
dependencies.run {
listOfDeps.forEach { dep ->
implementation(dep)
}
}
}

fun Project.implementationProjectsFrom(listOfDeps: Collection<String>): Project =
also {
dependencies.run {
listOfDeps.forEach { dep ->
implementation(project(":${dep}"))
}
}
}

fun Project.annotationProcessors(listOfDeps: Collection<String>): Project =
also {
dependencies.run {
listOfDeps.forEach { dep ->
kapt(dep)
}
}
}

fun ScriptHandlerScope.repositoriesFrom(listOfRepos: Collection<String>) {
repositories.run {
listOfRepos.forEach { repo ->
maven(repo)
}
}
}

fun ScriptHandlerScope.dependenciesFrom(listOfDeps: List<String>) {
dependencies.run {
listOfDeps.forEach { repo ->
classpath(repo)
}
}
}

fun DependencyHandler.implementation(dependency: Any) {
add("implementation", dependency)
}

fun DependencyHandler.androidTestImplementation(dependency: Any) {
add("androidTestImplementation", dependency)
}

fun DependencyHandler.testImplementation(dependency: Any) {
add("testImplementation", dependency)
}

fun DependencyHandler.kapt(dependency: Any) {
add("kapt", dependency)
}

fun DependencyHandler.kaptTest(dependency: Any) {
add("kaptTest", dependency)
}

fun DependencyHandler.kaptAndroidTest(dependency: Any) {
add("kaptAndroidTest", dependency)
}


Loading