Skip to content

Hide TestOutputHandler via annotations in AndroidX Test. - #2532

Open
copybara-service[bot] wants to merge 1 commit into
mainfrom
piper_1015650486
Open

copybara-service[bot] wants to merge 1 commit into
mainfrom
piper_1015650486

Conversation

@copybara-service

Copy link
Copy Markdown

Hide TestOutputHandler via annotations in AndroidX Test.

Mark TestOutputHandler with @RestrictTo(Scope.LIBRARY) in
open-source exports (via copybara:insert) and with a package-private
internal @HideFromApi annotation in google3 so Metalava and Dackka
exclude it without relying on @hide Javadoc tags.

In google3, external test harnesses still implement TestOutputHandler
(so active @RestrictTo triggers ErrorProne RestrictToEnforcer), and
package-level filtering cannot be used on
androidx.test.internal.platform.util because TestOutputEmitter in
the same package is part of monitor's current_internal.txt.

Using annotations instead of @hide doc tags:

  • Unlocks passing --ignore-comments on API signature generation,
    improving build performance and memory usage by skipping Javadoc/KDoc
    comment extraction and AST parsing.
  • Enables Metalava declarative <api-surfaces> XML configuration,
    which ignores @hide and @removed Javadoc tags by design.
  • Enforces @RestrictTo(Scope.LIBRARY) statically for external callers.

Mark `TestOutputHandler` with `@RestrictTo(Scope.LIBRARY)` in
open-source exports (via `copybara:insert`) and with a package-private
internal `@HideFromApi` annotation in google3 so Metalava and Dackka
exclude it without relying on `@hide` Javadoc tags.

In google3, external test harnesses still implement `TestOutputHandler`
(so active `@RestrictTo` triggers ErrorProne `RestrictToEnforcer`), and
package-level filtering cannot be used on
`androidx.test.internal.platform.util` because `TestOutputEmitter` in
the same package is part of `monitor`'s `current_internal.txt`.

Using annotations instead of `@hide` doc tags:
- Unlocks passing `--ignore-comments` on API signature generation,
  improving build performance and memory usage by skipping Javadoc/KDoc
  comment extraction and AST parsing.
- Enables Metalava declarative `<api-surfaces>` XML configuration,
  which ignores `@hide` and `@removed` Javadoc tags by design.
- Enforces `@RestrictTo(Scope.LIBRARY)` statically for external callers.

PiperOrigin-RevId: 1015650486

This branch has not been deployed

No deployments
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.

1 participant