Skip to content

MF-8059 add AGP 9 newDsl support#112

Open
adecker89 wants to merge 5 commits intomainfrom
MF-8059
Open

MF-8059 add AGP 9 newDsl support#112
adecker89 wants to merge 5 commits intomainfrom
MF-8059

Conversation

@adecker89
Copy link
Contributor

@adecker89 adecker89 commented Mar 13, 2026

Reworks plugin to use the new AGP apis like androidComponents

closes #111

@adecker89 adecker89 requested a review from rharter March 13, 2026 18:08
))
}

val adbExecutablePath = provider { android.adbExecutable.path }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty much at a loss to why most of the plugin logic is duplicated here, so let me know if I'm missing something.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure it's because there was a bootstrapping issue where the plugin automatically adds a Dropshots dependency, but we want to use the code under test here. There are also some minor differences in behavior IIRC. for instance, this always pulls screenshots but does not automatically overwrite the reference images when recording, since that would override the tests that are expected to fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But, is it still in use anywhere? I didn't see any references to it.

@adecker89 adecker89 changed the title #111 MF-8059 add AGP 9 newDsl support MF-8059 add AGP 9 newDsl support Mar 13, 2026

val deviceScreenshotDir =
androidTest.applicationId.map { "/storage/emulated/0/Download/screenshots/$it" }
val buildScreenshotDir =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is possibly a breaking change if anyone is hardcoding the results directory.

We used to use (it as AndroidTestTask).resultsDir but this task is created very late in AGP now and a headache to get a reference to. It's also not a good practice to use another tasks output directory in this way.

.withArguments("recordDebugAndroidTestScreenshots")
.withArguments("recordDebugAndroidTestScreenshots", "--stacktrace")
.build()
println(result.output)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this for debugging?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but I left it intentionally as it helps debugging when these tests fail.

))
}

val adbExecutablePath = provider { android.adbExecutable.path }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure it's because there was a bootstrapping issue where the plugin automatically adds a Dropshots dependency, but we want to use the code under test here. There are also some minor differences in behavior IIRC. for instance, this always pulls screenshots but does not automatically overwrite the reference images when recording, since that would override the tests that are expected to fail.

}
}

private fun NamedDomainObjectContainer<out AndroidSourceSet>.addDropshotsAssetsDir(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to extract this part of the dropshots configuration out of the configureDropshots function? Both ApplicationExtension and LibraryExtension still implement TestedExtension, so splitting the configuration in two doesn't seem entirely necessary (or desirable).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TestedExtension does define sourceSets

import org.gradle.work.DisableCachingByDefault

@DisableCachingByDefault(
because = "The task interacts with the connected test device, so caching is not applicable."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this true? These tasks still have input, so if the input hasn't changed or dependent tasks aren't executed then there should be no work to do here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean tasks generally aren't cached

but, this task should probably also have a

outputs.upToDateWhen { false }

since it interacts with adb and input tracking will not be accurate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for AGP 9's new DSL

2 participants