Added even more tweaks to convention plugins setup

This commit is contained in:
Arty Bishop committed 2026-03-28 20:03:11 +00:00
1 parent e2bf2a09a4
commit 8c1df334d8
18 files changed
+142 -171

No files matched your search

+15 -15
View File
@@ -24,25 +24,25 @@ group = "com.rtbishop.look4sat.build_logic.convention"
gradlePlugin {
plugins {
register("androidAppPlugin") {
id = libs.plugins.convention.androidAppPlugin.get().pluginId
implementationClass = "com.rtbishop.look4sat.convention.AndroidAppPlugin"
register("applicationPlugin") {
id = libs.plugins.convention.applicationPlugin.get().pluginId
implementationClass = "com.rtbishop.look4sat.convention.ApplicationPlugin"
}
register("androidLibraryPlugin") {
id = libs.plugins.convention.androidLibraryPlugin.get().pluginId
implementationClass = "com.rtbishop.look4sat.convention.AndroidLibraryPlugin"
register("coreDataPlugin") {
id = libs.plugins.convention.coreDataPlugin.get().pluginId
implementationClass = "com.rtbishop.look4sat.convention.CoreDataPlugin"
}
register("composeFeaturePlugin") {
id = libs.plugins.convention.composeFeaturePlugin.get().pluginId
implementationClass = "com.rtbishop.look4sat.convention.ComposeFeaturePlugin"
register("coreDomainPlugin") {
id = libs.plugins.convention.coreDomainPlugin.get().pluginId
implementationClass = "com.rtbishop.look4sat.convention.CoreDomainPlugin"
}
register("composeLibraryPlugin") {
id = libs.plugins.convention.composeLibraryPlugin.get().pluginId
implementationClass = "com.rtbishop.look4sat.convention.ComposeLibraryPlugin"
register("corePresentationPlugin") {
id = libs.plugins.convention.corePresentationPlugin.get().pluginId
implementationClass = "com.rtbishop.look4sat.convention.CorePresentationPlugin"
}
register("kotlinLibraryPlugin") {
id = libs.plugins.convention.kotlinLibraryPlugin.get().pluginId
implementationClass = "com.rtbishop.look4sat.convention.KotlinLibraryPlugin"
register("featurePlugin") {
id = libs.plugins.convention.featurePlugin.get().pluginId
implementationClass = "com.rtbishop.look4sat.convention.FeaturePlugin"
}
}
}
@@ -1,46 +0,0 @@
/*
* Look4Sat. Amateur radio satellite tracker and pass predictor.
* Copyright (C) 2019-2026 Arty Bishop and contributors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.rtbishop.look4sat.convention
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies
@Suppress("Unused")
internal class AndroidAppPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
setupAndroidApplication()
setupComposeFeature()
setupKotlinToolchain()
setupAndroidTestDependencies()
setupTestDependencies()
dependencies {
IMPLEMENTATION(project(":core:data"))
IMPLEMENTATION(project(":core:domain"))
IMPLEMENTATION(project(":core:presentation"))
IMPLEMENTATION(project(":feature:map"))
IMPLEMENTATION(project(":feature:passes"))
IMPLEMENTATION(project(":feature:radar"))
IMPLEMENTATION(project(":feature:satellites"))
IMPLEMENTATION(project(":feature:settings"))
IMPLEMENTATION(libs.androidx.core.splashscreen)
}
}
}
}
@@ -22,25 +22,22 @@ import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies
@Suppress("Unused")
internal class AndroidLibraryPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
alias(libs.plugins.google.ksp)
}
setupCommonLibrary()
setupKotlinToolchain()
setupAndroidTestDependencies()
setupTestDependencies()
dependencies {
IMPLEMENTATION(project(":core:domain"))
IMPLEMENTATION(libs.androidx.core.ktx)
IMPLEMENTATION(libs.androidx.room.asProvider())
IMPLEMENTATION(libs.androidx.room.runtime)
KSP(libs.androidx.room.compiler)
IMPLEMENTATION(libs.other.coroutines)
IMPLEMENTATION(libs.other.okhttp)
}
internal class ApplicationPlugin : Plugin<Project> {
override fun apply(target: Project) = with(target) {
setupAndroidApp()
setupCompose()
setupKotlin()
dependencies {
implementation(project(":core:data"))
implementation(project(":core:domain"))
implementation(project(":core:presentation"))
implementation(project(":feature:map"))
implementation(project(":feature:passes"))
implementation(project(":feature:radar"))
implementation(project(":feature:satellites"))
implementation(project(":feature:settings"))
implementation(libs.androidx.core.splashscreen)
androidTestImplementation(libs.bundles.androidTest)
}
}
}
@@ -0,0 +1,40 @@
/*
* Look4Sat. Amateur radio satellite tracker and pass predictor.
* Copyright (C) 2019-2026 Arty Bishop and contributors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.rtbishop.look4sat.convention
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies
@Suppress("Unused")
internal class CoreDataPlugin : Plugin<Project> {
override fun apply(target: Project) = with(target) {
applyPlugin(libs.plugins.google.ksp)
setupAndroidLib()
setupKotlin()
dependencies {
implementation(project(":core:domain"))
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.room)
implementation(libs.androidx.room.runtime)
ksp(libs.androidx.room.compiler)
implementation(libs.other.coroutines)
implementation(libs.other.okhttp)
}
}
}
@@ -22,18 +22,13 @@ import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies
@Suppress("Unused")
internal class KotlinLibraryPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
alias(libs.plugins.kotlin.jvm)
}
setupKotlinToolchain()
setupTestDependencies()
dependencies {
IMPLEMENTATION(libs.other.coroutines)
IMPLEMENTATION(libs.other.json)
}
internal class CoreDomainPlugin : Plugin<Project> {
override fun apply(target: Project) = with(target) {
applyPlugin(libs.plugins.kotlin.jvm)
setupKotlin()
dependencies {
implementation(libs.other.coroutines)
implementation(libs.other.json)
}
}
}
@@ -22,18 +22,14 @@ import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies
@Suppress("Unused")
internal class ComposeFeaturePlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
setupCommonLibrary()
setupComposeFeature()
setupKotlinToolchain()
setupAndroidTestDependencies()
setupTestDependencies()
dependencies {
IMPLEMENTATION(project(":core:domain"))
IMPLEMENTATION(project(":core:presentation"))
}
internal class CorePresentationPlugin : Plugin<Project> {
override fun apply(target: Project) = with(target) {
setupAndroidLib()
setupCompose()
setupKotlin()
dependencies {
implementation(project(":core:domain"))
implementation(libs.androidx.core.splashscreen)
}
}
}
@@ -22,18 +22,14 @@ import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies
@Suppress("Unused")
internal class ComposeLibraryPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
setupCommonLibrary()
setupComposeFeature()
setupKotlinToolchain()
setupAndroidTestDependencies()
setupTestDependencies()
dependencies {
IMPLEMENTATION(project(":core:domain"))
IMPLEMENTATION(libs.androidx.core.splashscreen)
}
internal class FeaturePlugin : Plugin<Project> {
override fun apply(target: Project) = with(target) {
setupAndroidLib()
setupCompose()
setupKotlin()
dependencies {
implementation(project(":core:domain"))
implementation(project(":core:presentation"))
}
}
}
@@ -21,7 +21,7 @@ import com.android.build.api.dsl.ApplicationExtension
import com.android.build.api.dsl.CommonExtension
import org.gradle.accessors.dm.LibrariesForLibs
import org.gradle.api.Project
import org.gradle.api.plugins.PluginManager
import org.gradle.api.artifacts.dsl.DependencyHandler
import org.gradle.api.provider.Provider
import org.gradle.kotlin.dsl.accessors.runtime.extensionOf
import org.gradle.kotlin.dsl.configure
@@ -29,23 +29,30 @@ import org.gradle.kotlin.dsl.dependencies
import org.gradle.plugin.use.PluginDependency
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
internal const val ANDROID_TEST_IMPLEMENTATION = "androidTestImplementation"
internal const val DEBUG_IMPLEMENTATION = "debugImplementation"
internal const val IMPLEMENTATION = "implementation"
internal const val KSP = "ksp"
internal const val TEST_IMPLEMENTATION = "testImplementation"
internal val Project.libs
get(): LibrariesForLibs = extensionOf(this, "libs") as LibrariesForLibs
internal fun PluginManager.alias(notation: Provider<PluginDependency>) {
apply(notation.get().pluginId)
internal fun Project.applyPlugin(notation: Provider<PluginDependency>) {
pluginManager.apply(notation.get().pluginId)
}
internal fun Project.setupAndroidApplication() {
with(pluginManager) {
alias(libs.plugins.android.application)
}
internal fun DependencyHandler.implementation(dependencyNotation: Any) =
add("implementation", dependencyNotation)
internal fun DependencyHandler.debugImplementation(dependencyNotation: Any) =
add("debugImplementation", dependencyNotation)
internal fun DependencyHandler.testImplementation(dependencyNotation: Any) =
add("testImplementation", dependencyNotation)
internal fun DependencyHandler.androidTestImplementation(dependencyNotation: Any) =
add("androidTestImplementation", dependencyNotation)
internal fun DependencyHandler.ksp(dependencyNotation: Any) =
add("ksp", dependencyNotation)
internal fun Project.setupAndroidApp() {
applyPlugin(libs.plugins.android.application)
extensions.configure<ApplicationExtension> {
namespace = libs.versions.packageName.get()
compileSdk = libs.versions.compileSdk.get().toInt()
@@ -55,9 +62,6 @@ internal fun Project.setupAndroidApplication() {
versionCode = libs.versions.appVersionCode.get().toInt()
versionName = libs.versions.appVersionName.get()
}
buildFeatures {
compose = true
}
buildTypes {
debug {
applicationIdSuffix = ".debug"
@@ -76,43 +80,32 @@ internal fun Project.setupAndroidApplication() {
}
}
internal fun Project.setupCommonLibrary() {
with(pluginManager) {
alias(libs.plugins.android.library)
}
internal fun Project.setupAndroidLib() {
applyPlugin(libs.plugins.android.library)
extensions.configure<CommonExtension> {
compileSdk = libs.versions.compileSdk.get().toInt()
defaultConfig.minSdk = libs.versions.minSdk.get().toInt()
}
dependencies {
androidTestImplementation(libs.bundles.androidTest)
}
}
internal fun Project.setupComposeFeature() {
with(pluginManager) {
alias(libs.plugins.compose.compiler)
}
internal fun Project.setupCompose() {
applyPlugin(libs.plugins.compose.compiler)
extensions.configure<CommonExtension> {
buildFeatures.compose = true
}
dependencies {
IMPLEMENTATION(platform(libs.compose.bom))
IMPLEMENTATION(libs.bundles.composeAll)
DEBUG_IMPLEMENTATION(libs.bundles.composeDebug)
implementation(platform(libs.compose.bom))
implementation(libs.bundles.composeAll)
debugImplementation(libs.bundles.composeDebug)
}
}
internal fun Project.setupKotlinToolchain() {
internal fun Project.setupKotlin() {
kotlinExtension.jvmToolchain(libs.versions.jdkVersion.get().toInt())
}
internal fun Project.setupAndroidTestDependencies() {
dependencies {
ANDROID_TEST_IMPLEMENTATION(libs.bundles.androidTest)
}
}
internal fun Project.setupTestDependencies() {
dependencies {
TEST_IMPLEMENTATION(libs.test.coroutines)
TEST_IMPLEMENTATION(libs.test.junit4)
testImplementation(libs.bundles.unitTest)
}
}