mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-17 23:47:02 +05:30
Merge #102
102: Gradle build improvements r=msfjarvis a=msfjarvis - Cleans up unnecessary dependencies - Skips configuring Dagger on modules where it's not needed - Hacks together a way to load buildSrc plugin dependencies from Kotlin sources bors r+ Co-authored-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
commit
43361b3a2a
6 changed files with 54 additions and 49 deletions
|
@ -1,18 +1,3 @@
|
||||||
buildscript {
|
|
||||||
apply(from = "buildSrc/buildDependencies.gradle")
|
|
||||||
val build: Map<Any, Any> by extra
|
|
||||||
repositories {
|
|
||||||
google()
|
|
||||||
jcenter()
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath(build.getValue("androidGradlePlugin"))
|
|
||||||
classpath(build.getValue("daggerGradlePlugin"))
|
|
||||||
classpath(build.getValue("kotlinGradlePlugin"))
|
|
||||||
classpath(build.getValue("sqldelightGradlePlugin"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("com.github.ben-manes.versions") version "0.36.0"
|
id("com.github.ben-manes.versions") version "0.36.0"
|
||||||
`lobsters-plugin`
|
`lobsters-plugin`
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
apply(from = "buildDependencies.gradle")
|
|
||||||
val build: Map<Any, Any> by extra
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
`kotlin-dsl`
|
`kotlin-dsl`
|
||||||
}
|
}
|
||||||
|
@ -32,12 +29,10 @@ gradlePlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(build.getValue("kotlinGradlePlugin"))
|
implementation(Plugins.androidGradlePlugin)
|
||||||
implementation(build.getValue("daggerGradlePlugin"))
|
implementation(Plugins.androidGradlePlugin_lintModel)
|
||||||
implementation(build.getValue("androidGradlePlugin"))
|
implementation(Plugins.daggerGradlePlugin)
|
||||||
implementation(build.getValue("androidGradlePlugin_builder"))
|
implementation(Plugins.jsemver)
|
||||||
implementation(build.getValue("androidGradlePlugin_builderModel"))
|
implementation(Plugins.kotlinGradlePlugin)
|
||||||
implementation(build.getValue("androidGradlePlugin_lintModel"))
|
implementation(Plugins.sqldelightGradlePlugin)
|
||||||
implementation(build.getValue("jsemver"))
|
|
||||||
implementation(build.getValue("sqldelightGradlePlugin"))
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
rootProject.ext.versions = [
|
|
||||||
agp : '7.0.0-alpha05',
|
|
||||||
daggerHilt: '2.31.2-alpha',
|
|
||||||
kotlin : '1.4.21',
|
|
||||||
lint : '30.0.0-alpha05',
|
|
||||||
semver : '0.9.0',
|
|
||||||
sqldelight: '1.4.4',
|
|
||||||
]
|
|
||||||
|
|
||||||
rootProject.ext.build = [
|
|
||||||
androidGradlePlugin : "com.android.tools.build:gradle:${versions.agp}",
|
|
||||||
androidGradlePlugin_builder : "com.android.tools.build:builder:${versions.agp}",
|
|
||||||
androidGradlePlugin_builderModel: "com.android.tools.build:builder-model:${versions.agp}",
|
|
||||||
androidGradlePlugin_lintModel : "com.android.tools.lint:lint-model:${versions.lint}",
|
|
||||||
daggerGradlePlugin : "com.google.dagger:hilt-android-gradle-plugin:${versions.daggerHilt}",
|
|
||||||
kotlinGradlePlugin : "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}",
|
|
||||||
jsemver : "com.github.zafarkhaja:java-semver:${versions.semver}",
|
|
||||||
sqldelightGradlePlugin : "com.squareup.sqldelight:gradle-plugin:${versions.sqldelight}",
|
|
||||||
]
|
|
21
buildSrc/buildSrc/build.gradle.kts
Normal file
21
buildSrc/buildSrc/build.gradle.kts
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
plugins {
|
||||||
|
`kotlin-dsl`
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
google()
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlinDslPluginOptions {
|
||||||
|
experimentalWarning.set(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
// force compilation of Dependencies.kt so it can be referenced in buildSrc/build.gradle.kts
|
||||||
|
sourceSets.main {
|
||||||
|
java {
|
||||||
|
setSrcDirs(setOf(projectDir.parentFile.resolve("src/main/java")))
|
||||||
|
include("Dependencies.kt")
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,6 +5,15 @@
|
||||||
|
|
||||||
private const val DAGGER_HILT_VERSION = "2.31.2-alpha"
|
private const val DAGGER_HILT_VERSION = "2.31.2-alpha"
|
||||||
|
|
||||||
|
object Plugins {
|
||||||
|
const val androidGradlePlugin = "com.android.tools.build:gradle:7.0.0-alpha05"
|
||||||
|
const val androidGradlePlugin_lintModel = "com.android.tools.lint:lint-model:30.0.0-alpha05"
|
||||||
|
const val daggerGradlePlugin = "com.google.dagger:hilt-android-gradle-plugin:${DAGGER_HILT_VERSION}"
|
||||||
|
const val kotlinGradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.21"
|
||||||
|
const val jsemver = "com.github.zafarkhaja:java-semver:0.9.0"
|
||||||
|
const val sqldelightGradlePlugin = "com.squareup.sqldelight:gradle-plugin:1.4.4"
|
||||||
|
}
|
||||||
|
|
||||||
object Dependencies {
|
object Dependencies {
|
||||||
const val COMPOSE_VERSION = "1.0.0-alpha10"
|
const val COMPOSE_VERSION = "1.0.0-alpha10"
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,24 @@ import org.jetbrains.kotlin.gradle.plugin.KaptExtension
|
||||||
internal fun Project.configureKapt() {
|
internal fun Project.configureKapt() {
|
||||||
extensions.configure<KaptExtension> {
|
extensions.configure<KaptExtension> {
|
||||||
javacOptions {
|
javacOptions {
|
||||||
option("-Adagger.fastInit=enabled")
|
if (hasDaggerCompilerDependency) {
|
||||||
option("-Adagger.experimentalDaggerErrorMessages=enabled")
|
option("-Adagger.fastInit=enabled")
|
||||||
option("-Xmaxerrs", 500)
|
option("-Adagger.strictMultibindingValidation=enabled")
|
||||||
option("-Adagger.moduleBindingValidation=ERROR")
|
option("-Adagger.experimentalDaggerErrorMessages=enabled")
|
||||||
|
option("-Xmaxerrs", 500)
|
||||||
|
option("-Adagger.moduleBindingValidation=ERROR")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// disable kapt tasks for unit tests
|
||||||
|
tasks.matching {
|
||||||
|
it.name.startsWith("kapt") && it.name.endsWith("UnitTestKotlin")
|
||||||
|
}.configureEach { enabled = false }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val Project.hasDaggerCompilerDependency: Boolean
|
||||||
|
get() = configurations.any {
|
||||||
|
it.dependencies.any { dependency ->
|
||||||
|
dependency.name == "dagger-compiler"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue