dataconnect: add gradle plugin that enables sharing code from src/test to src/androidTest#8098
dataconnect: add gradle plugin that enables sharing code from src/test to src/androidTest#8098
Conversation
…src/test with code in src/androidTest
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. |
|
/gemini review |
📝 PRs merging into main branchOur main branch should always be in a releasable state. If you are working on a larger change, or if you don't want this change to see the light of the day just yet, consider using a feature branch first, and only merge into the main branch when the code complete and ready to be released. |
There was a problem hiding this comment.
Code Review
This pull request introduces a new Gradle plugin, com.google.firebase.dataconnect.sharedtest, designed to share test utilities between unit tests and Android instrumentation tests. It includes a custom Gradle task that identifies Kotlin files annotated with @file:SharedWithAndroidTest in the unit test source set and copies them to a generated source directory for androidTest. Review feedback suggests replacing a risky null assertion with a safer check in the plugin implementation, removing redundant manual directory cleanup logic handled automatically by Gradle's @OutputDirectory, and improving the robustness of the annotation detection logic to avoid false positives.
…ectory, as gradle already looks after that [skip actions]
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new Gradle plugin, com.google.firebase.dataconnect.sharedtest, which enables sharing test utilities between unit tests and Android instrumentation tests by copying annotated Kotlin files into the androidTest source set. The review feedback identifies two critical improvements for the CopySharedWithAndroidTestFiles task: using relative paths in generated headers to maintain Gradle build cache reproducibility and clearing the output directory before execution to prevent stale files from persisting when annotations are removed.
… files, to avoid defeating build caches [skip actions]
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new Gradle plugin, com.google.firebase.dataconnect.sharedtest, designed to share test utilities between unit tests and Android instrumentation tests. It includes a custom Gradle task, CopySharedWithAndroidTestFiles, which scans for Kotlin files annotated with @file:SharedWithAndroidTest and copies them into the generated source sets for androidTest. Feedback suggests clearing the output directory before copying to avoid stale files and marking the input directory as optional to prevent build failures when the source directory is absent.
This PR introduces a new Gradle plugin that enables sharing test utilities between unit tests (
src/test) and instrumentation tests (src/androidTest). It allows developers to annotate Kotlin files with@file:SharedWithAndroidTest, which the plugin will automatically copy into theandroidTestgenerated sources directory during the build process.Highlights
com.google.firebase.dataconnect.sharedtest) to facilitate sharing code between unit and instrumentation tests.CopySharedWithAndroidTestFilestask to recursively search for files annotated with@file:SharedWithAndroidTestand copy them to theandroidTestsource set.@SharedWithAndroidTestannotation to mark source files intended for sharing across test environments.Changelog
com.google.firebase.dataconnect.sharedtestplugin.com.google.firebase.dataconnect.sharedtestplugin.@file:SharedWithAndroidTestfrom thesrc/testdirectory to a generatedandroidTestdirectory.CopySharedWithAndroidTestFilestask and hooks it into theandroidTestsource sets.@SharedWithAndroidTestfile-level annotation used to mark code to be shared.