-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
602 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
|
||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
group = "com.droidconke.doko.buildlogic" | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_21 | ||
targetCompatibility = JavaVersion.VERSION_21 | ||
} | ||
|
||
kotlin { | ||
compilerOptions { | ||
jvmTarget = JvmTarget.JVM_21 | ||
} | ||
} | ||
|
||
dependencies { | ||
compileOnly(libs.android.gradlePlugin) | ||
compileOnly(libs.android.tools.common) | ||
compileOnly(libs.compose.gradlePlugin) | ||
compileOnly(libs.firebase.crashlytics.gradlePlugin) | ||
compileOnly(libs.firebase.performance.gradlePlugin) | ||
compileOnly(libs.kotlin.gradlePlugin) | ||
compileOnly(libs.ksp.gradlePlugin) | ||
compileOnly(libs.room.gradlePlugin) | ||
implementation(libs.truth) | ||
} | ||
|
||
tasks { | ||
validatePlugins { | ||
enableStricterValidation = true | ||
failOnWarning = true | ||
} | ||
} | ||
|
||
gradlePlugin { | ||
plugins { | ||
register("androidApplicationCompose") { | ||
id = "doko.android.application.compose" | ||
implementationClass = "AndroidApplicationComposeConventionPlugin" | ||
} | ||
register("androidApplication") { | ||
id = "doko.android.application" | ||
implementationClass = "AndroidApplicationConventionPlugin" | ||
} | ||
register("androidLibraryCompose") { | ||
id = "doko.android.library.compose" | ||
implementationClass = "AndroidLibraryComposeConventionPlugin" | ||
} | ||
register("androidLibrary") { | ||
id = "doko.android.library" | ||
implementationClass = "AndroidLibraryConventionPlugin" | ||
} | ||
register("androidFeature") { | ||
id = "doko.android.feature" | ||
implementationClass = "AndroidFeatureConventionPlugin" | ||
} | ||
register("androidTest") { | ||
id = "doko.android.test" | ||
implementationClass = "AndroidTestConventionPlugin" | ||
} | ||
register("hilt") { | ||
id = "doko.hilt" | ||
implementationClass = "HiltConventionPlugin" | ||
} | ||
register("androidRoom") { | ||
id = "doko.android.room" | ||
implementationClass = "AndroidRoomConventionPlugin" | ||
} | ||
register("androidFirebase") { | ||
id = "doko.android.application.firebase" | ||
implementationClass = "AndroidApplicationFirebaseConventionPlugin" | ||
} | ||
register("androidLint") { | ||
id = "doko.android.lint" | ||
implementationClass = "AndroidLintConventionPlugin" | ||
} | ||
register("jvmLibrary") { | ||
id = "doko.jvm.library" | ||
implementationClass = "JvmLibraryConventionPlugin" | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
buildLogic/convention/src/main/kotlin/AndroidApplicationComposeConventionPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import com.android.build.api.dsl.ApplicationExtension | ||
import com.droidconke.doko.configureAndroidCompose | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.apply | ||
import org.gradle.kotlin.dsl.getByType | ||
|
||
class AndroidApplicationComposeConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
apply(plugin = "com.android.application") | ||
apply(plugin = "org.jetbrains.kotlin.plugin.compose") | ||
apply(plugin = "org.jetbrains.kotlin.android") | ||
|
||
val extension = extensions.getByType<ApplicationExtension>() | ||
configureAndroidCompose(extension) | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
buildLogic/convention/src/main/kotlin/AndroidApplicationConventionPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import com.android.build.api.dsl.ApplicationExtension | ||
import com.droidconke.doko.configureKotlinAndroid | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.configure | ||
|
||
|
||
class AndroidApplicationConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
with(pluginManager) { | ||
apply("com.android.application") | ||
apply("org.jetbrains.kotlin.android") | ||
apply("com.dropbox.dependency-guard") | ||
apply("doko.android.lint") | ||
} | ||
|
||
extensions.configure<ApplicationExtension> { | ||
configureKotlinAndroid(this) | ||
defaultConfig.targetSdk = 34 | ||
defaultConfig.minSdk = 28 | ||
@Suppress("UnstableApiUsage") | ||
testOptions.animationsDisabled = true | ||
} | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
buildLogic/convention/src/main/kotlin/AndroidApplicationFirebaseConventionPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import com.android.build.api.dsl.ApplicationExtension | ||
import com.google.firebase.crashlytics.buildtools.gradle.CrashlyticsExtension | ||
import com.droidconke.doko.libs | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.configure | ||
import org.gradle.kotlin.dsl.dependencies | ||
|
||
class AndroidApplicationFirebaseConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
with(pluginManager) { | ||
apply("com.google.gms.google-services") | ||
apply("com.google.firebase.firebase-perf") | ||
apply("com.google.firebase.crashlytics") | ||
} | ||
|
||
dependencies { | ||
val bom = libs.findLibrary("firebase-bom").get() | ||
add("implementation", platform(bom)) | ||
"implementation"(libs.findLibrary("firebase.analytics").get()) | ||
"implementation"(libs.findLibrary("firebase.performance").get()) | ||
"implementation"(libs.findLibrary("firebase.crashlytics").get()) | ||
} | ||
|
||
extensions.configure<ApplicationExtension> { | ||
buildTypes.configureEach { | ||
// Disable the Crashlytics mapping file upload. This feature should only be | ||
// enabled if a Firebase backend is available and configured in | ||
// google-services.json. | ||
configure<CrashlyticsExtension> { | ||
mappingFileUploadEnabled = false | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
buildLogic/convention/src/main/kotlin/AndroidFeatureConventionPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import com.android.build.gradle.LibraryExtension | ||
import com.droidconke.doko.libs | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.configure | ||
import org.gradle.kotlin.dsl.dependencies | ||
|
||
|
||
class AndroidFeatureConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
pluginManager.apply { | ||
apply("doko.android.library") | ||
apply("doko.hilt") | ||
} | ||
extensions.configure<LibraryExtension> { | ||
testOptions.animationsDisabled = true | ||
} | ||
|
||
dependencies { | ||
|
||
add("implementation", libs.findLibrary("androidx.hilt.navigation.compose").get()) | ||
add("implementation", libs.findLibrary("androidx.lifecycle.runtimeCompose").get()) | ||
add("implementation", libs.findLibrary("androidx.lifecycle.viewModelCompose").get()) | ||
add("implementation", libs.findLibrary("androidx.tracing.ktx").get()) | ||
|
||
add("androidTestImplementation", libs.findLibrary("androidx.lifecycle.runtimeTesting").get()) | ||
} | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
buildLogic/convention/src/main/kotlin/AndroidLibraryComposeConventionPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import com.android.build.gradle.LibraryExtension | ||
import com.droidconke.doko.configureAndroidCompose | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.apply | ||
import org.gradle.kotlin.dsl.getByType | ||
|
||
|
||
class AndroidLibraryComposeConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
apply(plugin = "com.android.library") | ||
apply(plugin = "org.jetbrains.kotlin.plugin.compose") | ||
|
||
val extension = extensions.getByType<LibraryExtension>() | ||
configureAndroidCompose(extension) | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
buildLogic/convention/src/main/kotlin/AndroidLibraryConventionPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import com.android.build.api.variant.LibraryAndroidComponentsExtension | ||
import com.android.build.gradle.LibraryExtension | ||
import com.droidconke.doko.configureKotlinAndroid | ||
import com.droidconke.doko.disableUnnecessaryAndroidTests | ||
import com.droidconke.doko.libs | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.configure | ||
import org.gradle.kotlin.dsl.dependencies | ||
import org.gradle.kotlin.dsl.kotlin | ||
|
||
|
||
|
||
class AndroidLibraryConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
with(pluginManager) { | ||
apply("com.android.library") | ||
apply("org.jetbrains.kotlin.android") | ||
apply("doko.android.lint") | ||
} | ||
|
||
extensions.configure<LibraryExtension> { | ||
configureKotlinAndroid(this) | ||
defaultConfig.targetSdk = 34 | ||
defaultConfig.testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
testOptions.animationsDisabled = true | ||
// The resource prefix is derived from the module name, | ||
// so resources inside ":core:module1" must be prefixed with "core_module1_" | ||
resourcePrefix = path | ||
.split("""\W""".toRegex()).drop(1).distinct().joinToString(separator = "_").lowercase() + "_" | ||
} | ||
extensions.configure<LibraryAndroidComponentsExtension> { | ||
disableUnnecessaryAndroidTests(target) | ||
} | ||
dependencies { | ||
add("androidTestImplementation", kotlin("test")) | ||
add("testImplementation", kotlin("test")) | ||
|
||
add("implementation", libs.findLibrary("androidx.tracing.ktx").get()) | ||
} | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
buildLogic/convention/src/main/kotlin/AndroidLintConventionPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import com.android.build.api.dsl.ApplicationExtension | ||
import com.android.build.api.dsl.LibraryExtension | ||
import com.android.build.api.dsl.Lint | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.configure | ||
|
||
|
||
class AndroidLintConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
when { | ||
pluginManager.hasPlugin("com.android.application") -> | ||
configure<ApplicationExtension> { lint(Lint::configure) } | ||
|
||
pluginManager.hasPlugin("com.android.library") -> | ||
configure<LibraryExtension> { lint(Lint::configure) } | ||
|
||
else -> { | ||
pluginManager.apply("com.android.lint") | ||
configure<Lint>(Lint::configure) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
private fun Lint.configure() { | ||
xmlReport = true | ||
checkDependencies = true | ||
} | ||
|
34 changes: 34 additions & 0 deletions
34
buildLogic/convention/src/main/kotlin/AndroidRoomConventionPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import androidx.room.gradle.RoomExtension | ||
import com.google.devtools.ksp.gradle.KspExtension | ||
import com.droidconke.doko.libs | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.configure | ||
import org.gradle.kotlin.dsl.dependencies | ||
|
||
|
||
class AndroidRoomConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
pluginManager.apply("androidx.room") | ||
pluginManager.apply("com.google.devtools.ksp") | ||
|
||
extensions.configure<KspExtension> { | ||
arg("room.generateKotlin", "true") | ||
} | ||
|
||
extensions.configure<RoomExtension> { | ||
// The schemas directory contains a schema file for each version of the Room database. | ||
// This is required to enable Room auto migrations. | ||
// See https://developer.android.com/reference/kotlin/androidx/room/AutoMigration. | ||
schemaDirectory("$projectDir/schemas") | ||
} | ||
|
||
dependencies { | ||
add("implementation", libs.findLibrary("room.runtime").get()) | ||
add("implementation", libs.findLibrary("room.ktx").get()) | ||
add("ksp", libs.findLibrary("room.compiler").get()) | ||
} | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
buildLogic/convention/src/main/kotlin/AndroidTestConventionPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import com.android.build.gradle.TestExtension | ||
import com.droidconke.doko.configureKotlinAndroid | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.configure | ||
|
||
|
||
class AndroidTestConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
with(pluginManager) { | ||
apply("com.android.test") | ||
apply("org.jetbrains.kotlin.android") | ||
} | ||
|
||
extensions.configure<TestExtension> { | ||
configureKotlinAndroid(this) | ||
defaultConfig.targetSdk = 34 | ||
} | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.