summaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
author Ronald Braunstein <rbraunstein@google.com> 2024-04-12 11:23:19 -0700
committer Ronald Braunstein <rbraunstein@google.com> 2024-04-12 11:42:10 -0700
commitcdc66f4268d5f185fc39208352de51965ed7aa53 (patch)
tree6380074f7138b5d8c564bfa1ce78cbe03beab7c7 /java/java.go
parentfc5cdcbdf55980e43f20d5d4bd11e83532ca8d10 (diff)
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
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/java/java.go b/java/java.go
index 778c9a2d9..ca99e6991 100644
--- a/java/java.go
+++ b/java/java.go
@@ -958,6 +958,11 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
}
j.installFile = ctx.InstallFile(installDir, j.Stem()+".jar", j.outputFile, extraInstallDeps...)
}
+
+ android.SetProvider(ctx, android.TestOnlyProviderKey, android.TestModuleInformation{
+ TestOnly: Bool(j.sourceProperties.Test_only),
+ TopLevelTarget: j.sourceProperties.Top_level_test_target,
+ })
}
func (j *Library) DepsMutator(ctx android.BottomUpMutatorContext) {
@@ -1123,6 +1128,7 @@ func LibraryFactory() android.Module {
module := &Library{}
module.addHostAndDeviceProperties()
+ module.AddProperties(&module.sourceProperties)
module.initModuleAndImport(module)
@@ -1604,6 +1610,8 @@ func TestFactory() android.Module {
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
InitJavaModule(module, android.HostAndDeviceSupported)
return module
@@ -1619,6 +1627,7 @@ func TestHelperLibraryFactory() android.Module {
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)
InitJavaModule(module, android.HostAndDeviceSupported)
return module
@@ -1674,6 +1683,8 @@ func InitTestHost(th *TestHost, installable *bool, testSuites []string, autoGenC
th.properties.Installable = installable
th.testProperties.Auto_gen_config = autoGenConfig
th.testProperties.Test_suites = testSuites
+ th.sourceProperties.Test_only = proptools.BoolPtr(true)
+ th.sourceProperties.Top_level_test_target = true
}
//
@@ -1799,7 +1810,7 @@ func BinaryFactory() android.Module {
module := &Binary{}
module.addHostAndDeviceProperties()
- module.AddProperties(&module.binaryProperties)
+ module.AddProperties(&module.binaryProperties, &module.sourceProperties)
module.Module.properties.Installable = proptools.BoolPtr(true)