Add "test-only" flag for java modules

As part of aosp/3022586 where we added the idea of "test-only" modules
and top_level_test_targets, this CL implements that for java modules.

We let users set "test-only" on java_library, but not on other modules
where the module kind is implicitly test-only, like java_test.
The implementation, not the user decides it is test-only.
We also exclude it from java_defaults.

	% gqui from  "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind, count(*) where teams.test_only = true and teams.kind not like "%cc_%" group by teams.kind'
	+--------------------------+----------+
	|        teams.kind        | count(*) |
	+--------------------------+----------+
	| android_test             |     1382 |
	| android_test_helper_app  |     1680 |
	| java_fuzz                |        5 |
	| java_test                |      774 |
	| java_test_helper_library |       29 |
	+--------------------------+----------+

	 % gqui from  "flatten(~/aosp-main-with-phones/out/soong/ownership/all_teams.pb, teams)" proto team.proto:AllTeams 'select teams.kind, count(*) where teams.top_level_target = true and teams.kind not like "%cc_%" group by teams.kind'
	+--------------+----------+
	|  teams.kind  | count(*) |
	+--------------+----------+
	| android_test |     1382 |
	| java_fuzz    |        5 |
	| java_test    |      774 |
	+--------------+----------+

Test: m nothing --no-skip-soong-tests
Test: go test ./java
Test: m all_teams

Bug: b/327280661
Change-Id: I9c3ad947dc3d68d6427abada27449526d69daa6b
diff --git a/java/fuzz.go b/java/fuzz.go
index dc4c6be..fb31ce7 100644
--- a/java/fuzz.go
+++ b/java/fuzz.go
@@ -64,6 +64,8 @@
 	module.Module.properties.Installable = proptools.BoolPtr(true)
 	module.Module.dexpreopter.isTest = true
 	module.Module.linter.properties.Lint.Test = proptools.BoolPtr(true)
+	module.Module.sourceProperties.Test_only = proptools.BoolPtr(true)
+	module.Module.sourceProperties.Top_level_test_target = true
 
 	android.AddLoadHook(module, func(ctx android.LoadHookContext) {
 		disableLinuxBionic := struct {