summaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
author Paul Duffin <paulduffin@google.com> 2024-07-22 21:03:50 +0100
committer Paul Duffin <paulduffin@google.com> 2024-07-23 10:38:01 +0100
commit278193669eee7a92187f8f70a738bcda1b9e298a (patch)
tree492ae004b6371fb962b6c1e23a59b1fcdb5e417d /java/java.go
parent39d3883500fe2fa964a64df2e3225a7811744b5e (diff)
Pass config files to metalava
Adds a filegroup "metalava-config-files" whose contents are passed to Metalava using the `--config-file` option. Bug: 354699349 Test: m checkapi Change-Id: I1e246517c2ef678e41214c975aecee97f9faca67
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go17
1 files changed, 13 insertions, 4 deletions
diff --git a/java/java.go b/java/java.go
index 3dae4e42b..b320732cd 100644
--- a/java/java.go
+++ b/java/java.go
@@ -269,7 +269,7 @@ type JavaInfo struct {
ImplementationAndResourcesJars android.Paths
// ImplementationJars is a list of jars that contain the implementations of classes in the
- //module.
+ // module.
ImplementationJars android.Paths
// ResourceJars is a list of jars that contain the resources included in the module.
@@ -2039,12 +2039,17 @@ type JavaApiLibraryProperties struct {
// List of aconfig_declarations module names that the stubs generated in this module
// depend on.
Aconfig_declarations []string
+
+ // List of hard coded filegroups containing Metalava config files that are passed to every
+ // Metalava invocation that this module performs. See addMetalavaConfigFilesToCmd.
+ ConfigFiles []string `android:"path" blueprint:"mutated"`
}
func ApiLibraryFactory() android.Module {
module := &ApiLibrary{}
- android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
module.AddProperties(&module.properties)
+ module.properties.ConfigFiles = getMetalavaConfigFilegroupReference()
+ android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
module.initModuleAndImport(module)
android.InitDefaultableModule(module)
return module
@@ -2060,7 +2065,7 @@ func (al *ApiLibrary) StubsJar() android.Path {
func metalavaStubCmd(ctx android.ModuleContext, rule *android.RuleBuilder,
srcs android.Paths, homeDir android.WritablePath,
- classpath android.Paths) *android.RuleBuilderCommand {
+ classpath android.Paths, configFiles android.Paths) *android.RuleBuilderCommand {
rule.Command().Text("rm -rf").Flag(homeDir.String())
rule.Command().Text("mkdir -p").Flag(homeDir.String())
@@ -2099,6 +2104,8 @@ func metalavaStubCmd(ctx android.ModuleContext, rule *android.RuleBuilder,
FlagWithArg("--hide ", "InvalidNullabilityOverride").
FlagWithArg("--hide ", "ChangedDefault")
+ addMetalavaConfigFilesToCmd(cmd, configFiles)
+
if len(classpath) == 0 {
// The main purpose of the `--api-class-resolution api` option is to force metalava to ignore
// classes on the classpath when an API file contains missing classes. However, as this command
@@ -2310,7 +2317,9 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
ctx.ModuleErrorf("Error: %s has an empty api file.", ctx.ModuleName())
}
- cmd := metalavaStubCmd(ctx, rule, srcFiles, homeDir, systemModulesPaths)
+ configFiles := android.PathsForModuleSrc(ctx, al.properties.ConfigFiles)
+
+ cmd := metalavaStubCmd(ctx, rule, srcFiles, homeDir, systemModulesPaths, configFiles)
al.stubsFlags(ctx, cmd, stubsDir)