Ignore VisibleForTests in all test libraries In test libraries, the lint warning that you shouldn't use code annotated with @VisibleForTests is a false positive. While the code is technically production code, it should only be run as test code. This CL introduces two new library types: PUBLISHED_TEST_LIBRARY and INTERNAL_TEST_LIBRARY. The first one has the same properties as PUBLISHED_LIBRARY and the latter one has the same properties as UNSET. The difference is that for these test library types, the "VisibleForTests" lint warning is disabled instead of fatal. I didn't change the libary type of the following libraries, mostly because they did not have a type (so UNSET), but did have publish set to SNAPSHOT_AND_RELEASE (with some exceptions, e.g. LINT libraries). Setting these libraries to INTERNAL_TEST_LIBRARY would be incorrect (they are not internal), but setting them to PUBLISHED_TEST_LIBRARY **may** affect how they are published. * arch/core/core-testing * camera/camera-camera2-pipe-testing * compose/lint/common-test * core/core-animation-testing * enterprise/enterprise-feedback-testing * fragment/fragment-testing * fragment/fragment-testing-lint * lifecycle/lifecycle-runtime-testing * mediarouter/mediarouter-testing * navigation/navigation-testing * room/room-compiler-processing-testing * room/room-testing * wear/wear-input-testing * wear/tiles/tiles-testing * work/work-testing Fix: 207828221 Test: ./gradlew bOS Change-Id: I3d7a1cb601bb95ebbad319b1dc739e827a8ece8f
diff --git a/testutils/testutils-common/build.gradle b/testutils/testutils-common/build.gradle index dccc2a9..19480c5 100644 --- a/testutils/testutils-common/build.gradle +++ b/testutils/testutils-common/build.gradle
@@ -16,6 +16,8 @@ * limitations under the License. */ +import androidx.build.LibraryType + plugins { id("AndroidXPlugin") id("kotlin") @@ -32,3 +34,7 @@ freeCompilerArgs += ["-Xopt-in=kotlin.RequiresOptIn"] } } + +androidx { + type = LibraryType.INTERNAL_TEST_LIBRARY +}