From 2aecc178c5a8884fb3856b1804f0d26b2ded9339 Mon Sep 17 00:00:00 2001 From: Erik Eelde Date: Fri, 3 May 2024 11:57:36 +0200 Subject: [PATCH] Mr emulator --- .github/workflows/pull-request.yml | 52 ++++++- build-logic/conventions/build.gradle.kts | 6 +- build-logic/conventions/settings.gradle.kts | 13 +- ...android.application-conventions.gradle.kts | 71 +++++++-- ...les.android.library-conventions.gradle.kts | 2 - ...gles.android.module-conventions.gradle.kts | 53 +++++++ .../toggles.detekt-conventions.gradle.kts | 2 +- build.gradle.kts | 15 ++ gradle.properties | 4 +- gradle/libs.versions.toml | 146 +++++++----------- gradle/wrapper/gradle-wrapper.properties | 2 +- modules/applications/build.gradle.kts | 7 +- .../toggles/applications/ExampleSharedTest.kt | 26 ++++ .../resources/robolectric.properties | 1 + modules/booleanconfiguration/build.gradle.kts | 7 +- modules/compose-theme/build.gradle.kts | 7 +- modules/configurations/build.gradle.kts | 7 +- modules/enumconfiguration/build.gradle.kts | 7 +- modules/help/build.gradle.kts | 7 +- modules/integerconfiguration/build.gradle.kts | 7 +- modules/oss/build.gradle.kts | 7 +- modules/provider/build.gradle.kts | 8 +- modules/stringconfiguration/build.gradle.kts | 7 +- scripts/pr_check.sh | 17 ++ settings.gradle.kts | 13 +- toggles-app/build.gradle.kts | 20 +++ toggles-core/settings.gradle.kts | 11 +- toggles-flow-noop/settings.gradle.kts | 11 +- toggles-flow/build.gradle.kts | 2 +- toggles-flow/settings.gradle.kts | 11 +- toggles-prefs-noop/settings.gradle.kts | 11 +- toggles-prefs/build.gradle.kts | 2 +- toggles-prefs/settings.gradle.kts | 11 +- .../toggles/applications/ExampleSharedTest.kt | 29 ++++ .../resources/robolectric.properties | 1 + 35 files changed, 408 insertions(+), 195 deletions(-) create mode 100644 modules/applications/src/sharedTest/java/se/eelde/toggles/applications/ExampleSharedTest.kt create mode 100644 modules/applications/src/sharedTest/resources/robolectric.properties create mode 100755 scripts/pr_check.sh create mode 100644 toggles-sample/src/sharedTest/java/se/eelde/toggles/applications/ExampleSharedTest.kt create mode 100644 toggles-sample/src/sharedTest/resources/robolectric.properties diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index e3014cce..439fbea9 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -30,7 +30,19 @@ jobs: - name: Setup Gradle uses: gradle/gradle-build-action@v2 - - name: Run app Checks + - name: Run test without shared tests + run: ./gradlew test -Pshared-tests-are-android-tests=false + +# - name: Run test with shared tests +# run: ./gradlew test -Pshared-tests-are-android-tests=true + + - name: Run test without shared tests + run: ./gradlew assembleAndroidTest -Pshared-tests-are-android-tests=false + +# - name: Run test with shared tests +# run: ./gradlew assembleAndroidTest -Pshared-tests-are-android-tests=true + + - name: Run check run: ./gradlew check - name: Run core Checks @@ -55,3 +67,41 @@ jobs: name: Reports path: '**/build/reports/*' retention-days: 2 + + emulator-tests: + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v4 + with: + fetch-depth: '0' + + - name: Check out java + uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: 17 + + - name: Copy CI gradle.properties + run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + + - name: Enable KVM group perms + run: | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules + sudo udevadm control --reload-rules + sudo udevadm trigger --name-match=kvm + + - name: run tests + run: ./gradlew :toggles-app:pixel2api30DebugAndroidTest + + - name: "Upload reports" + uses: actions/upload-artifact@v4 + if: failure() + with: + name: "Android test results" + path: '**/build/reports/*' + retention-days: 2 diff --git a/build-logic/conventions/build.gradle.kts b/build-logic/conventions/build.gradle.kts index ff3a239f..952804da 100644 --- a/build-logic/conventions/build.gradle.kts +++ b/build-logic/conventions/build.gradle.kts @@ -10,11 +10,13 @@ java { dependencies { // implementation("gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.7.2") - implementation("se.premex:ownership-gradle-plugin:0.0.11") + implementation(libs.se.premex.ownership.gradle.plugin) implementation(libs.io.gitlab.arturbosch.detekt.detekt.gradle.plugin) implementation(libs.com.android.tools.build.gradle) implementation(libs.org.jetbrains.kotlin.kotlin.gradle.plugin) - implementation("com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:1.9.10-1.0.13") + implementation(libs.com.google.devtools.ksp.com.google.devtools.ksp.gradle.plugin) + implementation(libs.com.squareup.kotlinpoet) + implementation(libs.org.jetbrains.kotlin.compose.compiler.gradle.plugin) // https://github.com/gradle/gradle/issues/15383 implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location)) diff --git a/build-logic/conventions/settings.gradle.kts b/build-logic/conventions/settings.gradle.kts index 427ea61f..7afd983f 100644 --- a/build-logic/conventions/settings.gradle.kts +++ b/build-logic/conventions/settings.gradle.kts @@ -1,4 +1,4 @@ -rootProject.name="conventions" +rootProject.name = "conventions" pluginManagement { repositories { @@ -23,6 +23,13 @@ dependencyResolutionManagement { } plugins { - id("com.gradle.enterprise") version "3.16.1" - id("org.gradle.toolchains.foojay-resolver-convention") version("0.7.0") + id("com.gradle.develocity") version "3.18" + id("org.gradle.toolchains.foojay-resolver-convention") version ("0.8.0") +} + +develocity { + buildScan { + termsOfUseUrl.set("https://gradle.com/help/legal-terms-of-use") + termsOfUseAgree.set("yes") + } } diff --git a/build-logic/conventions/src/main/kotlin/toggles.android.application-conventions.gradle.kts b/build-logic/conventions/src/main/kotlin/toggles.android.application-conventions.gradle.kts index aabf6ca6..ac268315 100644 --- a/build-logic/conventions/src/main/kotlin/toggles.android.application-conventions.gradle.kts +++ b/build-logic/conventions/src/main/kotlin/toggles.android.application-conventions.gradle.kts @@ -9,31 +9,19 @@ plugins { kotlin("android") id("kotlin-android") id("toggles.detekt-conventions") + id("org.jetbrains.kotlin.plugin.compose") } android { - compileSdk = 34 + compileSdk = 35 defaultConfig { minSdk = 21 - targetSdk = 34 + targetSdk = 35 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } - buildFeatures { - compose = true - } - - composeOptions { - kotlinCompilerExtensionVersion = libs.versions.androidx.compose.compiler.get() - } - - @Suppress("UnstableApiUsage") - testOptions { - unitTests.isIncludeAndroidResources = true - } - lint { baseline = file("lint-baseline.xml") checkReleaseBuilds = true @@ -41,6 +29,50 @@ android { warningsAsErrors = true lintConfig = File("../lint.xml") } + + testOptions { + animationsDisabled = true + execution = "ANDROIDX_TEST_ORCHESTRATOR" + unitTests { + isReturnDefaultValues = true + isIncludeAndroidResources = true + } + managedDevices { + devices { + maybeCreate("pixel2api30").apply { + // Use device profiles you typically see in Android Studio. + device = "Pixel 2" + // Use only API levels 30 and higher. + apiLevel = 30 + // To include Google services, use "google". + systemImageSource = "aosp" + } + } + } + } + + sourceSets { +// val sharedTestDir = "src/sharedTest/" +// if(project.file(sharedTestDir).exists()) { +// val sharedTestSourceDir = sharedTestDir + "java" +// val sharedTestResourceDir = sharedTestDir + "resources" +// val sharedIsAndroid = +// providers.gradleProperty("shared-tests-are-android-tests").get().toBoolean() +// if (sharedIsAndroid) { +// logger.lifecycle("Shared tests are androidTests") +// named("androidTest") { +// java.srcDir(sharedTestSourceDir) +// resources.srcDir(sharedTestResourceDir) +// } +// } else { +// logger.lifecycle("Shared tests are unitTests") +// named("test") { +// java.srcDir(sharedTestSourceDir) +// resources.srcDir(sharedTestResourceDir) +// } +// } +// } + } } kotlin { @@ -51,4 +83,13 @@ kotlin { dependencies { lintChecks(libs.com.slack.lint.compose.compose.lint.checks) + + testImplementation(libs.androidx.test.ext.junit) + testImplementation(libs.org.robolectric) + testImplementation(libs.androidx.test.runner) + + androidTestImplementation(libs.androidx.test.ext.junit) + androidTestImplementation(libs.androidx.test.runner) + + androidTestUtil(libs.androidx.test.orchestrator) } diff --git a/build-logic/conventions/src/main/kotlin/toggles.android.library-conventions.gradle.kts b/build-logic/conventions/src/main/kotlin/toggles.android.library-conventions.gradle.kts index 9a2b6651..050ac20b 100644 --- a/build-logic/conventions/src/main/kotlin/toggles.android.library-conventions.gradle.kts +++ b/build-logic/conventions/src/main/kotlin/toggles.android.library-conventions.gradle.kts @@ -1,10 +1,8 @@ - plugins { id("com.android.library") kotlin("android") id("io.gitlab.arturbosch.detekt") id("toggles.detekt-library-conventions") - } android { diff --git a/build-logic/conventions/src/main/kotlin/toggles.android.module-conventions.gradle.kts b/build-logic/conventions/src/main/kotlin/toggles.android.module-conventions.gradle.kts index 7287ad55..f289258a 100644 --- a/build-logic/conventions/src/main/kotlin/toggles.android.module-conventions.gradle.kts +++ b/build-logic/conventions/src/main/kotlin/toggles.android.module-conventions.gradle.kts @@ -25,6 +25,50 @@ android { warningsAsErrors = true lintConfig = File("../../lint.xml") } + + testOptions { + animationsDisabled = true + execution = "ANDROIDX_TEST_ORCHESTRATOR" + unitTests { + isReturnDefaultValues = true + isIncludeAndroidResources = true + } + managedDevices { + devices { + maybeCreate("pixel2api30").apply { + // Use device profiles you typically see in Android Studio. + device = "Pixel 2" + // Use only API levels 30 and higher. + apiLevel = 30 + // To include Google services, use "google". + systemImageSource = "aosp" + } + } + } + } + + sourceSets { +// val sharedTestDir = "src/sharedTest/" +// if(project.file(sharedTestDir).exists()) { +// val sharedTestSourceDir = sharedTestDir + "java" +// val sharedTestResourceDir = sharedTestDir + "resources" +// val sharedIsAndroid = +// providers.gradleProperty("shared-tests-are-android-tests").get().toBoolean() +// if (sharedIsAndroid) { +// logger.lifecycle("Shared tests are androidTests") +// named("androidTest") { +// java.srcDir(sharedTestSourceDir) +// resources.srcDir(sharedTestResourceDir) +// } +// } else { +// logger.lifecycle("Shared tests are unitTests") +// named("test") { +// java.srcDir(sharedTestSourceDir) +// resources.srcDir(sharedTestResourceDir) +// } +// } +// } + } } kotlin { @@ -35,4 +79,13 @@ kotlin { dependencies { lintChecks(libs.com.slack.lint.compose.compose.lint.checks) + + testImplementation(libs.androidx.test.ext.junit) + testImplementation(libs.org.robolectric) + testImplementation(libs.androidx.test.runner) + + androidTestImplementation(libs.androidx.test.ext.junit) + androidTestImplementation(libs.androidx.test.runner) + + androidTestUtil(libs.androidx.test.orchestrator) } \ No newline at end of file diff --git a/build-logic/conventions/src/main/kotlin/toggles.detekt-conventions.gradle.kts b/build-logic/conventions/src/main/kotlin/toggles.detekt-conventions.gradle.kts index 5671e3d9..234d4095 100644 --- a/build-logic/conventions/src/main/kotlin/toggles.detekt-conventions.gradle.kts +++ b/build-logic/conventions/src/main/kotlin/toggles.detekt-conventions.gradle.kts @@ -6,7 +6,7 @@ plugins { } dependencies { - detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.22.0") + detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.6") } detekt { diff --git a/build.gradle.kts b/build.gradle.kts index 84720ee4..2ff37dde 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -18,6 +18,14 @@ buildscript { } } +versionCatalogUpdate { + keep { + keepUnusedVersions = true + keepUnusedLibraries = true + keepUnusedPlugins = true + } +} + plugins { alias(libs.plugins.com.github.ben.manes.versions) alias(libs.plugins.nl.littlerobots.version.catalog.update) @@ -28,6 +36,13 @@ plugins { alias(libs.plugins.com.autonomousapps.dependency.analysis) } +develocity { + buildScan { + termsOfUseUrl.set("https://gradle.com/help/legal-terms-of-use") + termsOfUseAgree.set("yes") + } +} + fun isNonStable(version: String): Boolean { val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.uppercase(Locale.getDefault()).contains(it) diff --git a/gradle.properties b/gradle.properties index 0227d7ee..ebd41097 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx2g -Xms500m -Dfile.encoding=UTF-8 +org.gradle.jvmargs=-Xmx12120m # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit @@ -42,3 +42,5 @@ android.enableJetifier=false org.gradle.caching=true org.gradle.configuration-cache=true org.gradle.configuration-cache.max-problems=5 + +shared-tests-are-android-tests=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 847daf37..db54f283 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,106 +1,68 @@ [versions] -agp = "8.2.1" -androidx-activity = "1.7.1" -androidx-appcompat = "1.6.1" +agp = "8.6.0" +androidx-activity = "1.9.2" +androidx-appcompat = "1.7.0" androidx-arch-core = "2.2.0" -androidx-collection = "1.1.0" -androidx-compose-bom = "2023.10.01" -androidx-compose-compiler = "1.5.8" -androidx-core = "1.10.0" -androidx-hilt = "1.0.0" -androidx-lifecycle = "2.6.1" -androidx-navigation = "2.7.0" -androidx-room = "2.6.0-alpha03" -androidx-savedstate = "1.2.1" -androidx-test = "1.5.0" -androidx-vectordrawable = "1.1.0" -com-google-dagger = "2.48" -com-squareup-leakcanary = "2.8.1" -com-squareup-moshi = "1.15.0" -dokka = "1.9.0" -espresso-core = "3.5.1" +androidx-compose-bom = "2024.09.00" +androidx-hilt = "1.2.0" +androidx-lifecycle = "2.8.5" +androidx-navigation = "2.8.0" +androidx-room = "2.6.1" +androidx-test = "1.6.1" +com-google-dagger = "2.52" +com-squareup-leakcanary = "2.14" +com-squareup-moshi = "1.15.1" +dokka = "1.9.20" +espresso-core = "3.6.1" +io-gitlab-arturbosch-detekt = "1.23.6" junit = "4.13.2" -kotlin = "1.9.22" -org-jetbrains-kotlinx = "1.6.4" +kotlin = "2.0.20" +ksp = "2.0.20-1.0.25" +orchestrator = "1.5.0" +org-jetbrains-kotlinx = "1.8.1" +se-eelde-toggles = "0.0.1" [libraries] -androidx-activity = { module = "androidx.activity:activity", version.ref = "androidx-activity" } androidx-activity-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity" } -androidx-activity-activity-ktx = { module = "androidx.activity:activity-ktx", version.ref = "androidx-activity" } androidx-annotation = "androidx.annotation:annotation:1.6.0" androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" } -androidx-arch-core-core-common = { module = "androidx.arch.core:core-common", version.ref = "androidx-arch-core" } -androidx-arch-core-core-runtime = { module = "androidx.arch.core:core-runtime", version.ref = "androidx-arch-core" } androidx-arch-core-core-testing = { module = "androidx.arch.core:core-testing", version.ref = "androidx-arch-core" } -androidx-collection = { module = "androidx.collection:collection", version.ref = "androidx-collection" } -androidx-collection-collection-ktx = { module = "androidx.collection:collection-ktx", version.ref = "androidx-collection" } androidx-compose-animation = { module = "androidx.compose.animation:animation" } -androidx-compose-animation-animation-core = { module = "androidx.compose.animation:animation-core" } androidx-compose-bom = { module = "androidx.compose:compose-bom", version.ref = "androidx-compose-bom" } androidx-compose-foundation = { module = "androidx.compose.foundation:foundation" } androidx-compose-foundation-foundation-layout = { module = "androidx.compose.foundation:foundation-layout" } -androidx-compose-material-material-icons-core = { module = "androidx.compose.material:material-icons-core" } androidx-compose-material-material-icons-extended = { module = "androidx.compose.material:material-icons-extended" } -androidx-compose-material-material-ripple = { module = "androidx.compose.material:material-ripple" } androidx-compose-material3 = { module = "androidx.compose.material3:material3" } androidx-compose-runtime = { module = "androidx.compose.runtime:runtime" } -androidx-compose-runtime-runtime-saveable = { module = "androidx.compose.runtime:runtime-saveable" } androidx-compose-ui = { module = "androidx.compose.ui:ui" } -androidx-compose-ui-ui-geometry = { module = "androidx.compose.ui:ui-geometry" } -androidx-compose-ui-ui-graphics = { module = "androidx.compose.ui:ui-graphics" } androidx-compose-ui-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4" } androidx-compose-ui-ui-text = { module = "androidx.compose.ui:ui-text" } androidx-compose-ui-ui-tooling = { module = "androidx.compose.ui:ui-tooling" } -androidx-compose-ui-ui-tooling-data = { module = "androidx.compose.ui:ui-tooling-data" } androidx-compose-ui-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" } -androidx-compose-ui-ui-unit = { module = "androidx.compose.ui:ui-unit" } -androidx-compose-ui-ui-util = { module = "androidx.compose.ui:ui-util" } -androidx-concurrent-concurrent-futures = "androidx.concurrent:concurrent-futures:1.1.0" -androidx-core = { module = "androidx.core:core", version.ref = "androidx-core" } -androidx-core-core-ktx = "androidx.core:core-ktx:1.9.0" -androidx-cursoradapter = "androidx.cursoradapter:cursoradapter:1.0.0" -androidx-customview-customview-poolingcontainer = "androidx.customview:customview-poolingcontainer:1.0.0" -androidx-fragment = "androidx.fragment:fragment:1.5.1" +androidx-core-core-ktx = "androidx.core:core-ktx:1.13.1" androidx-hilt-hilt-compiler = { module = "androidx.hilt:hilt-compiler", version.ref = "androidx-hilt" } -androidx-hilt-hilt-navigation = { module = "androidx.hilt:hilt-navigation", version.ref = "androidx-hilt" } androidx-hilt-hilt-navigation-compose = { module = "androidx.hilt:hilt-navigation-compose", version.ref = "androidx-hilt" } -androidx-interpolator = "androidx.interpolator:interpolator:1.0.0" -androidx-lifecycle-lifecycle-common = { module = "androidx.lifecycle:lifecycle-common", version.ref = "androidx-lifecycle" } androidx-lifecycle-lifecycle-common-java8 = { module = "androidx.lifecycle:lifecycle-common-java8", version.ref = "androidx-lifecycle" } -androidx-lifecycle-lifecycle-runtime-compose = "androidx.lifecycle:lifecycle-runtime-compose:2.6.1" -androidx-lifecycle-lifecycle-runtime = { module = "androidx.lifecycle:lifecycle-runtime", version.ref = "androidx-lifecycle" } +androidx-lifecycle-lifecycle-runtime-compose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version.ref = "androidx-lifecycle" } androidx-lifecycle-lifecycle-runtime-ktx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "androidx-lifecycle" } -androidx-lifecycle-lifecycle-viewmodel = { module = "androidx.lifecycle:lifecycle-viewmodel", version.ref = "androidx-lifecycle" } androidx-lifecycle-lifecycle-viewmodel-compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "androidx-lifecycle" } androidx-lifecycle-lifecycle-viewmodel-ktx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "androidx-lifecycle" } -androidx-lifecycle-lifecycle-viewmodel-savedstate = { module = "androidx.lifecycle:lifecycle-viewmodel-savedstate", version.ref = "androidx-lifecycle" } -androidx-loader = "androidx.loader:loader:1.0.0" -androidx-navigation-navigation-common = { module = "androidx.navigation:navigation-common", version.ref = "androidx-navigation" } -androidx-navigation-navigation-common-ktx = { module = "androidx.navigation:navigation-common-ktx", version.ref = "androidx-navigation" } androidx-navigation-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "androidx-navigation" } -androidx-navigation-navigation-runtime = { module = "androidx.navigation:navigation-runtime", version.ref = "androidx-navigation" } androidx-navigation-navigation-runtime-ktx = { module = "androidx.navigation:navigation-runtime-ktx", version.ref = "androidx-navigation" } androidx-room-room-compiler = { module = "androidx.room:room-compiler", version.ref = "androidx-room" } androidx-room-room-ktx = { module = "androidx.room:room-ktx", version.ref = "androidx-room" } androidx-room-room-runtime = { module = "androidx.room:room-runtime", version.ref = "androidx-room" } androidx-room-room-testing = { module = "androidx.room:room-testing", version.ref = "androidx-room" } -androidx-savedstate = { module = "androidx.savedstate:savedstate", version.ref = "androidx-savedstate" } androidx-startup-startup-runtime = "androidx.startup:startup-runtime:1.1.1" -androidx-test-core = { module = "androidx.test:core", version.ref = "androidx-test" } androidx-test-core-ktx = { module = "androidx.test:core-ktx", version.ref = "androidx-test" } androidx-test-espresso-espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "espresso-core" } -androidx-test-ext-junit = "androidx.test.ext:junit:1.1.5" -androidx-test-ext-truth = "androidx.test.ext:truth:1.5.0" +androidx-test-ext-junit = "androidx.test.ext:junit:1.2.1" +androidx-test-ext-truth = "androidx.test.ext:truth:1.6.0" +androidx-test-orchestrator = { module = "androidx.test:orchestrator", version.ref = "orchestrator" } androidx-test-rules = { module = "androidx.test:rules", version.ref = "androidx-test" } -androidx-test-runner = "androidx.test:runner:1.5.2" -androidx-tracing = "androidx.tracing:tracing:1.0.0" -androidx-vectordrawable = { module = "androidx.vectordrawable:vectordrawable", version.ref = "androidx-vectordrawable" } -androidx-vectordrawable-vectordrawable-animated = { module = "androidx.vectordrawable:vectordrawable-animated", version.ref = "androidx-vectordrawable" } -androidx-versionedparcelable = "androidx.versionedparcelable:versionedparcelable:1.1.1" -androidx-viewpager = "androidx.viewpager:viewpager:1.0.0" -app-cash-licensee-licensee-gradle-plugin = "app.cash.licensee:licensee-gradle-plugin:1.8.0" -com-android-tools-build-gradle = "com.android.tools.build:gradle:8.2.1" -com-google-code-findbugs-jsr305 = "com.google.code.findbugs:jsr305:3.0.2" +androidx-test-runner = "androidx.test:runner:1.6.2" +app-cash-licensee-licensee-gradle-plugin = "app.cash.licensee:licensee-gradle-plugin:1.11.0" +com-android-tools-build-gradle = "com.android.tools.build:gradle:8.6.0" com-google-dagger = { module = "com.google.dagger:dagger", version.ref = "com-google-dagger" } com-google-dagger-dagger-compiler = { module = "com.google.dagger:dagger-compiler", version.ref = "com-google-dagger" } com-google-dagger-hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "com-google-dagger" } @@ -108,43 +70,41 @@ com-google-dagger-hilt-android-compiler = { module = "com.google.dagger:hilt-and com-google-dagger-hilt-android-gradle-plugin = { module = "com.google.dagger:hilt-android-gradle-plugin", version.ref = "com-google-dagger" } com-google-dagger-hilt-android-testing = { module = "com.google.dagger:hilt-android-testing", version.ref = "com-google-dagger" } com-google-dagger-hilt-compiler = { module = "com.google.dagger:hilt-compiler", version.ref = "com-google-dagger" } -com-google-firebase-firebase-crashlytics-gradle = "com.google.firebase:firebase-crashlytics-gradle:2.9.8" -com-google-gms-google-services = "com.google.gms:google-services:4.3.15" -com-slack-lint-compose-compose-lint-checks = "com.slack.lint.compose:compose-lint-checks:1.2.0" +com-google-devtools-ksp-com-google-devtools-ksp-gradle-plugin = { module = "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin", version.ref = "ksp" } +com-google-gms-google-services = "com.google.gms:google-services:4.4.2" +com-slack-lint-compose-compose-lint-checks = "com.slack.lint.compose:compose-lint-checks:1.3.1" +com-squareup-kotlinpoet = "com.squareup:kotlinpoet:1.16.0" com-squareup-leakcanary-leakcanary-android = { module = "com.squareup.leakcanary:leakcanary-android", version.ref = "com-squareup-leakcanary" } com-squareup-moshi = { module = "com.squareup.moshi:moshi", version.ref = "com-squareup-moshi" } com-squareup-moshi-moshi-kotlin-codegen = { module = "com.squareup.moshi:moshi-kotlin-codegen", version.ref = "com-squareup-moshi" } -com-squareup-okio = "com.squareup.okio:okio:3.5.0" -espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "espresso-core" } -io-gitlab-arturbosch-detekt-detekt-formatting = "io.gitlab.arturbosch.detekt:detekt-formatting:1.23.1" -io-gitlab-arturbosch-detekt-detekt-gradle-plugin = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.23.1" -io-gitlab-arturbosch-detekt-detekt-rules-libraries = "io.gitlab.arturbosch.detekt:detekt-rules-libraries:1.23.1" +com-squareup-okio = "com.squareup.okio:okio:3.9.0" +io-gitlab-arturbosch-detekt-detekt-formatting = "io.gitlab.arturbosch.detekt:detekt-formatting:1.23.7" +io-gitlab-arturbosch-detekt-detekt-gradle-plugin = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", version.ref = "io-gitlab-arturbosch-detekt" } +io-gitlab-arturbosch-detekt-detekt-rules-libraries = { module = "io.gitlab.arturbosch.detekt:detekt-rules-libraries", version.ref = "io-gitlab-arturbosch-detekt" } junit = { module = "junit:junit", version.ref = "junit" } org-jetbrains-dokka-dokka-gradle-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" } +org-jetbrains-kotlin-compose-compiler-gradle-plugin = { module = "org.jetbrains.kotlin:compose-compiler-gradle-plugin", version.ref = "kotlin" } org-jetbrains-kotlin-kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } -org-jetbrains-kotlin-kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" } -org-jetbrains-kotlin-kotlin-stdlib-jdk8 = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.0" -org-jetbrains-kotlinx-kotlinx-collections-immutable = "org.jetbrains.kotlinx:kotlinx-collections-immutable:0.3.5" +org-jetbrains-kotlinx-kotlinx-collections-immutable = "org.jetbrains.kotlinx:kotlinx-collections-immutable:0.3.8" org-jetbrains-kotlinx-kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android" } org-jetbrains-kotlinx-kotlinx-coroutines-bom = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-bom", version.ref = "org-jetbrains-kotlinx" } -org-robolectric = "org.robolectric:robolectric:4.10.3" -se-eelde-toggles-toggles-core = { module = "se.eelde.toggles:toggles-core" } -se-eelde-toggles-toggles-flow = { module = "se.eelde.toggles:toggles-flow" } -se-eelde-toggles-toggles-prefs = { module = "se.eelde.toggles:toggles-prefs" } -#se-eelde-toggles-toggles-core = "se.eelde.toggles:toggles-core:0.0.2" -#se-eelde-toggles-toggles-flow = "se.eelde.toggles:toggles-flow:0.0.1" -#se-eelde-toggles-toggles-prefs = "se.eelde.toggles:toggles-prefs:0.0.1" +org-robolectric = "org.robolectric:robolectric:4.13" +#se-eelde-toggles-toggles-core = { module = "se.eelde.toggles:toggles-core" } +#se-eelde-toggles-toggles-flow = { module = "se.eelde.toggles:toggles-flow" } +#se-eelde-toggles-toggles-prefs = { module = "se.eelde.toggles:toggles-prefs" } +se-eelde-toggles-toggles-core = "se.eelde.toggles:toggles-core:0.0.2" +se-eelde-toggles-toggles-flow = { module = "se.eelde.toggles:toggles-flow", version.ref = "se-eelde-toggles" } +se-eelde-toggles-toggles-prefs = { module = "se.eelde.toggles:toggles-prefs", version.ref = "se-eelde-toggles" } +se-premex-ownership-gradle-plugin = "se.premex:ownership-gradle-plugin:0.0.11" + [plugins] com-android-library = { id = "com.android.library", version.ref = "agp" } -com-autonomousapps-dependency-analysis = "com.autonomousapps.dependency-analysis:1.28.0" -com-github-ben-manes-versions = "com.github.ben-manes.versions:0.50.0" -com-github-triplet-play = "com.github.triplet.play:3.8.4" -com-google-dagger-hilt-android = { id = "com.google.dagger.hilt.android", version.ref = "com-google-dagger" } -com-google-devtools-ksp = "com.google.devtools.ksp:1.9.22-1.0.16" -com-google-firebase-crashlytics = "com.google.firebase.crashlytics:2.9.8" -com-google-gms-google-services = "com.google.gms.google-services:4.3.15" +com-autonomousapps-dependency-analysis = "com.autonomousapps.dependency-analysis:2.0.1" +com-github-ben-manes-versions = "com.github.ben-manes.versions:0.51.0" +com-github-triplet-play = "com.github.triplet.play:3.11.0" +com-google-devtools-ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } com-vanniktech-maven-publish = "com.vanniktech.maven.publish:0.27.0" -nl-littlerobots-version-catalog-update = "nl.littlerobots.version-catalog-update:0.8.3" +nl-littlerobots-version-catalog-update = "nl.littlerobots.version-catalog-update:0.8.4" org-jetbrains-dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } org-jetbrains-kotlinx-binary-compatibility-validator = "org.jetbrains.kotlinx.binary-compatibility-validator:0.13.2" -se-premex-gross = "se.premex.gross:0.2.0" +se-premex-gross = "se.premex.gross:0.4.2" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1af9e093..9355b415 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/modules/applications/build.gradle.kts b/modules/applications/build.gradle.kts index 583950ac..4e8de7c3 100644 --- a/modules/applications/build.gradle.kts +++ b/modules/applications/build.gradle.kts @@ -2,16 +2,11 @@ plugins { id("toggles.android.module-conventions") id("toggles.ownership-conventions") alias(libs.plugins.com.google.devtools.ksp) + id("org.jetbrains.kotlin.plugin.compose") } android { namespace = "se.eelde.toggles.applications" - buildFeatures { - compose = true - } - composeOptions { - kotlinCompilerExtensionVersion = libs.versions.androidx.compose.compiler.get() - } } dependencies { diff --git a/modules/applications/src/sharedTest/java/se/eelde/toggles/applications/ExampleSharedTest.kt b/modules/applications/src/sharedTest/java/se/eelde/toggles/applications/ExampleSharedTest.kt new file mode 100644 index 00000000..027c9e74 --- /dev/null +++ b/modules/applications/src/sharedTest/java/se/eelde/toggles/applications/ExampleSharedTest.kt @@ -0,0 +1,26 @@ +package se.eelde.toggles.applications + +import android.app.Application +import androidx.test.core.app.ApplicationProvider +import androidx.test.ext.junit.runners.AndroidJUnit4 +import org.junit.Assert.assertEquals +import org.junit.Test +import org.junit.runner.RunWith + +/** + * ./gradlew :modules:applications:pixel2api30DebugAndroidTest -Pshared-tests-are-android-tests=false + * ./gradlew :modules:applications:pixel2api30DebugAndroidTest -Pshared-tests-are-android-tests=true + */ +@RunWith(AndroidJUnit4::class) +class ExampleSharedTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } + + @Test + fun useAppContext() { + val context = ApplicationProvider.getApplicationContext() + assertEquals("se.eelde.toggles.applications.test", context.packageName) + } +} diff --git a/modules/applications/src/sharedTest/resources/robolectric.properties b/modules/applications/src/sharedTest/resources/robolectric.properties new file mode 100644 index 00000000..37420983 --- /dev/null +++ b/modules/applications/src/sharedTest/resources/robolectric.properties @@ -0,0 +1 @@ +sdk=33 \ No newline at end of file diff --git a/modules/booleanconfiguration/build.gradle.kts b/modules/booleanconfiguration/build.gradle.kts index 72d059a6..f77927d4 100644 --- a/modules/booleanconfiguration/build.gradle.kts +++ b/modules/booleanconfiguration/build.gradle.kts @@ -2,16 +2,11 @@ plugins { id("toggles.android.module-conventions") id("toggles.ownership-conventions") alias(libs.plugins.com.google.devtools.ksp) + id("org.jetbrains.kotlin.plugin.compose") } android { namespace = "se.eelde.toggles.booleanconfiguration" - buildFeatures { - compose = true - } - composeOptions { - kotlinCompilerExtensionVersion = libs.versions.androidx.compose.compiler.get() - } } dependencies { diff --git a/modules/compose-theme/build.gradle.kts b/modules/compose-theme/build.gradle.kts index 60e589b2..ea537764 100644 --- a/modules/compose-theme/build.gradle.kts +++ b/modules/compose-theme/build.gradle.kts @@ -1,16 +1,11 @@ plugins { id("toggles.android.module-conventions") id("toggles.ownership-conventions") + id("org.jetbrains.kotlin.plugin.compose") } android { namespace = "se.eelde.toggles.composetheme" - buildFeatures { - compose = true - } - composeOptions { - kotlinCompilerExtensionVersion = libs.versions.androidx.compose.compiler.get() - } } dependencies { implementation(platform(libs.androidx.compose.bom)) diff --git a/modules/configurations/build.gradle.kts b/modules/configurations/build.gradle.kts index a9541d7f..d56019e5 100644 --- a/modules/configurations/build.gradle.kts +++ b/modules/configurations/build.gradle.kts @@ -2,16 +2,11 @@ plugins { id("toggles.android.module-conventions") id("toggles.ownership-conventions") alias(libs.plugins.com.google.devtools.ksp) + id("org.jetbrains.kotlin.plugin.compose") } android { namespace = "se.eelde.toggles.configurations" - buildFeatures { - compose = true - } - composeOptions { - kotlinCompilerExtensionVersion = libs.versions.androidx.compose.compiler.get() - } } dependencies { diff --git a/modules/enumconfiguration/build.gradle.kts b/modules/enumconfiguration/build.gradle.kts index 531d1e92..815e0ebe 100644 --- a/modules/enumconfiguration/build.gradle.kts +++ b/modules/enumconfiguration/build.gradle.kts @@ -2,16 +2,11 @@ plugins { id("toggles.android.module-conventions") id("toggles.ownership-conventions") alias(libs.plugins.com.google.devtools.ksp) + id("org.jetbrains.kotlin.plugin.compose") } android { namespace = "se.eelde.toggles.enumconfiguration" - buildFeatures { - compose = true - } - composeOptions { - kotlinCompilerExtensionVersion = libs.versions.androidx.compose.compiler.get() - } } dependencies { diff --git a/modules/help/build.gradle.kts b/modules/help/build.gradle.kts index 62ab0678..59e09102 100644 --- a/modules/help/build.gradle.kts +++ b/modules/help/build.gradle.kts @@ -2,16 +2,11 @@ plugins { id("toggles.android.module-conventions") id("toggles.ownership-conventions") alias(libs.plugins.com.google.devtools.ksp) + id("org.jetbrains.kotlin.plugin.compose") } android { namespace = "se.eelde.toggles.help" - buildFeatures { - compose = true - } - composeOptions { - kotlinCompilerExtensionVersion = libs.versions.androidx.compose.compiler.get() - } } dependencies { diff --git a/modules/integerconfiguration/build.gradle.kts b/modules/integerconfiguration/build.gradle.kts index 1adf999a..68723e79 100644 --- a/modules/integerconfiguration/build.gradle.kts +++ b/modules/integerconfiguration/build.gradle.kts @@ -2,16 +2,11 @@ plugins { id("toggles.android.module-conventions") id("toggles.ownership-conventions") alias(libs.plugins.com.google.devtools.ksp) + id("org.jetbrains.kotlin.plugin.compose") } android { namespace = "se.eelde.toggles.integerconfiguration" - buildFeatures { - compose = true - } - composeOptions { - kotlinCompilerExtensionVersion = libs.versions.androidx.compose.compiler.get() - } } dependencies { diff --git a/modules/oss/build.gradle.kts b/modules/oss/build.gradle.kts index d5af9f62..b362e668 100644 --- a/modules/oss/build.gradle.kts +++ b/modules/oss/build.gradle.kts @@ -2,16 +2,11 @@ plugins { id("toggles.android.module-conventions") id("toggles.ownership-conventions") alias(libs.plugins.com.google.devtools.ksp) + id("org.jetbrains.kotlin.plugin.compose") } android { namespace = "se.eelde.toggles.oss" - buildFeatures { - compose = true - } - composeOptions { - kotlinCompilerExtensionVersion = libs.versions.androidx.compose.compiler.get() - } } dependencies { diff --git a/modules/provider/build.gradle.kts b/modules/provider/build.gradle.kts index daf67d98..d3b8946c 100644 --- a/modules/provider/build.gradle.kts +++ b/modules/provider/build.gradle.kts @@ -2,17 +2,11 @@ plugins { id("toggles.android.module-conventions") id("toggles.ownership-conventions") alias(libs.plugins.com.google.devtools.ksp) + id("org.jetbrains.kotlin.plugin.compose") } android { namespace = "se.eelde.toggles.provider" - buildFeatures { - - compose = true - } - composeOptions { - kotlinCompilerExtensionVersion = libs.versions.androidx.compose.compiler.get() - } } dependencies { diff --git a/modules/stringconfiguration/build.gradle.kts b/modules/stringconfiguration/build.gradle.kts index 4aa9d1d3..107e0dc3 100644 --- a/modules/stringconfiguration/build.gradle.kts +++ b/modules/stringconfiguration/build.gradle.kts @@ -2,16 +2,11 @@ plugins { id("toggles.android.module-conventions") id("toggles.ownership-conventions") alias(libs.plugins.com.google.devtools.ksp) + id("org.jetbrains.kotlin.plugin.compose") } android { namespace = "se.eelde.toggles.stringconfiguration" - buildFeatures { - compose = true - } - composeOptions { - kotlinCompilerExtensionVersion = libs.versions.androidx.compose.compiler.get() - } } dependencies { diff --git a/scripts/pr_check.sh b/scripts/pr_check.sh new file mode 100755 index 00000000..d2dd13e5 --- /dev/null +++ b/scripts/pr_check.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +cd "$SCRIPT_DIR"/.. || exit + +./gradlew detekt +./gradlew test -Pshared-tests-are-android-tests=false +./gradlew test -Pshared-tests-are-android-tests=true +./gradlew assembleAndroidTest -Pshared-tests-are-android-tests=false +./gradlew assembleAndroidTest -Pshared-tests-are-android-tests=true +./gradlew check +./gradlew :toggles-core:check +./gradlew :toggles-flow:check --no-configuration-cache +./gradlew :toggles-flow-noop:check +./gradlew :toggles-prefs:check --no-configuration-cache +./gradlew :toggles-prefs-noop:check diff --git a/settings.gradle.kts b/settings.gradle.kts index d596e8c9..d0a5cbe4 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -10,8 +10,15 @@ pluginManagement { } plugins { - id("com.gradle.enterprise") version "3.16.1" - id("org.gradle.toolchains.foojay-resolver-convention") version("0.7.0") + id("com.gradle.develocity") version "3.18" + id("org.gradle.toolchains.foojay-resolver-convention") version ("0.8.0") +} + +develocity { + buildScan { + termsOfUseUrl.set("https://gradle.com/help/legal-terms-of-use") + termsOfUseAgree.set("yes") + } } buildCache { @@ -25,7 +32,7 @@ buildCache { } } -private val localLibraries = true +private val localLibraries = false rootProject.name = "Toggles" includeBuild("build-logic/conventions") diff --git a/toggles-app/build.gradle.kts b/toggles-app/build.gradle.kts index 01730a1b..15c49bad 100644 --- a/toggles-app/build.gradle.kts +++ b/toggles-app/build.gradle.kts @@ -96,6 +96,26 @@ android { versionNameSuffix = " debug" } } + testOptions { + animationsDisabled = true + execution = "ANDROIDX_TEST_ORCHESTRATOR" + unitTests { + isReturnDefaultValues = true + isIncludeAndroidResources = true + } + managedDevices { + devices { + maybeCreate("pixel2api30").apply { + // Use device profiles you typically see in Android Studio. + device = "Pixel 2" + // Use only API levels 30 and higher. + apiLevel = 30 + // To include Google services, use "google". + systemImageSource = "aosp" + } + } + } + } } dependencies { diff --git a/toggles-core/settings.gradle.kts b/toggles-core/settings.gradle.kts index af96acbd..f6ca5ae4 100644 --- a/toggles-core/settings.gradle.kts +++ b/toggles-core/settings.gradle.kts @@ -23,8 +23,15 @@ pluginManagement { } plugins { - id("com.gradle.enterprise") version "3.16.1" - id("org.gradle.toolchains.foojay-resolver-convention") version("0.7.0") + id("com.gradle.develocity") version "3.18" + id("org.gradle.toolchains.foojay-resolver-convention") version ("0.8.0") +} + +develocity { + buildScan { + termsOfUseUrl.set("https://gradle.com/help/legal-terms-of-use") + termsOfUseAgree.set("yes") + } } dependencyResolutionManagement { diff --git a/toggles-flow-noop/settings.gradle.kts b/toggles-flow-noop/settings.gradle.kts index 441fef75..a2a9fb80 100644 --- a/toggles-flow-noop/settings.gradle.kts +++ b/toggles-flow-noop/settings.gradle.kts @@ -23,8 +23,15 @@ pluginManagement { } plugins { - id("com.gradle.enterprise") version "3.16.1" - id("org.gradle.toolchains.foojay-resolver-convention") version("0.7.0") + id("com.gradle.develocity") version "3.18" + id("org.gradle.toolchains.foojay-resolver-convention") version ("0.8.0") +} + +develocity { + buildScan { + termsOfUseUrl.set("https://gradle.com/help/legal-terms-of-use") + termsOfUseAgree.set("yes") + } } dependencyResolutionManagement { diff --git a/toggles-flow/build.gradle.kts b/toggles-flow/build.gradle.kts index e16816f1..2fc396f7 100644 --- a/toggles-flow/build.gradle.kts +++ b/toggles-flow/build.gradle.kts @@ -13,7 +13,7 @@ android { dependencies { testImplementation(libs.junit) - testImplementation(libs.androidx.test.core) + testImplementation(libs.androidx.test.core.ktx) testImplementation(libs.androidx.test.ext.truth) testImplementation(libs.androidx.test.rules) testImplementation(libs.androidx.test.runner) diff --git a/toggles-flow/settings.gradle.kts b/toggles-flow/settings.gradle.kts index a10920c2..453ff5df 100644 --- a/toggles-flow/settings.gradle.kts +++ b/toggles-flow/settings.gradle.kts @@ -23,8 +23,15 @@ pluginManagement { } plugins { - id("com.gradle.enterprise") version "3.16.1" - id("org.gradle.toolchains.foojay-resolver-convention") version("0.7.0") + id("com.gradle.develocity") version "3.18" + id("org.gradle.toolchains.foojay-resolver-convention") version ("0.8.0") +} + +develocity { + buildScan { + termsOfUseUrl.set("https://gradle.com/help/legal-terms-of-use") + termsOfUseAgree.set("yes") + } } dependencyResolutionManagement { diff --git a/toggles-prefs-noop/settings.gradle.kts b/toggles-prefs-noop/settings.gradle.kts index a51331da..a68b295d 100644 --- a/toggles-prefs-noop/settings.gradle.kts +++ b/toggles-prefs-noop/settings.gradle.kts @@ -23,8 +23,15 @@ pluginManagement { } plugins { - id("com.gradle.enterprise") version "3.16.1" - id("org.gradle.toolchains.foojay-resolver-convention") version("0.7.0") + id("com.gradle.develocity") version "3.18" + id("org.gradle.toolchains.foojay-resolver-convention") version ("0.8.0") +} + +develocity { + buildScan { + termsOfUseUrl.set("https://gradle.com/help/legal-terms-of-use") + termsOfUseAgree.set("yes") + } } dependencyResolutionManagement { diff --git a/toggles-prefs/build.gradle.kts b/toggles-prefs/build.gradle.kts index 6dc28f59..0ccf4a23 100644 --- a/toggles-prefs/build.gradle.kts +++ b/toggles-prefs/build.gradle.kts @@ -13,7 +13,7 @@ android { dependencies { testImplementation(libs.junit) - testImplementation(libs.androidx.test.core) + testImplementation(libs.androidx.test.core.ktx) testImplementation(libs.androidx.test.ext.truth) testImplementation(libs.androidx.test.rules) testImplementation(libs.androidx.test.runner) diff --git a/toggles-prefs/settings.gradle.kts b/toggles-prefs/settings.gradle.kts index fdd6a980..a577266e 100644 --- a/toggles-prefs/settings.gradle.kts +++ b/toggles-prefs/settings.gradle.kts @@ -23,8 +23,15 @@ pluginManagement { } plugins { - id("com.gradle.enterprise") version "3.16.1" - id("org.gradle.toolchains.foojay-resolver-convention") version("0.7.0") + id("com.gradle.develocity") version "3.18" + id("org.gradle.toolchains.foojay-resolver-convention") version ("0.8.0") +} + +develocity { + buildScan { + termsOfUseUrl.set("https://gradle.com/help/legal-terms-of-use") + termsOfUseAgree.set("yes") + } } dependencyResolutionManagement { diff --git a/toggles-sample/src/sharedTest/java/se/eelde/toggles/applications/ExampleSharedTest.kt b/toggles-sample/src/sharedTest/java/se/eelde/toggles/applications/ExampleSharedTest.kt new file mode 100644 index 00000000..a833cc28 --- /dev/null +++ b/toggles-sample/src/sharedTest/java/se/eelde/toggles/applications/ExampleSharedTest.kt @@ -0,0 +1,29 @@ +package se.eelde.toggles.applications + +import android.app.Application +import android.content.pm.ApplicationInfo +import androidx.test.core.app.ApplicationProvider +import androidx.test.ext.junit.runners.AndroidJUnit4 +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue +import org.junit.Test +import org.junit.runner.RunWith + + +@RunWith(AndroidJUnit4::class) +class ExampleSharedTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } + + @Test + fun useAppContext() { + val context = ApplicationProvider.getApplicationContext() + + assertTrue( + "Package name missmatch ${context.packageName}", + context.packageName.startsWith("se.eelde.toggles.example") + ) + } +} diff --git a/toggles-sample/src/sharedTest/resources/robolectric.properties b/toggles-sample/src/sharedTest/resources/robolectric.properties new file mode 100644 index 00000000..37420983 --- /dev/null +++ b/toggles-sample/src/sharedTest/resources/robolectric.properties @@ -0,0 +1 @@ +sdk=33 \ No newline at end of file