Skip to content

Commit

Permalink
chore: create an android wear convention plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
GerardPaligot committed Oct 10, 2024
1 parent 644bc86 commit b8e9138
Show file tree
Hide file tree
Showing 20 changed files with 56 additions and 19 deletions.
4 changes: 4 additions & 0 deletions build-logic/plugins/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ gradlePlugin {
id = "confily.multiplatform.library"
implementationClass = "MultiplatformLibraryPlugin"
}
register("androidWearLibrary") {
id = "confily.android.wear.library"
implementationClass = "AndroidWearLibraryPlugin"
}
register("backendApplication") {
id = "confily.backend.application"
implementationClass = "BackendPlugin"
Expand Down
31 changes: 31 additions & 0 deletions build-logic/plugins/src/main/kotlin/AndroidWearLibraryPlugin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

import com.android.build.gradle.LibraryExtension
import extensions.configureDesugaring
import extensions.configureKotlinAndroid
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.getByType

class AndroidWearLibraryPlugin: Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply("com.android.library")
apply("kotlin-parcelize")
apply("org.jetbrains.kotlin.android")
}
extensions.configure<LibraryExtension> {
configureKotlinAndroid(this, compileSdk = 35, minSdk = 30)
configureDesugaring(this)
defaultConfig.targetSdk = 34
}
val libs = extensions.getByType<VersionCatalogsExtension>().named("libs")
dependencies {
add("lintChecks", libs.findLibrary("compose-linter").get())
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ private val CommonExtension<*, *, *, *, *, *>.hasKotlinOptionsExt: Boolean

internal fun configureKotlinAndroid(
commonExtension: CommonExtension<*, *, *, *, *, *>,
compileSdk: Int = 34,
minSdk: Int = 23
) {
commonExtension.apply {
compileSdk = 34
this.compileSdk = compileSdk

defaultConfig {
minSdk = 23
this.minSdk = minSdk
}

compileOptions {
Expand Down
2 changes: 1 addition & 1 deletion wear/wear-features/events/events-di/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("confily.android.library")
id("confily.android.wear.library")
id("confily.quality")
}

Expand Down
2 changes: 1 addition & 1 deletion wear/wear-features/events/events-panes/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("confily.android.library")
id("confily.android.wear.library")
id("confily.android.library.compose")
id("confily.quality")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("confily.android.library")
id("confily.android.wear.library")
id("confily.android.library.compose")
id("confily.quality")
}
Expand Down
2 changes: 1 addition & 1 deletion wear/wear-features/main/main-di/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("confily.android.library")
id("confily.android.wear.library")
id("confily.quality")
}

Expand Down
2 changes: 1 addition & 1 deletion wear/wear-features/main/main/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("confily.android.library")
id("confily.android.wear.library")
id("confily.android.library.compose")
id("confily.quality")
}
Expand Down
2 changes: 1 addition & 1 deletion wear/wear-features/partners/partners-di/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("confily.android.library")
id("confily.android.wear.library")
id("confily.quality")
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("confily.android.library")
id("confily.android.wear.library")
id("confily.android.library.compose")
id("confily.quality")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("confily.android.library")
id("confily.android.wear.library")
id("confily.android.library.compose")
id("confily.quality")
}
Expand Down
2 changes: 1 addition & 1 deletion wear/wear-features/schedules/schedules-di/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("confily.android.library")
id("confily.android.wear.library")
id("confily.quality")
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("confily.android.library")
id("confily.android.wear.library")
id("confily.android.library.compose")
id("confily.quality")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("confily.android.library")
id("confily.android.wear.library")
id("confily.android.library.compose")
id("confily.quality")
}
Expand Down
2 changes: 1 addition & 1 deletion wear/wear-features/schedules/schedules-ui/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("confily.android.library")
id("confily.android.wear.library")
id("confily.android.library.compose")
id("confily.quality")
}
Expand Down
2 changes: 1 addition & 1 deletion wear/wear-features/speakers/speakers-di/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("confily.android.library")
id("confily.android.wear.library")
id("confily.quality")
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("confily.android.library")
id("confily.android.wear.library")
id("confily.android.library.compose")
id("confily.quality")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("confily.android.library")
id("confily.android.wear.library")
id("confily.android.library.compose")
id("confily.quality")
}
Expand Down
2 changes: 1 addition & 1 deletion wear/wear-resources/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("confily.android.library")
id("confily.android.wear.library")
id("confily.quality")
}

Expand Down
2 changes: 1 addition & 1 deletion wear/wear-theme/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("confily.android.library")
id("confily.android.wear.library")
id("confily.android.library.compose")
id("confily.quality")
}
Expand Down

0 comments on commit b8e9138

Please sign in to comment.