diff --git a/appyx-components/experimental/cards/android/build.gradle.kts b/appyx-components/experimental/cards/android/build.gradle.kts index 45a408f4e..492c1b4b3 100644 --- a/appyx-components/experimental/cards/android/build.gradle.kts +++ b/appyx-components/experimental/cards/android/build.gradle.kts @@ -3,28 +3,8 @@ plugins { id("org.jetbrains.compose") } - -android { - namespace = "com.bumble.appyx.components.experimental.cards.android" - compileSdk = libs.versions.androidCompileSdk.get().toInt() - defaultConfig { - minSdk = libs.versions.androidMinSdk.get().toInt() - targetSdk = libs.versions.androidTargetSdk.get().toInt() - - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - - testOptions { - unitTests.all { - it.useJUnitPlatform() - } - } - packagingOptions { - resources.excludes.apply { - add("META-INF/LICENSE.md") - add("META-INF/LICENSE-notice.md") - } - } +appyx { + namespace.set("com.bumble.appyx.components.experimental.cards.android") } dependencies { @@ -36,11 +16,8 @@ dependencies { implementation(project(":appyx-interactions:appyx-interactions")) implementation(project(":appyx-components:experimental:cards:cards")) implementation(composeBom) - androidTestImplementation(libs.compose.ui.test.junit4) + androidTestImplementation(libs.compose.ui.test.junit4) androidTestImplementation(libs.junit.api) - testRuntimeOnly(libs.junit.engine) - testRuntimeOnly(libs.junit.vintage) - androidTestImplementation(libs.compose.ui.test.manifest) } diff --git a/appyx-components/experimental/cards/common/build.gradle.kts b/appyx-components/experimental/cards/common/build.gradle.kts index 35f8d0517..c3564b4ec 100644 --- a/appyx-components/experimental/cards/common/build.gradle.kts +++ b/appyx-components/experimental/cards/common/build.gradle.kts @@ -7,6 +7,10 @@ plugins { id("com.google.devtools.ksp") } +appyx { + androidNamespace.set("com.bumble.appyx.components.experimental.cards.common") +} + kotlin { android { publishLibraryVariants("release") @@ -40,17 +44,6 @@ kotlin { } } -android { - namespace = "com.bumble.appyx.components.experimental.cards.common" - compileSdk = libs.versions.androidCompileSdk.get().toInt() - sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") - - defaultConfig { - minSdk = libs.versions.androidMinSdk.get().toInt() - targetSdk = libs.versions.androidTargetSdk.get().toInt() - } -} - dependencies { add("kspCommonMainMetadata", project(":ksp:mutable-ui-processor")) add("kspAndroid", project(":ksp:mutable-ui-processor")) diff --git a/appyx-components/experimental/modal/common/build.gradle.kts b/appyx-components/experimental/modal/common/build.gradle.kts index 547c082d1..b6a5625cf 100644 --- a/appyx-components/experimental/modal/common/build.gradle.kts +++ b/appyx-components/experimental/modal/common/build.gradle.kts @@ -7,6 +7,10 @@ plugins { id("com.google.devtools.ksp") } +appyx { + androidNamespace.set("com.bumble.appyx.components.experimental.modal") +} + kotlin { android { publishLibraryVariants("release") @@ -45,16 +49,6 @@ kotlin { } } -android { - compileSdk = libs.versions.androidCompileSdk.get().toInt() - sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") - - defaultConfig { - minSdk = libs.versions.androidMinSdk.get().toInt() - targetSdk = libs.versions.androidTargetSdk.get().toInt() - } -} - dependencies { add("kspCommonMainMetadata", project(":ksp:mutable-ui-processor")) add("kspAndroid", project(":ksp:mutable-ui-processor")) diff --git a/appyx-components/experimental/promoter/android/build.gradle.kts b/appyx-components/experimental/promoter/android/build.gradle.kts index 34ba96ffa..5815e1091 100644 --- a/appyx-components/experimental/promoter/android/build.gradle.kts +++ b/appyx-components/experimental/promoter/android/build.gradle.kts @@ -3,28 +3,8 @@ plugins { id("org.jetbrains.compose") } - -android { - namespace = "com.bumble.appyx.components.experimental.promoter.android" - compileSdk = libs.versions.androidCompileSdk.get().toInt() - defaultConfig { - minSdk = libs.versions.androidMinSdk.get().toInt() - targetSdk = libs.versions.androidTargetSdk.get().toInt() - - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - - testOptions { - unitTests.all { - it.useJUnitPlatform() - } - } - packagingOptions { - resources.excludes.apply { - add("META-INF/LICENSE.md") - add("META-INF/LICENSE-notice.md") - } - } +appyx { + namespace.set("com.bumble.appyx.components.experimental.promoter.android") } dependencies { @@ -35,11 +15,8 @@ dependencies { implementation(project(":appyx-interactions:appyx-interactions")) implementation(project(":appyx-components:experimental:promoter:promoter")) implementation(composeBom) - androidTestImplementation(libs.compose.ui.test.junit4) + androidTestImplementation(libs.compose.ui.test.junit4) androidTestImplementation(libs.junit.api) - testRuntimeOnly(libs.junit.engine) - testRuntimeOnly(libs.junit.vintage) - androidTestImplementation(libs.compose.ui.test.manifest) } diff --git a/appyx-components/experimental/promoter/common/build.gradle.kts b/appyx-components/experimental/promoter/common/build.gradle.kts index 58fb4faa6..34bb9086b 100644 --- a/appyx-components/experimental/promoter/common/build.gradle.kts +++ b/appyx-components/experimental/promoter/common/build.gradle.kts @@ -7,6 +7,10 @@ plugins { id("com.google.devtools.ksp") } +appyx { + androidNamespace.set("com.bumble.appyx.components.experimental.promoter.common") +} + kotlin { android { publishLibraryVariants("release") @@ -41,17 +45,6 @@ kotlin { } } -android { - namespace = "com.bumble.appyx.components.experimental.promoter.common" - compileSdk = libs.versions.androidCompileSdk.get().toInt() - sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") - - defaultConfig { - minSdk = libs.versions.androidMinSdk.get().toInt() - targetSdk = libs.versions.androidTargetSdk.get().toInt() - } -} - dependencies { add("kspCommonMainMetadata", project(":ksp:mutable-ui-processor")) add("kspAndroid", project(":ksp:mutable-ui-processor")) diff --git a/appyx-components/experimental/puzzle15/android/build.gradle.kts b/appyx-components/experimental/puzzle15/android/build.gradle.kts index 0711db98b..d4c271393 100644 --- a/appyx-components/experimental/puzzle15/android/build.gradle.kts +++ b/appyx-components/experimental/puzzle15/android/build.gradle.kts @@ -3,28 +3,8 @@ plugins { id("org.jetbrains.compose") } - -android { - namespace = "com.bumble.appyx.components.experimental.puzzle15.android" - compileSdk = libs.versions.androidCompileSdk.get().toInt() - defaultConfig { - minSdk = libs.versions.androidMinSdk.get().toInt() - targetSdk = libs.versions.androidTargetSdk.get().toInt() - - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - - testOptions { - unitTests.all { - it.useJUnitPlatform() - } - } - packagingOptions { - resources.excludes.apply { - add("META-INF/LICENSE.md") - add("META-INF/LICENSE-notice.md") - } - } +appyx { + namespace.set("com.bumble.appyx.components.experimental.puzzle15.android") } dependencies { diff --git a/appyx-components/experimental/puzzle15/common/build.gradle.kts b/appyx-components/experimental/puzzle15/common/build.gradle.kts index c90e9c889..d88f88de3 100644 --- a/appyx-components/experimental/puzzle15/common/build.gradle.kts +++ b/appyx-components/experimental/puzzle15/common/build.gradle.kts @@ -7,6 +7,10 @@ plugins { id("com.google.devtools.ksp") } +appyx { + androidNamespace.set("com.bumble.appyx.components.experimental.puzzle15.common") +} + kotlin { android { publishLibraryVariants("release") @@ -40,17 +44,6 @@ kotlin { } } -android { - namespace = "com.bumble.appyx.components.experimental.puzzle15.common" - compileSdk = libs.versions.androidCompileSdk.get().toInt() - sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") - - defaultConfig { - minSdk = libs.versions.androidMinSdk.get().toInt() - targetSdk = libs.versions.androidTargetSdk.get().toInt() - } -} - dependencies { add("kspCommonMainMetadata", project(":ksp:mutable-ui-processor")) add("kspAndroid", project(":ksp:mutable-ui-processor")) diff --git a/appyx-components/internal/test-drive/android/build.gradle.kts b/appyx-components/internal/test-drive/android/build.gradle.kts index 22fd33f4e..aa9d0888c 100644 --- a/appyx-components/internal/test-drive/android/build.gradle.kts +++ b/appyx-components/internal/test-drive/android/build.gradle.kts @@ -2,31 +2,10 @@ plugins { id("com.bumble.appyx.android.library") id("org.jetbrains.compose") id("appyx-screenshots") - kotlin("android") } - -android { - namespace = "com.bumble.appyx.components.internal.testdrive.android" - compileSdk = libs.versions.androidCompileSdk.get().toInt() - defaultConfig { - minSdk = libs.versions.androidMinSdk.get().toInt() - targetSdk = libs.versions.androidTargetSdk.get().toInt() - - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - - testOptions { - unitTests.all { - it.useJUnitPlatform() - } - } - packagingOptions { - resources.excludes.apply { - add("META-INF/LICENSE.md") - add("META-INF/LICENSE-notice.md") - } - } +appyx { + namespace.set("com.bumble.appyx.components.internal.testdrive.android") } dependencies { diff --git a/appyx-components/internal/test-drive/common/build.gradle.kts b/appyx-components/internal/test-drive/common/build.gradle.kts index 77d0d2b92..a25f90532 100644 --- a/appyx-components/internal/test-drive/common/build.gradle.kts +++ b/appyx-components/internal/test-drive/common/build.gradle.kts @@ -7,6 +7,10 @@ plugins { id("com.google.devtools.ksp") } +appyx { + androidNamespace.set("com.bumble.appyx.components.internal.testdrive") +} + kotlin { android { publishLibraryVariants("release") @@ -41,16 +45,6 @@ kotlin { } } -android { - compileSdk = libs.versions.androidCompileSdk.get().toInt() - sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") - - defaultConfig { - minSdk = libs.versions.androidMinSdk.get().toInt() - targetSdk = libs.versions.androidTargetSdk.get().toInt() - } -} - dependencies { add("kspCommonMainMetadata", project(":ksp:mutable-ui-processor")) add("kspAndroid", project(":ksp:mutable-ui-processor")) diff --git a/appyx-components/stable/backstack/android/build.gradle.kts b/appyx-components/stable/backstack/android/build.gradle.kts index f6466e4c3..80de1b1ec 100644 --- a/appyx-components/stable/backstack/android/build.gradle.kts +++ b/appyx-components/stable/backstack/android/build.gradle.kts @@ -3,28 +3,8 @@ plugins { id("org.jetbrains.compose") } - -android { - namespace = "com.bumble.appyx.components.backstack.android" - compileSdk = libs.versions.androidCompileSdk.get().toInt() - defaultConfig { - minSdk = libs.versions.androidMinSdk.get().toInt() - targetSdk = libs.versions.androidTargetSdk.get().toInt() - - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - - testOptions { - unitTests.all { - it.useJUnitPlatform() - } - } - packagingOptions { - resources.excludes.apply { - add("META-INF/LICENSE.md") - add("META-INF/LICENSE-notice.md") - } - } +appyx { + namespace.set("com.bumble.appyx.components.backstack.android") } dependencies { @@ -35,10 +15,6 @@ dependencies { androidTestImplementation(project(":appyx-interactions:android")) androidTestImplementation(project(":appyx-interactions:appyx-interactions")) androidTestImplementation(libs.compose.ui.test.junit4) - androidTestImplementation(libs.junit.api) - testRuntimeOnly(libs.junit.engine) - testRuntimeOnly(libs.junit.vintage) - androidTestImplementation(libs.compose.ui.test.manifest) } diff --git a/appyx-components/stable/backstack/common/build.gradle.kts b/appyx-components/stable/backstack/common/build.gradle.kts index 05999f239..32399e451 100644 --- a/appyx-components/stable/backstack/common/build.gradle.kts +++ b/appyx-components/stable/backstack/common/build.gradle.kts @@ -7,6 +7,10 @@ plugins { id("com.google.devtools.ksp") } +appyx { + androidNamespace.set("com.bumble.appyx.components.backstack") +} + kotlin { android { publishLibraryVariants("release") @@ -41,16 +45,6 @@ kotlin { } } -android { - compileSdk = libs.versions.androidCompileSdk.get().toInt() - sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") - - defaultConfig { - minSdk = libs.versions.androidMinSdk.get().toInt() - targetSdk = libs.versions.androidTargetSdk.get().toInt() - } -} - dependencies { add("kspCommonMainMetadata", project(":ksp:mutable-ui-processor")) add("kspAndroid", project(":ksp:mutable-ui-processor")) diff --git a/appyx-components/stable/spotlight/android/build.gradle.kts b/appyx-components/stable/spotlight/android/build.gradle.kts index b8a2f8b59..a7f84f7a4 100644 --- a/appyx-components/stable/spotlight/android/build.gradle.kts +++ b/appyx-components/stable/spotlight/android/build.gradle.kts @@ -4,28 +4,8 @@ plugins { id("appyx-screenshots") } - -android { - namespace = "com.bumble.appyx.components.spotlight.android" - compileSdk = libs.versions.androidCompileSdk.get().toInt() - defaultConfig { - minSdk = libs.versions.androidMinSdk.get().toInt() - targetSdk = libs.versions.androidTargetSdk.get().toInt() - - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - - testOptions { - unitTests.all { - it.useJUnitPlatform() - } - } - packagingOptions { - resources.excludes.apply { - add("META-INF/LICENSE.md") - add("META-INF/LICENSE-notice.md") - } - } +appyx { + namespace.set("com.bumble.appyx.components.spotlight.android") } dependencies { @@ -38,9 +18,5 @@ dependencies { androidTestImplementation(project(":appyx-interactions:android")) androidTestImplementation(libs.compose.ui.test.junit4) androidTestImplementation(libs.junit.api) - - testRuntimeOnly(libs.junit.engine) - testRuntimeOnly(libs.junit.vintage) - androidTestImplementation(libs.compose.ui.test.manifest) } diff --git a/appyx-components/stable/spotlight/common/build.gradle.kts b/appyx-components/stable/spotlight/common/build.gradle.kts index cd8b37532..863674d5c 100644 --- a/appyx-components/stable/spotlight/common/build.gradle.kts +++ b/appyx-components/stable/spotlight/common/build.gradle.kts @@ -7,6 +7,10 @@ plugins { id("com.google.devtools.ksp") } +appyx { + androidNamespace.set("com.bumble.appyx.components.spotlight") +} + kotlin { android { publishLibraryVariants("release") @@ -44,16 +48,6 @@ kotlin { } } -android { - compileSdk = libs.versions.androidCompileSdk.get().toInt() - sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") - - defaultConfig { - minSdk = libs.versions.androidMinSdk.get().toInt() - targetSdk = libs.versions.androidTargetSdk.get().toInt() - } -} - dependencies { add("kspCommonMainMetadata", project(":ksp:mutable-ui-processor")) add("kspAndroid", project(":ksp:mutable-ui-processor")) diff --git a/appyx-interactions/android/build.gradle.kts b/appyx-interactions/android/build.gradle.kts index fb0b24d74..302ace0bd 100644 --- a/appyx-interactions/android/build.gradle.kts +++ b/appyx-interactions/android/build.gradle.kts @@ -3,29 +3,8 @@ plugins { id("org.jetbrains.compose") } - -android { - namespace = "com.bumble.appyx.interactions.android" - compileSdk = libs.versions.androidCompileSdk.get().toInt() - defaultConfig { - minSdk = libs.versions.androidMinSdk.get().toInt() - targetSdk = libs.versions.androidTargetSdk.get().toInt() - - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - - testOptions { - unitTests.all { - it.useJUnitPlatform() - } - } - - packagingOptions { - resources.excludes.apply { - add("META-INF/LICENSE.md") - add("META-INF/LICENSE-notice.md") - } - } +appyx { + namespace.set("com.bumble.appyx.interactions.android") } dependencies { @@ -38,8 +17,5 @@ dependencies { implementation(composeBom) androidTestImplementation(composeBom) - testRuntimeOnly(libs.junit.engine) - testRuntimeOnly(libs.junit.vintage) - debugRuntimeOnly(libs.compose.ui.test.manifest) } diff --git a/appyx-interactions/common/build.gradle.kts b/appyx-interactions/common/build.gradle.kts index 381481403..9b1568389 100644 --- a/appyx-interactions/common/build.gradle.kts +++ b/appyx-interactions/common/build.gradle.kts @@ -7,6 +7,10 @@ plugins { id("appyx-publish-multiplatform") } +appyx { + androidNamespace.set("com.bumble.appyx.interactions.common") +} + kotlin { android { publishLibraryVariants("release") @@ -60,13 +64,3 @@ kotlin { } } } - -android { - namespace = "com.bumble.appyx.interactions.common" - compileSdk = libs.versions.androidCompileSdk.get().toInt() - sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") - defaultConfig { - minSdk = libs.versions.androidMinSdk.get().toInt() - targetSdk = libs.versions.androidTargetSdk.get().toInt() - } -} diff --git a/appyx-navigation/android/build.gradle.kts b/appyx-navigation/android/build.gradle.kts index 607da8468..0d9d5d5e8 100644 --- a/appyx-navigation/android/build.gradle.kts +++ b/appyx-navigation/android/build.gradle.kts @@ -1,29 +1,14 @@ plugins { id("com.bumble.appyx.android.library") id("org.jetbrains.compose") - id("kotlin-parcelize") } -android { - namespace = "com.bumble.appyx.navigation.android" - compileSdk = libs.versions.androidCompileSdk.get().toInt() - defaultConfig { - minSdk = libs.versions.androidMinSdk.get().toInt() - targetSdk = libs.versions.androidTargetSdk.get().toInt() +appyx { + namespace.set("com.bumble.appyx.navigation.android") - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } buildFeatures { - compose = true - } - composeOptions { - kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get() - } - testOptions { - unitTests.all { - // interface method default implementation - it.exclude("**/*\$DefaultImpls.class") - } + compose.set(true) + kotlinParcelize.set(true) } } diff --git a/appyx-navigation/common/build.gradle.kts b/appyx-navigation/common/build.gradle.kts index 139d1a308..dfb68a786 100644 --- a/appyx-navigation/common/build.gradle.kts +++ b/appyx-navigation/common/build.gradle.kts @@ -5,6 +5,10 @@ plugins { id("appyx-publish-multiplatform") } +appyx { + androidNamespace.set("com.bumble.appyx.navigation") +} + kotlin { android { publishLibraryVariants("release") @@ -62,21 +66,12 @@ kotlin { } android { - namespace = "com.bumble.appyx.navigation" - compileSdk = libs.versions.androidCompileSdk.get().toInt() - sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") - defaultConfig { - minSdk = libs.versions.androidMinSdk.get().toInt() - targetSdk = libs.versions.androidTargetSdk.get().toInt() - } buildFeatures { compose = true } composeOptions { kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get() } - testOptions { - } dependencies { val composeBom = platform(libs.compose.bom) diff --git a/build.gradle.kts b/build.gradle.kts index dd56a142a..d417d223f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -42,7 +42,10 @@ dependencyAnalysis { // This is used to add the testing activity to the debug manifest // However since not code is referenced, it is raised as unused. - ":utils:testing-ui-activity" + ":utils:testing-ui-activity", + + // Convenience for convention plugins to avoid needing to define this. + "org.junit.jupiter:junit-jupiter-api" ) } } diff --git a/demos/appyx-interactions/android/build.gradle.kts b/demos/appyx-interactions/android/build.gradle.kts index caffbab61..22a629dae 100644 --- a/demos/appyx-interactions/android/build.gradle.kts +++ b/demos/appyx-interactions/android/build.gradle.kts @@ -1,36 +1,13 @@ plugins { id("com.bumble.appyx.android.application") - id("kotlin-parcelize") } -android { - compileSdk = libs.versions.androidCompileSdk.get().toInt() - namespace = "com.bumble.appyx.demos.appyxinteractions" +appyx { + namespace.set("com.bumble.appyx.demos.appyxinteractions") - defaultConfig { - applicationId = "com.bumble.appyx.demos.appyxinteractions" - minSdk = libs.versions.androidMinSdk.get().toInt() - targetSdk = libs.versions.androidTargetSdk.get().toInt() - versionCode = 1 - versionName = "1.0" - - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - vectorDrawables { - useSupportLibrary = true - } - } buildFeatures { - compose = true - } - composeOptions { - kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get() - } - - packagingOptions { - resources.excludes.apply { - add("META-INF/LICENSE.md") - add("META-INF/LICENSE-notice.md") - } + compose.set(true) + kotlinParcelize.set(true) } } diff --git a/demos/appyx-navigation/android/build.gradle.kts b/demos/appyx-navigation/android/build.gradle.kts index 8650ddce7..69c5cf26f 100644 --- a/demos/appyx-navigation/android/build.gradle.kts +++ b/demos/appyx-navigation/android/build.gradle.kts @@ -1,24 +1,17 @@ plugins { id("com.bumble.appyx.android.application") - id("kotlin-parcelize") } -android { - compileSdk = libs.versions.androidCompileSdk.get().toInt() - namespace = "com.bumble.appyx.demos.appyxnavigation" - - defaultConfig { - applicationId = "com.bumble.demos.samples.appyxnavigation" - minSdk = libs.versions.androidMinSdk.get().toInt() - targetSdk = libs.versions.androidTargetSdk.get().toInt() - versionCode = 1 - versionName = "1.0" +appyx { + namespace.set("com.bumble.appyx.demos.appyxnavigation") - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - vectorDrawables { - useSupportLibrary = true - } + buildFeatures { + compose.set(true) + kotlinParcelize.set(true) } +} + +android { signingConfigs { create("sampleConfig") { // debug is already created storeFile = file("debug.keystore") @@ -41,12 +34,6 @@ android { signingConfig = signingConfigs.findByName("sampleConfig") } } - buildFeatures { - compose = true - } - composeOptions { - kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get() - } } dependencies { diff --git a/demos/appyx-navigation/common/build.gradle.kts b/demos/appyx-navigation/common/build.gradle.kts index a90b96375..b84371c5c 100644 --- a/demos/appyx-navigation/common/build.gradle.kts +++ b/demos/appyx-navigation/common/build.gradle.kts @@ -7,6 +7,10 @@ plugins { id("com.google.devtools.ksp") } +appyx { + androidNamespace.set("com.bumble.appyx.demos.appyxnavigation.common") +} + kotlin { android { publishLibraryVariants("release") @@ -66,13 +70,6 @@ kotlin { } android { - namespace = "com.bumble.appyx.demos.appyxnavigation.common" - compileSdk = libs.versions.androidCompileSdk.get().toInt() - sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") - defaultConfig { - minSdk = libs.versions.androidMinSdk.get().toInt() - targetSdk = libs.versions.androidTargetSdk.get().toInt() - } buildFeatures { compose = true } diff --git a/demos/common/build.gradle.kts b/demos/common/build.gradle.kts index 4fdd7b67c..90a3339f3 100644 --- a/demos/common/build.gradle.kts +++ b/demos/common/build.gradle.kts @@ -6,6 +6,10 @@ plugins { id("appyx-publish-multiplatform") } +appyx { + androidNamespace.set("com.bumble.appyx.samples.common") +} + kotlin { android { publishLibraryVariants("release") @@ -46,13 +50,3 @@ kotlin { val desktopMain by getting } } - -android { - compileSdk = libs.versions.androidCompileSdk.get().toInt() - sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") - - defaultConfig { - minSdk = libs.versions.androidMinSdk.get().toInt() - targetSdk = libs.versions.androidTargetSdk.get().toInt() - } -} diff --git a/demos/navigation-compose/build.gradle.kts b/demos/navigation-compose/build.gradle.kts index 8d9ddbd86..88d89106e 100644 --- a/demos/navigation-compose/build.gradle.kts +++ b/demos/navigation-compose/build.gradle.kts @@ -1,32 +1,13 @@ plugins { id("com.bumble.appyx.android.library") - id("kotlin-parcelize") } -android { - namespace = "com.bumble.appyx.sample.navigation.compose" - compileSdk = libs.versions.androidCompileSdk.get().toInt() +appyx { + namespace.set("com.bumble.appyx.sample.navigation.compose") - defaultConfig { - minSdk = libs.versions.androidMinSdk.get().toInt() - targetSdk = libs.versions.androidTargetSdk.get().toInt() - - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - vectorDrawables { - useSupportLibrary = true - } - } - buildTypes { - release { - isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") - } - } buildFeatures { - compose = true - } - composeOptions { - kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get() + compose.set(true) + kotlinParcelize.set(true) } } diff --git a/plugins/convention/src/main/kotlin/com/bumble/appyx/ProjectExt.kt b/plugins/convention/src/main/kotlin/com/bumble/appyx/ProjectExt.kt new file mode 100644 index 000000000..e806a4e35 --- /dev/null +++ b/plugins/convention/src/main/kotlin/com/bumble/appyx/ProjectExt.kt @@ -0,0 +1,9 @@ +package com.bumble.appyx + +import org.gradle.api.Project +import org.gradle.api.artifacts.VersionCatalogsExtension + +val Project.versionCatalog + get() = extensions + .getByType(VersionCatalogsExtension::class.java) + .named("libs") diff --git a/plugins/convention/src/main/kotlin/com/bumble/appyx/android/AndroidCommonConfiguration.kt b/plugins/convention/src/main/kotlin/com/bumble/appyx/android/AndroidCommonConfiguration.kt index 67a279bfe..deb45afa6 100644 --- a/plugins/convention/src/main/kotlin/com/bumble/appyx/android/AndroidCommonConfiguration.kt +++ b/plugins/convention/src/main/kotlin/com/bumble/appyx/android/AndroidCommonConfiguration.kt @@ -1,14 +1,87 @@ package com.bumble.appyx.android +import com.android.build.api.dsl.CommonExtension +import com.android.build.api.dsl.DefaultConfig +import com.android.build.api.variant.AndroidComponentsExtension +import com.bumble.appyx.versionCatalog import org.gradle.api.Project +import org.gradle.api.artifacts.VersionCatalog +import org.gradle.api.artifacts.VersionCatalogsExtension +import org.gradle.kotlin.dsl.getByType -internal fun Project.applyAndroidPlugin( +internal inline fun < + reified ConfigT : DefaultConfig, + reified DslExtensionT : CommonExtension<*, *, ConfigT, *>, + reified ComponentsExtensionT : AndroidComponentsExtension + > Project.applyAndroidPlugin( androidPluginId: String, + noinline onExtension: DslExtensionT.(AndroidConventionExtension, VersionCatalog) -> Unit = { _, _ -> }, ) { - extensions.create("appyx", AndroidConventionExtension::class.java) + val appyxExtension = extensions.create("appyx", AndroidConventionExtension::class.java) + appyxExtension.initDefaults() plugins.apply(androidPluginId) plugins.apply("kotlin-android") plugins.apply("appyx-lint") plugins.apply("appyx-detekt") + + val libs = project.versionCatalog + + dependencies.add("testImplementation", libs.findLibrary("junit-api").get()) + dependencies.add("testRuntimeOnly", libs.findLibrary("junit-engine").get()) + + extensions + .getByType() + .finalizeDsl { extension -> + extension.configure( + appyxExtension = appyxExtension, + libs = libs, + ) + onExtension(extension, appyxExtension, libs) + + if (appyxExtension.buildFeatures.kotlinParcelize.get()) { + plugins.apply("kotlin-parcelize") + } + } +} + +private fun CommonExtension<*, *, DefaultConfigT, *>.configure( + appyxExtension: AndroidConventionExtension, + libs: VersionCatalog, +) { + namespace = appyxExtension.namespace.get() + compileSdk = libs.findVersion("androidCompileSdk").get().displayName.toInt() + + defaultConfig { + minSdk = libs.findVersion("androidMinSdk").get().displayName.toInt() + + vectorDrawables { + useSupportLibrary = true + } + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + val composeEnabled = appyxExtension.buildFeatures.compose.get() + buildFeatures { + compose = composeEnabled + } + if (composeEnabled) { + composeOptions { + kotlinCompilerExtensionVersion = + libs.findVersion("composeCompiler").get().displayName + } + } + + testOptions { + unitTests.all { + it.useJUnitPlatform() + } + } + + packagingOptions { + resources.excludes.apply { + add("META-INF/LICENSE.md") + add("META-INF/LICENSE-notice.md") + } + } } diff --git a/plugins/convention/src/main/kotlin/com/bumble/appyx/android/AndroidConventionExtension.kt b/plugins/convention/src/main/kotlin/com/bumble/appyx/android/AndroidConventionExtension.kt index 61b0fc731..01b8435d4 100644 --- a/plugins/convention/src/main/kotlin/com/bumble/appyx/android/AndroidConventionExtension.kt +++ b/plugins/convention/src/main/kotlin/com/bumble/appyx/android/AndroidConventionExtension.kt @@ -1,5 +1,30 @@ package com.bumble.appyx.android import com.bumble.appyx.BaseConventionExtension +import org.gradle.api.provider.Property +import org.gradle.api.tasks.Nested -interface AndroidConventionExtension : BaseConventionExtension +abstract class AndroidConventionExtension : BaseConventionExtension { + abstract val namespace: Property + + @get:Nested + abstract val buildFeatures: BuildFeatures + + fun buildFeatures(action: BuildFeatures.() -> Unit) { + action(buildFeatures) + } + + fun initDefaults() { + buildFeatures.initDefaults() + } + + abstract class BuildFeatures { + abstract val compose: Property + abstract val kotlinParcelize: Property + + fun initDefaults() { + compose.convention(false) + kotlinParcelize.convention(false) + } + } +} diff --git a/plugins/convention/src/main/kotlin/com/bumble/appyx/android/application/AndroidApplicationConventionPlugin.kt b/plugins/convention/src/main/kotlin/com/bumble/appyx/android/application/AndroidApplicationConventionPlugin.kt index f8e35cbdc..fb254975b 100644 --- a/plugins/convention/src/main/kotlin/com/bumble/appyx/android/application/AndroidApplicationConventionPlugin.kt +++ b/plugins/convention/src/main/kotlin/com/bumble/appyx/android/application/AndroidApplicationConventionPlugin.kt @@ -1,5 +1,8 @@ package com.bumble.appyx.android.application +import com.android.build.api.dsl.ApplicationDefaultConfig +import com.android.build.api.dsl.ApplicationExtension +import com.android.build.api.variant.ApplicationAndroidComponentsExtension import com.bumble.appyx.android.applyAndroidPlugin import org.gradle.api.Plugin import org.gradle.api.Project @@ -7,8 +10,15 @@ import org.gradle.api.Project class AndroidApplicationConventionPlugin : Plugin { override fun apply(project: Project) { project - .applyAndroidPlugin( + .applyAndroidPlugin( "com.android.application" - ) + ) { extension, libs -> + defaultConfig { + applicationId = extension.namespace.get() + targetSdk = libs.findVersion("androidTargetSdk").get().displayName.toInt() + versionCode = 1 + versionName = "1.0" + } + } } } diff --git a/plugins/convention/src/main/kotlin/com/bumble/appyx/android/library/AndroidLibraryConventionPlugin.kt b/plugins/convention/src/main/kotlin/com/bumble/appyx/android/library/AndroidLibraryConventionPlugin.kt index 486fc1b55..d8947306b 100644 --- a/plugins/convention/src/main/kotlin/com/bumble/appyx/android/library/AndroidLibraryConventionPlugin.kt +++ b/plugins/convention/src/main/kotlin/com/bumble/appyx/android/library/AndroidLibraryConventionPlugin.kt @@ -1,5 +1,8 @@ package com.bumble.appyx.android.library +import com.android.build.api.dsl.LibraryDefaultConfig +import com.android.build.api.dsl.LibraryExtension +import com.android.build.api.variant.LibraryAndroidComponentsExtension import com.bumble.appyx.android.applyAndroidPlugin import org.gradle.api.Plugin import org.gradle.api.Project @@ -7,8 +10,12 @@ import org.gradle.api.Project class AndroidLibraryConventionPlugin : Plugin { override fun apply(project: Project) { project - .applyAndroidPlugin( + .applyAndroidPlugin( "com.android.library" - ) + ) { extension, libs -> + defaultConfig { + targetSdk = libs.findVersion("androidTargetSdk").get().displayName.toInt() + } + } } } diff --git a/plugins/convention/src/main/kotlin/com/bumble/appyx/multiplatform/MultiplatformConventionExtension.kt b/plugins/convention/src/main/kotlin/com/bumble/appyx/multiplatform/MultiplatformConventionExtension.kt index 14224c812..f79a413e6 100644 --- a/plugins/convention/src/main/kotlin/com/bumble/appyx/multiplatform/MultiplatformConventionExtension.kt +++ b/plugins/convention/src/main/kotlin/com/bumble/appyx/multiplatform/MultiplatformConventionExtension.kt @@ -1,5 +1,8 @@ package com.bumble.appyx.multiplatform import com.bumble.appyx.BaseConventionExtension +import org.gradle.api.provider.Property -interface MultiplatformConventionExtension : BaseConventionExtension +abstract class MultiplatformConventionExtension : BaseConventionExtension { + abstract val androidNamespace: Property +} diff --git a/plugins/convention/src/main/kotlin/com/bumble/appyx/multiplatform/MultiplatformConventionPlugin.kt b/plugins/convention/src/main/kotlin/com/bumble/appyx/multiplatform/MultiplatformConventionPlugin.kt index 26577dac5..6e77b32bd 100644 --- a/plugins/convention/src/main/kotlin/com/bumble/appyx/multiplatform/MultiplatformConventionPlugin.kt +++ b/plugins/convention/src/main/kotlin/com/bumble/appyx/multiplatform/MultiplatformConventionPlugin.kt @@ -1,13 +1,19 @@ package com.bumble.appyx.multiplatform +import com.android.build.api.variant.LibraryAndroidComponentsExtension +import com.bumble.appyx.versionCatalog import io.gitlab.arturbosch.detekt.extensions.DetektExtension 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.get +import org.gradle.kotlin.dsl.getByType class MultiplatformConventionPlugin : Plugin { override fun apply(project: Project) { - project.extensions.create("appyx", MultiplatformConventionExtension::class.java) + val conventionExtension = + project.extensions.create("appyx", MultiplatformConventionExtension::class.java) project.plugins.apply("kotlin-multiplatform") project.plugins.apply("appyx-detekt") @@ -24,5 +30,24 @@ class MultiplatformConventionPlugin : Plugin { "src/jsTest/kotlin", ) } + + project.plugins.withId("com.android.library") { + project.extensions + .getByType() + .finalizeDsl { extension -> + val libs = project.versionCatalog + + with(extension) { + namespace = conventionExtension.androidNamespace.get() + compileSdk = libs.findVersion("androidCompileSdk").get().displayName.toInt() + sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") + + defaultConfig { + minSdk = libs.findVersion("androidMinSdk").get().displayName.toInt() + targetSdk = libs.findVersion("androidTargetSdk").get().displayName.toInt() + } + } + } + } } } diff --git a/utils/customisations/build.gradle.kts b/utils/customisations/build.gradle.kts index b2f723889..8bc96599b 100644 --- a/utils/customisations/build.gradle.kts +++ b/utils/customisations/build.gradle.kts @@ -4,6 +4,10 @@ plugins { id("appyx-publish-multiplatform") } +appyx { + androidNamespace.set("com.bumble.appyx.utils.customisation") +} + publishingPlugin { artifactId = "utils-customisations" } @@ -29,13 +33,3 @@ kotlin { val jsMain by getting } } - -android { - namespace = "com.bumble.appyx.utils.customisation" - compileSdk = libs.versions.androidCompileSdk.get().toInt() - sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") - defaultConfig { - minSdk = libs.versions.androidMinSdk.get().toInt() - targetSdk = libs.versions.androidTargetSdk.get().toInt() - } -} diff --git a/utils/interop-ribs/build.gradle.kts b/utils/interop-ribs/build.gradle.kts index d9065c4cf..fc05f83f2 100644 --- a/utils/interop-ribs/build.gradle.kts +++ b/utils/interop-ribs/build.gradle.kts @@ -1,6 +1,5 @@ plugins { id("com.bumble.appyx.android.library") - id("kotlin-parcelize") id("appyx-publish-android") } @@ -8,21 +7,12 @@ publishingPlugin { artifactId = "utils-interop-ribs" } -android { - namespace = "com.bumble.appyx.utils.interop.ribs" - compileSdk = libs.versions.androidCompileSdk.get().toInt() +appyx { + namespace.set("com.bumble.appyx.utils.interop.ribs") - defaultConfig { - minSdk = libs.versions.androidMinSdk.get().toInt() - targetSdk = libs.versions.androidTargetSdk.get().toInt() - - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } buildFeatures { - compose = true - } - composeOptions { - kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get() + compose.set(true) + kotlinParcelize.set(true) } } diff --git a/utils/interop-rx2/build.gradle.kts b/utils/interop-rx2/build.gradle.kts index 3c85c9ff4..4767297e4 100644 --- a/utils/interop-rx2/build.gradle.kts +++ b/utils/interop-rx2/build.gradle.kts @@ -7,21 +7,8 @@ publishingPlugin { artifactId = "utils-interop-rx2" } -android { - namespace = "com.bumble.appyx.utils.interop.rx2" - compileSdk = libs.versions.androidCompileSdk.get().toInt() - - defaultConfig { - minSdk = libs.versions.androidMinSdk.get().toInt() - targetSdk = libs.versions.androidTargetSdk.get().toInt() - - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - testOptions { - unitTests.all { - it.useJUnitPlatform() - } - } +appyx { + namespace.set("com.bumble.appyx.utils.interop.rx2") } dependencies { @@ -31,7 +18,4 @@ dependencies { implementation(libs.kotlin.coroutines.rx2) implementation(libs.androidx.lifecycle.java8) - - testImplementation(libs.junit.api) - testRuntimeOnly(libs.junit.engine) } diff --git a/utils/interop-rx3/build.gradle.kts b/utils/interop-rx3/build.gradle.kts index 3ae24b41c..b8b1d5657 100644 --- a/utils/interop-rx3/build.gradle.kts +++ b/utils/interop-rx3/build.gradle.kts @@ -7,21 +7,8 @@ publishingPlugin { artifactId = "utils-interop-rx3" } -android { - namespace = "com.bumble.appyx.utils.interop.rx3" - compileSdk = libs.versions.androidCompileSdk.get().toInt() - - defaultConfig { - minSdk = libs.versions.androidMinSdk.get().toInt() - targetSdk = libs.versions.androidTargetSdk.get().toInt() - - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - testOptions { - unitTests.all { - it.useJUnitPlatform() - } - } +appyx { + namespace.set("com.bumble.appyx.utils.interop.rx3") } dependencies { @@ -30,7 +17,4 @@ dependencies { api(libs.rxrelay3) implementation(libs.androidx.lifecycle.java8) - - testImplementation(libs.junit.api) - testRuntimeOnly(libs.junit.engine) } diff --git a/utils/multiplatform/build.gradle.kts b/utils/multiplatform/build.gradle.kts index 8e1d0a205..33af06409 100644 --- a/utils/multiplatform/build.gradle.kts +++ b/utils/multiplatform/build.gradle.kts @@ -6,6 +6,10 @@ plugins { id("appyx-publish-multiplatform") } +appyx { + androidNamespace.set("com.bumble.appyx.utils.multiplatform") +} + publishingPlugin { artifactId = "utils-multiplatform" } @@ -39,13 +43,3 @@ kotlin { val jsMain by getting } } - -android { - namespace = "com.bumble.appyx.utils.multiplatform" - compileSdk = libs.versions.androidCompileSdk.get().toInt() - sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") - defaultConfig { - minSdk = libs.versions.androidMinSdk.get().toInt() - targetSdk = libs.versions.androidTargetSdk.get().toInt() - } -} diff --git a/utils/testing-junit4/build.gradle.kts b/utils/testing-junit4/build.gradle.kts index 2b5a15d09..d4fd75c8a 100644 --- a/utils/testing-junit4/build.gradle.kts +++ b/utils/testing-junit4/build.gradle.kts @@ -7,21 +7,11 @@ publishingPlugin { artifactId = "utils-testing-junit4" } -android { - namespace = "com.bumble.appyx.utils.testing.junit4" - compileSdk = libs.versions.androidCompileSdk.get().toInt() +appyx { + namespace.set("com.bumble.appyx.utils.testing.junit4") - defaultConfig { - minSdk = libs.versions.androidMinSdk.get().toInt() - targetSdk = libs.versions.androidTargetSdk.get().toInt() - - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } buildFeatures { - compose = true - } - composeOptions { - kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get() + compose.set(true) } } diff --git a/utils/testing-junit5/build.gradle.kts b/utils/testing-junit5/build.gradle.kts index f90c11830..9c5bc696f 100644 --- a/utils/testing-junit5/build.gradle.kts +++ b/utils/testing-junit5/build.gradle.kts @@ -7,25 +7,11 @@ publishingPlugin { artifactId = "utils-testing-junit5" } -android { - namespace = "com.bumble.appyx.utils.testing.junit5" - compileSdk = libs.versions.androidCompileSdk.get().toInt() +appyx { + namespace.set("com.bumble.appyx.utils.testing.junit5") - defaultConfig { - minSdk = libs.versions.androidMinSdk.get().toInt() - targetSdk = libs.versions.androidTargetSdk.get().toInt() - - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } buildFeatures { - compose = true - } - composeOptions { - kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get() - } - packagingOptions { - exclude("META-INF/LICENSE.md") - exclude("META-INF/LICENSE-notice.md") + compose.set(true) } } diff --git a/utils/testing-ui-activity/build.gradle.kts b/utils/testing-ui-activity/build.gradle.kts index 2a2c3c742..615357462 100644 --- a/utils/testing-ui-activity/build.gradle.kts +++ b/utils/testing-ui-activity/build.gradle.kts @@ -7,19 +7,11 @@ publishingPlugin { artifactId = "utils-testing-ui-activity" } -android { - namespace = "com.bumble.appyx.utils.testing.ui.activity" - compileSdk = libs.versions.androidCompileSdk.get().toInt() +appyx { + namespace.set("com.bumble.appyx.utils.testing.ui.activity") - defaultConfig { - minSdk = libs.versions.androidMinSdk.get().toInt() - targetSdk = libs.versions.androidTargetSdk.get().toInt() - } buildFeatures { - compose = true - } - composeOptions { - kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get() + compose.set(true) } } diff --git a/utils/testing-ui/build.gradle.kts b/utils/testing-ui/build.gradle.kts index 9d5edfc5d..268bc9a7c 100644 --- a/utils/testing-ui/build.gradle.kts +++ b/utils/testing-ui/build.gradle.kts @@ -7,21 +7,11 @@ publishingPlugin { artifactId = "utils-testing-ui" } -android { - namespace = "com.bumble.appyx.utils.testing.ui" - compileSdk = libs.versions.androidCompileSdk.get().toInt() +appyx { + namespace.set("com.bumble.appyx.utils.testing.ui") - defaultConfig { - minSdk = libs.versions.androidMinSdk.get().toInt() - targetSdk = libs.versions.androidTargetSdk.get().toInt() - - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } buildFeatures { - compose = true - } - composeOptions { - kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get() + compose.set(true) } } diff --git a/utils/testing-unit-common/build.gradle.kts b/utils/testing-unit-common/build.gradle.kts index 2183a5015..d0ff2c45d 100644 --- a/utils/testing-unit-common/build.gradle.kts +++ b/utils/testing-unit-common/build.gradle.kts @@ -7,21 +7,11 @@ publishingPlugin { artifactId = "utils-testing-unit-common" } -android { - namespace = "com.bumble.appyx.utils.testing.unit.common" - compileSdk = libs.versions.androidCompileSdk.get().toInt() +appyx { + namespace.set("com.bumble.appyx.utils.testing.unit.common") - defaultConfig { - minSdk = libs.versions.androidMinSdk.get().toInt() - targetSdk = libs.versions.androidTargetSdk.get().toInt() - - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } buildFeatures { - compose = true - } - composeOptions { - kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get() + compose.set(true) } }