Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions build-logic/leakcanary-min-sdk-override/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:tools="http://schemas.android.com/tools">

<uses-sdk
tools:overrideLibrary="com.squareup.leakcanary,com.squareup.leakcanary.android.test,com.squareup.leakcanary.core,com.squareup.leakcanary.fragments.androidx,com.squareup.leakcanary.instrumentation,com.squareup.leakcanary.objectwatcher,com.squareup.leakcanary.objectwatcher.core,com.squareup.leakcanary.plumber,com.squareup.leakcanary.plumber.core,com.squareup.leakcanary.release,com.squareup.leakcanary.utils" />
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,12 @@ class AndroidDefaultsPlugin : Plugin<Project> {
}
}
}

internal fun TestedExtension.useLeakCanaryMinSdkOverrideManifest(
target: Project,
sourceSetName: String,
) {
sourceSets.getByName(sourceSetName).manifest.srcFile(
target.rootProject.file("build-logic/leakcanary-min-sdk-override/AndroidManifest.xml")
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ class AndroidSampleAppPlugin : Plugin<Project> {

@Suppress("UnstableApiUsage")
testedExtension.buildFeatures.viewBinding = true

// LeakCanary 3 requires API 26 resources. Keep this scoped to sample apps so published
// artifacts can continue to use the shared library minSdk.
testedExtension.defaultConfig { defaultConfig ->
defaultConfig.minSdk = maxOf(defaultConfig.minSdk ?: 1, 26)
}
}

target.extensions.configure(BaseAppModuleExtension::class.java) { appExtension ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import com.squareup.workflow1.buildsrc.internal.androidTestImplementation
import com.squareup.workflow1.buildsrc.internal.invoke
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.ExternalModuleDependency
import org.gradle.api.artifacts.MinimalExternalModuleDependency

class AndroidUiTestsPlugin : Plugin<Project> {

Expand All @@ -23,14 +25,29 @@ class AndroidUiTestsPlugin : Plugin<Project> {
// Disable transition and rotation animations.
testOptions.animationsDisabled = true
}

if (!target.file("src/androidTest/AndroidManifest.xml").exists()) {
testedExtension.useLeakCanaryMinSdkOverrideManifest(target, "androidTest")
}
}

target.dependencies {
androidTestImplementation(target.project(":workflow-ui:internal-testing-android"))

androidTestImplementation(target.libsCatalog.library("androidx-test-espresso-core"))
androidTestImplementation(target.libsCatalog.library("androidx-test-junit"))
androidTestImplementation(target.libsCatalog.library("squareup-leakcanary-instrumentation"))
androidTestImplementation(target.libsCatalog.library("squareup-leakcanary-objectwatcher-android"))
addProvider<MinimalExternalModuleDependency, ExternalModuleDependency>(
"androidTestImplementation",
target.libsCatalog.library("squareup-leakcanary-instrumentation")
) { dependency ->
dependency.exclude(
mapOf(
"group" to "com.squareup.leakcanary",
"module" to "leakcanary-android-core"
)
)
}
}
}
}
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ rxjava2-core = "2.2.21"

squareup-curtains = "1.2.5"
squareup-cycler = "0.1.9"
squareup-leakcanary = "3.0-alpha-8"
squareup-leakcanary = "3.0-alpha-9"
squareup-moshi = "1.15.2"
squareup-moshi-kotlin = "1.15.2"
squareup-okhttp = "4.9.1"
Expand Down
11 changes: 10 additions & 1 deletion workflow-runtime/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,16 @@ kotlin {

implementation(libs.androidx.test.espresso.core)
implementation(libs.androidx.test.junit)
implementation(libs.squareup.leakcanary.instrumentation)
implementation(libs.squareup.leakcanary.objectwatcher.android)
implementation(
"com.squareup.leakcanary:leakcanary-android-instrumentation:" +
libs.versions.squareup.leakcanary.get()
) {
exclude(
group = "com.squareup.leakcanary",
module = "leakcanary-android-core"
)
}
implementation(libs.truth)

implementation(libs.androidx.activity.ktx)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-sdk
tools:overrideLibrary="com.squareup.leakcanary,com.squareup.leakcanary.android.test,com.squareup.leakcanary.core,com.squareup.leakcanary.fragments.androidx,com.squareup.leakcanary.instrumentation,com.squareup.leakcanary.objectwatcher,com.squareup.leakcanary.objectwatcher.core,com.squareup.leakcanary.plumber,com.squareup.leakcanary.plumber.core,com.squareup.leakcanary.release,com.squareup.leakcanary.utils" />

<application>
<activity android:name="androidx.activity.ComponentActivity"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ internal class SimpleLoggingWorkflowInterceptorTest {
val EXPECTED_ERRORS = listOf(
(
"ErrorLoggingInterceptor\\.logBeforeMethod threw exception:\n" +
".+IllegalArgumentException.*"
".*IllegalArgumentException.*"
).toRegex(),
(
"ErrorLoggingInterceptor\\.logAfterMethod threw exception:\n" +
".+IllegalArgumentException.*"
".*IllegalArgumentException.*"
).toRegex()
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-sdk
tools:overrideLibrary="com.squareup.leakcanary,com.squareup.leakcanary.android.test,com.squareup.leakcanary.core,com.squareup.leakcanary.fragments.androidx,com.squareup.leakcanary.instrumentation,com.squareup.leakcanary.objectwatcher,com.squareup.leakcanary.objectwatcher.core,com.squareup.leakcanary.plumber,com.squareup.leakcanary.plumber.core,com.squareup.leakcanary.release,com.squareup.leakcanary.utils" />

<application>
<activity android:name="androidx.activity.ComponentActivity"/>
Expand Down
6 changes: 5 additions & 1 deletion workflow-ui/compose/src/androidTest/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-sdk
tools:overrideLibrary="com.squareup.leakcanary,com.squareup.leakcanary.android.test,com.squareup.leakcanary.core,com.squareup.leakcanary.fragments.androidx,com.squareup.leakcanary.instrumentation,com.squareup.leakcanary.objectwatcher,com.squareup.leakcanary.objectwatcher.core,com.squareup.leakcanary.plumber,com.squareup.leakcanary.plumber.core,com.squareup.leakcanary.release,com.squareup.leakcanary.utils" />

<application>
<activity android:name="androidx.activity.ComponentActivity"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-sdk
tools:overrideLibrary="com.squareup.leakcanary,com.squareup.leakcanary.android.test,com.squareup.leakcanary.core,com.squareup.leakcanary.fragments.androidx,com.squareup.leakcanary.instrumentation,com.squareup.leakcanary.objectwatcher,com.squareup.leakcanary.objectwatcher.core,com.squareup.leakcanary.plumber,com.squareup.leakcanary.plumber.core,com.squareup.leakcanary.release,com.squareup.leakcanary.utils" />

<application>
<activity
Expand Down
3 changes: 0 additions & 3 deletions workflow-ui/internal-testing-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ dependencies {
api(project(":workflow-ui:core-common"))

implementation(libs.androidx.lifecycle.common)
implementation(libs.squareup.leakcanary.instrumentation)
implementation(libs.squareup.leakcanary.objectwatcher.android)

testImplementation(libs.hamcrest)
testImplementation(libs.robolectric)
testImplementation(libs.robolectric.annotations)
Expand Down
Loading