-
Notifications
You must be signed in to change notification settings - Fork 5
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
25 changed files
with
5,086 additions
and
0 deletions.
There are no files selected for viewing
1,192 changes: 1,192 additions & 0 deletions
1,192
app/schemas/com.niyaj.poposroom.features.common.database.PoposDatabase/5.json
Large diffs are not rendered by default.
Oops, something went wrong.
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 @@ | ||
# Convention Plugins | ||
|
||
The `build-logic` folder defines project-specific convention plugins, used to keep a single | ||
source of truth for common module configurations. | ||
|
||
This approach is heavily based on | ||
[https://developer.squareup.com/blog/herding-elephants/](https://developer.squareup.com/blog/herding-elephants/) | ||
and | ||
[https://github.com/jjohannes/idiomatic-gradle](https://github.com/jjohannes/idiomatic-gradle). | ||
|
||
By setting up convention plugins in `build-logic`, we can avoid duplicated build script setup, | ||
messy `subproject` configurations, without the pitfalls of the `buildSrc` directory. | ||
|
||
`build-logic` is an included build, as configured in the root | ||
[`settings.gradle.kts`](../settings.gradle.kts). | ||
|
||
Inside `build-logic` is a `convention` module, which defines a set of plugins that all normal | ||
modules can use to configure themselves. | ||
|
||
`build-logic` also includes a set of `Kotlin` files used to share logic between plugins themselves, | ||
which is most useful for configuring Android components (libraries vs applications) with shared | ||
code. | ||
|
||
These plugins are *additive* and *composable*, and try to only accomplish a single responsibility. | ||
Modules can then pick and choose the configurations they need. | ||
If there is one-off logic for a module without shared code, it's preferable to define that directly | ||
in the module's `build.gradle`, as opposed to creating a convention plugin with module-specific | ||
setup. | ||
|
||
Current list of convention plugins: | ||
|
||
- [`nowinandroid.android.application`](convention/src/main/kotlin/AndroidApplicationConventionPlugin.kt), | ||
[`nowinandroid.android.library`](convention/src/main/kotlin/AndroidLibraryConventionPlugin.kt), | ||
[`nowinandroid.android.test`](convention/src/main/kotlin/AndroidTestConventionPlugin.kt): | ||
Configures common Android and Kotlin options. | ||
- [`nowinandroid.android.application.compose`](convention/src/main/kotlin/AndroidApplicationComposeConventionPlugin.kt), | ||
[`nowinandroid.android.library.compose`](convention/src/main/kotlin/AndroidLibraryComposeConventionPlugin.kt): | ||
Configures Jetpack Compose options |
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,96 @@ | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
/* | ||
* Copyright 2022 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
group = "com.niyaj.samples.apps.popos.buildlogic" | ||
|
||
// Configure the build-logic plugins to target JDK 17 | ||
// This matches the JDK used to build the project, and is not related to what is running on device. | ||
java { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
} | ||
|
||
//tasks.withType<KotlinCompile>().configureEach { | ||
// kotlinOptions { | ||
// jvmTarget = JavaVersion.VERSION_17.toString() | ||
// } | ||
//} | ||
|
||
dependencies { | ||
compileOnly(libs.android.gradlePlugin) | ||
compileOnly(libs.kotlin.gradlePlugin) | ||
compileOnly(libs.ksp.gradlePlugin) | ||
compileOnly(libs.hilt.gradlePlugin) | ||
} | ||
|
||
gradlePlugin { | ||
plugins { | ||
register("androidApplicationCompose") { | ||
id = "popos.android.application.compose" | ||
implementationClass = "AndroidApplicationComposeConventionPlugin" | ||
} | ||
register("androidApplication") { | ||
id = "popos.android.application" | ||
implementationClass = "AndroidApplicationConventionPlugin" | ||
} | ||
register("androidApplicationJacoco") { | ||
id = "popos.android.application.jacoco" | ||
implementationClass = "AndroidApplicationJacocoConventionPlugin" | ||
} | ||
register("androidLibraryCompose") { | ||
id = "popos.android.library.compose" | ||
implementationClass = "AndroidLibraryComposeConventionPlugin" | ||
} | ||
register("androidLibrary") { | ||
id = "popos.android.library" | ||
implementationClass = "AndroidLibraryConventionPlugin" | ||
} | ||
register("androidFeature") { | ||
id = "popos.android.feature" | ||
implementationClass = "AndroidFeatureConventionPlugin" | ||
} | ||
register("androidTest") { | ||
id = "popos.android.test" | ||
implementationClass = "AndroidTestConventionPlugin" | ||
} | ||
register("androidHilt") { | ||
id = "popos.android.hilt" | ||
implementationClass = "AndroidHiltConventionPlugin" | ||
} | ||
register("androidLibraryJacoco") { | ||
id = "popos.android.library.jacoco" | ||
implementationClass = "AndroidLibraryJacocoConventionPlugin" | ||
} | ||
register("androidFlavors") { | ||
id = "popos.android.application.flavors" | ||
implementationClass = "AndroidApplicationFlavorsConventionPlugin" | ||
} | ||
register("androidRoom") { | ||
id = "popos.android.room" | ||
implementationClass = "AndroidRoomConventionPlugin" | ||
} | ||
register("jvmLibrary") { | ||
id = "popos.jvm.library" | ||
implementationClass = "JvmLibraryConventionPlugin" | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
build-logic/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,32 @@ | ||
/* | ||
* Copyright 2022 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import com.android.build.api.dsl.ApplicationExtension | ||
import com.niyaj.samples.apps.popos.configureAndroidCompose | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.getByType | ||
|
||
class AndroidApplicationComposeConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
pluginManager.apply("com.android.application") | ||
val extension = extensions.getByType<ApplicationExtension>() | ||
configureAndroidCompose(extension) | ||
} | ||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
build-logic/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,45 @@ | ||
/* | ||
* Copyright 2022 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import com.android.build.api.dsl.ApplicationExtension | ||
import com.android.build.api.variant.ApplicationAndroidComponentsExtension | ||
import com.niyaj.samples.apps.popos.configureGradleManagedDevices | ||
import com.niyaj.samples.apps.popos.configureKotlinAndroid | ||
import com.niyaj.samples.apps.popos.configurePrintApksTask | ||
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") | ||
} | ||
|
||
extensions.configure<ApplicationExtension> { | ||
configureKotlinAndroid(this) | ||
defaultConfig.targetSdk = 34 | ||
configureGradleManagedDevices(this) | ||
} | ||
extensions.configure<ApplicationAndroidComponentsExtension> { | ||
configurePrintApksTask(this) | ||
} | ||
} | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
build-logic/convention/src/main/kotlin/AndroidApplicationFlavorsConventionPlugin.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 @@ | ||
/* | ||
* Copyright 2023 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import com.android.build.api.dsl.ApplicationExtension | ||
import com.niyaj.samples.apps.popos.configureFlavors | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.configure | ||
|
||
class AndroidApplicationFlavorsConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
extensions.configure<ApplicationExtension> { | ||
configureFlavors(this) | ||
} | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
build-logic/convention/src/main/kotlin/AndroidApplicationJacocoConventionPlugin.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,35 @@ | ||
/* | ||
* Copyright 2022 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import com.android.build.api.variant.ApplicationAndroidComponentsExtension | ||
import com.niyaj.samples.apps.popos.configureJacoco | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.getByType | ||
|
||
class AndroidApplicationJacocoConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
with(pluginManager) { | ||
apply("org.gradle.jacoco") | ||
apply("com.android.application") | ||
} | ||
val extension = extensions.getByType<ApplicationAndroidComponentsExtension>() | ||
configureJacoco(extension) | ||
} | ||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
build-logic/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,45 @@ | ||
import com.android.build.gradle.LibraryExtension | ||
import com.niyaj.samples.apps.popos.configureGradleManagedDevices | ||
import com.niyaj.samples.apps.popos.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 AndroidFeatureConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
pluginManager.apply { | ||
apply("popos.android.library") | ||
apply("popos.android.hilt") | ||
} | ||
extensions.configure<LibraryExtension> { | ||
defaultConfig { | ||
testInstrumentationRunner = "com.niyaj.testing.PoposTestRunner" | ||
} | ||
configureGradleManagedDevices(this) | ||
} | ||
|
||
dependencies { | ||
add("implementation", project(":core:model")) | ||
add("implementation", project(":core:ui")) | ||
add("implementation", project(":core:designsystem")) | ||
add("implementation", project(":core:data")) | ||
add("implementation", project(":core:common")) | ||
add("implementation", project(":core:domain")) | ||
|
||
add("testImplementation", kotlin("test")) | ||
add("testImplementation", project(":core:testing")) | ||
add("androidTestImplementation", kotlin("test")) | ||
add("androidTestImplementation", project(":core:testing")) | ||
|
||
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("kotlinx.coroutines.android").get()) | ||
} | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
build-logic/convention/src/main/kotlin/AndroidHiltConventionPlugin.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,28 @@ | ||
|
||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.artifacts.VersionCatalogsExtension | ||
import org.gradle.kotlin.dsl.dependencies | ||
import org.gradle.kotlin.dsl.getByType | ||
|
||
class AndroidHiltConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
with(pluginManager) { | ||
apply("dagger.hilt.android.plugin") | ||
// KAPT must go last to avoid build warnings. | ||
// See: https://stackoverflow.com/questions/70550883/warning-the-following-options-were-not-recognized-by-any-processor-dagger-f | ||
apply("org.jetbrains.kotlin.kapt") | ||
} | ||
|
||
val libs = extensions.getByType<VersionCatalogsExtension>().named("libs") | ||
dependencies { | ||
"implementation"(libs.findLibrary("hilt.android").get()) | ||
"kapt"(libs.findLibrary("hilt.compiler").get()) | ||
"kaptAndroidTest"(libs.findLibrary("hilt.compiler").get()) | ||
} | ||
|
||
} | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
build-logic/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,16 @@ | ||
|
||
import com.android.build.gradle.LibraryExtension | ||
import com.niyaj.samples.apps.popos.configureAndroidCompose | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.getByType | ||
|
||
class AndroidLibraryComposeConventionPlugin : Plugin<Project> { | ||
override fun apply(target: Project) { | ||
with(target) { | ||
pluginManager.apply("com.android.library") | ||
val extension = extensions.getByType<LibraryExtension>() | ||
configureAndroidCompose(extension) | ||
} | ||
} | ||
} |
Oops, something went wrong.