Added more tweaks to convention plugins setup

This commit is contained in:
Arty Bishop committed 2026-03-18 15:59:55 +00:00
1 parent c1966442a7
commit 082b52c58b
14 files changed
+84 -273

No files matched your search

-18
View File
@@ -1,8 +1,6 @@
import org.gradle.initialization.DependenciesAccessors
import org.gradle.kotlin.dsl.support.serviceOf
//import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
`kotlin-dsl`
}
@@ -10,7 +8,6 @@ plugins {
dependencies {
compileOnly(libs.android.gradlePlugin)
compileOnly(libs.kotlin.gradlePlugin)
gradle.serviceOf<DependenciesAccessors>().classes.asFiles.forEach {
compileOnly(files(it.absolutePath))
}
@@ -25,21 +22,6 @@ tasks {
group = "com.rtbishop.look4sat.build_logic.convention"
//kotlin {
// jvmToolchain(libs.versions.jdkVersion.get().toInt())
//}
//java {
// sourceCompatibility = JavaVersion.VERSION_17
// targetCompatibility = JavaVersion.VERSION_17
//}
//
//tasks.withType<KotlinCompile>().configureEach {
// kotlinOptions {
// jvmTarget = JavaVersion.VERSION_17.toString()
// }
//}
gradlePlugin {
plugins {
register("androidAppPlugin") {
@@ -17,44 +17,29 @@
*/
package com.rtbishop.look4sat.convention
import com.android.build.api.dsl.ApplicationExtension
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies
@Suppress("Unused")
class AndroidAppPlugin : Plugin<Project> {
internal class AndroidAppPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
alias(libs.plugins.android.application)
alias(libs.plugins.compose.compiler)
}
configureKotlinLibrary()
extensions.configure<ApplicationExtension> {
configureAndroidApp(this)
}
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)
IMPLEMENTATION(platform(libs.compose.bom))
IMPLEMENTATION(libs.bundles.composeAll)
IMPLEMENTATION(libs.other.osmdroid)
DEBUG_IMPLEMENTATION(libs.bundles.composeDebug)
TEST_IMPLEMENTATION(libs.test.coroutines)
TEST_IMPLEMENTATION(libs.test.junit4)
ANDROID_TEST_IMPLEMENTATION(libs.bundles.androidTest)
}
}
}
@@ -17,39 +17,29 @@
*/
package com.rtbishop.look4sat.convention
import com.android.build.api.dsl.LibraryExtension
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies
@Suppress("Unused")
class AndroidLibraryPlugin : Plugin<Project> {
internal class AndroidLibraryPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
alias(libs.plugins.android.library)
alias(libs.plugins.google.ksp)
}
// setupAndroidModule(isApplication = false)
// setupBaseDependencies()
configureKotlinLibrary()
extensions.configure<LibraryExtension> {
configureAndroidLibrary(this)
}
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)
TEST_IMPLEMENTATION(libs.test.coroutines)
TEST_IMPLEMENTATION(libs.test.junit4)
ANDROID_TEST_IMPLEMENTATION(libs.bundles.androidTest)
}
}
}
@@ -17,47 +17,22 @@
*/
package com.rtbishop.look4sat.convention
import com.android.build.api.dsl.LibraryExtension
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies
@Suppress("Unused")
class ComposeFeaturePlugin : Plugin<Project> {
internal class ComposeFeaturePlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
alias(libs.plugins.android.library)
alias(libs.plugins.compose.compiler)
}
configureKotlinLibrary()
extensions.configure<LibraryExtension> {
configureAndroidLibrary(this)
configureComposeFeature(this)
}
setupCommonLibrary()
setupComposeFeature()
setupKotlinToolchain()
setupAndroidTestDependencies()
setupTestDependencies()
dependencies {
IMPLEMENTATION(project(":core:domain"))
IMPLEMENTATION(project(":core:presentation"))
IMPLEMENTATION(libs.androidx.core.splashscreen)
IMPLEMENTATION(platform(libs.compose.bom))
IMPLEMENTATION(libs.compose.activity)
IMPLEMENTATION(libs.compose.lifecycle)
IMPLEMENTATION(libs.compose.navigation)
IMPLEMENTATION(libs.compose.viewmodel)
IMPLEMENTATION(libs.compose.animation)
IMPLEMENTATION(libs.compose.material3)
// IMPLEMENTATION(libs.compose.material3.asProvider())
IMPLEMENTATION(libs.compose.material3.navigation)
IMPLEMENTATION(libs.compose.runtime)
IMPLEMENTATION(libs.compose.tooling)
IMPLEMENTATION(libs.other.osmdroid)
DEBUG_IMPLEMENTATION(libs.bundles.composeDebug)
TEST_IMPLEMENTATION(libs.test.coroutines)
TEST_IMPLEMENTATION(libs.test.junit4)
ANDROID_TEST_IMPLEMENTATION(libs.bundles.androidTest)
}
}
}
@@ -17,46 +17,21 @@
*/
package com.rtbishop.look4sat.convention
import com.android.build.api.dsl.LibraryExtension
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies
@Suppress("Unused")
class ComposeLibraryPlugin : Plugin<Project> {
internal class ComposeLibraryPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
alias(libs.plugins.android.library)
alias(libs.plugins.compose.compiler)
}
configureKotlinLibrary()
extensions.configure<LibraryExtension> {
configureAndroidLibrary(this)
configureComposeFeature(this)
}
setupCommonLibrary()
setupComposeFeature()
setupKotlinToolchain()
setupAndroidTestDependencies()
setupTestDependencies()
dependencies {
IMPLEMENTATION(project(":core:domain"))
IMPLEMENTATION(libs.androidx.core.splashscreen)
IMPLEMENTATION(platform(libs.compose.bom))
IMPLEMENTATION(libs.compose.activity)
IMPLEMENTATION(libs.compose.lifecycle)
IMPLEMENTATION(libs.compose.navigation)
IMPLEMENTATION(libs.compose.viewmodel)
IMPLEMENTATION(libs.compose.animation)
IMPLEMENTATION(libs.compose.material3)
// IMPLEMENTATION(libs.compose.material3.asProvider())
IMPLEMENTATION(libs.compose.material3.navigation)
IMPLEMENTATION(libs.compose.runtime)
IMPLEMENTATION(libs.compose.tooling)
IMPLEMENTATION(libs.other.osmdroid)
DEBUG_IMPLEMENTATION(libs.bundles.composeDebug)
TEST_IMPLEMENTATION(libs.test.coroutines)
TEST_IMPLEMENTATION(libs.test.junit4)
ANDROID_TEST_IMPLEMENTATION(libs.bundles.androidTest)
}
}
}
@@ -22,18 +22,17 @@ import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies
@Suppress("Unused")
class KotlinLibraryPlugin : Plugin<Project> {
internal class KotlinLibraryPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
alias(libs.plugins.kotlin.jvm)
}
configureKotlinLibrary()
setupKotlinToolchain()
setupTestDependencies()
dependencies {
implementation(libs.other.coroutines)
implementation(libs.other.json)
testImplementation(libs.test.coroutines)
testImplementation(libs.test.junit4)
IMPLEMENTATION(libs.other.coroutines)
IMPLEMENTATION(libs.other.json)
}
}
}
@@ -18,15 +18,11 @@
package com.rtbishop.look4sat.convention
import com.android.build.api.dsl.ApplicationExtension
import com.android.build.api.dsl.LibraryExtension
import com.android.build.api.dsl.CommonExtension
import org.gradle.accessors.dm.LibrariesForLibs
import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.api.artifacts.MinimalExternalModuleDependency
import org.gradle.api.artifacts.dsl.DependencyHandler
import org.gradle.api.plugins.PluginManager
import org.gradle.api.provider.Provider
import org.gradle.api.provider.ProviderConvertible
import org.gradle.kotlin.dsl.accessors.runtime.extensionOf
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies
@@ -40,71 +36,21 @@ internal const val KSP = "ksp"
internal const val TEST_IMPLEMENTATION = "testImplementation"
internal val Project.libs
// get(): VersionCatalog = extensions.getByType<VersionCatalogsExtension>().named("libs")
get(): LibrariesForLibs = extensionOf(this, "libs") as LibrariesForLibs
internal fun Project.configureKotlinLibrary() {
// kotlinExtension.jvmToolchain(libs.findVersion("jdkVersion").get().requiredVersion.toInt())
kotlinExtension.jvmToolchain(libs.versions.jdkVersion.get().toInt())
// tasks.withType(AbstractTestTask::class.java).configureEach { setProperty("failOnNoDiscoveredTests", false) }
}
fun PluginManager.alias(notation: Provider<PluginDependency>) {
internal fun PluginManager.alias(notation: Provider<PluginDependency>) {
apply(notation.get().pluginId)
}
fun PluginManager.alias(notation: ProviderConvertible<PluginDependency>) {
apply(notation.asProvider().get().pluginId)
}
fun DependencyHandler.implementation(provider: Provider<MinimalExternalModuleDependency>) {
add("implementation", provider.get().group + ":" + provider.get().name + ":" + provider.get().version)
}
fun DependencyHandler.testImplementation(provider: Provider<MinimalExternalModuleDependency>) {
add("testImplementation", provider.get().group + ":" + provider.get().name + ":" + provider.get().version)
}
fun DependencyHandler.ksp(provider: Provider<MinimalExternalModuleDependency>) {
add("ksp", provider.get().group + ":" + provider.get().name + ":" + provider.get().version)
}
internal fun Project.configureAndroidLibrary(commonExtension: LibraryExtension) {
commonExtension.apply {
compileSdk = libs.versions.compileSdk.get().toInt()
defaultConfig {
minSdk = libs.versions.minSdk.get().toInt()
}
// compileOptions { isCoreLibraryDesugaringEnabled = true }
// testOptions {
// unitTests {
// all { it.useJUnitPlatform() }
// isReturnDefaultValues = true
// isIncludeAndroidResources = true
// }
// }
// packaging { resources { excludes += listOf("META-INF/*") } }
// dependencies {
// IMPLEMENTATION(libs.findLibrary("androidx-core").get())
// IMPLEMENTATION(libs.findLibrary("kotlinx-serialization-json").get())
// IMPLEMENTATION(libs.findLibrary("other-timber").get())
// IMPLEMENTATION(libs.findLibrary("google-hilt-android").get())
// KSP(libs.findLibrary("google-hilt-compiler").get())
//
// ANDROID_TEST_IMPLEMENTATION(libs.findBundle("androidTest").get())
// ANDROID_TEST_IMPLEMENTATION(libs.findBundle("unitTest").get())
// CORE_LIBRARY_DESUGARING(libs.findLibrary("other-desugaring").get())
// TEST_IMPLEMENTATION(libs.findBundle("unitTest").get())
// }
internal fun Project.setupAndroidApplication() {
with(pluginManager) {
alias(libs.plugins.android.application)
}
}
internal fun Project.configureAndroidApp(commonExtension: ApplicationExtension) {
commonExtension.apply {
namespace = "com.rtbishop.look4sat"
extensions.configure<ApplicationExtension> {
namespace = libs.versions.packageName.get()
compileSdk = libs.versions.compileSdk.get().toInt()
defaultConfig {
applicationId = "com.rtbishop.look4sat"
applicationId = libs.versions.packageName.get()
minSdk = libs.versions.minSdk.get().toInt()
versionCode = libs.versions.appVersionCode.get().toInt()
versionName = libs.versions.appVersionName.get()
@@ -126,84 +72,47 @@ internal fun Project.configureAndroidApp(commonExtension: ApplicationExtension)
generateLocaleConfig = true
localeFilters.addAll(listOf("en", "es", "ru", "si", "uk", "zh"))
}
}
// extensions.configure<ApplicationExtension> {
// namespace = "com.rtbishop.look4sat"
// compileSdk = 36
// defaultConfig {
// applicationId = "com.rtbishop.look4sat"
// minSdk = 24
// versionCode = 410
// versionName = "4.1.0"
// }
// buildFeatures {
// compose = true
// }
// buildTypes {
// debug {
// applicationIdSuffix = ".debug"
// }
// release {
// isMinifyEnabled = true
// isShrinkResources = true
// proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"))
// }
// }
// androidResources {
// generateLocaleConfig = true
// localeFilters.addAll(listOf("en", "es", "ru", "si", "uk", "zh"))
// }
// }
}
internal fun Project.configureComposeFeature(commonExtension: LibraryExtension) {
commonExtension.apply {
buildFeatures { compose = true }
// testOptions { animationsDisabled = true }
dependencies {
// IMPLEMENTATION(platform(libs.findLibrary("compose-bom").get()))
// IMPLEMENTATION(libs.findBundle("composeAll").get())
//
// ANDROID_TEST_IMPLEMENTATION(libs.findBundle("composeDebug").get())
// DEBUG_IMPLEMENTATION(libs.findBundle("composeDebug").get())
// SCREENSHOT_TEST_IMPLEMENTATION(libs.findLibrary("compose-ui-tooling").get())
}
packaging { resources { excludes += listOf("META-INF/*") } }
}
}
fun Project.setupAndroidModule(isApplication: Boolean) {
internal fun Project.setupCommonLibrary() {
with(pluginManager) {
if (isApplication) {
alias(libs.plugins.android.application)
alias(libs.plugins.compose.compiler)
} else {
alias(libs.plugins.android.library)
alias(libs.plugins.google.ksp)
}
alias(libs.plugins.android.library)
}
extensions.configure<ApplicationExtension> {
extensions.configure<CommonExtension> {
compileSdk = libs.versions.compileSdk.get().toInt()
defaultConfig {
minSdk = 26
versionCode = 1
versionName = "1.0"
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
buildTypes {
buildTypes {
maybeCreate("debug")
maybeCreate("release")
named("release") {
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
}
defaultConfig.minSdk = libs.versions.minSdk.get().toInt()
}
}
internal fun Project.setupComposeFeature() {
with(pluginManager) {
alias(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)
}
}
internal fun Project.setupKotlinToolchain() {
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)
}
}
-3
View File
@@ -1,5 +1,3 @@
@file:Suppress("UnstableApiUsage")
dependencyResolutionManagement {
repositories {
google()
@@ -13,4 +11,3 @@ dependencyResolutionManagement {
}
rootProject.name = "build-logic"
include(":convention")
//enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")