Convert java modules' module-info.json to Soong

This change converts the module-info.json of java_library
and other java modules that call java_library's
GenerateAndroidBuildActions() in its
GenerateAndroidBuildActions() to Soong.

Bug: 389720048
Test: Inspect module-info.json diff, CI
Change-Id: I0db5ae3a5fb41bb60dc538aea2d8e614c9ae23d4
diff --git a/android/module_context.go b/android/module_context.go
index e63c672..1f4758c 100644
--- a/android/module_context.go
+++ b/android/module_context.go
@@ -231,6 +231,10 @@
 	// the module-info.json generated by Make, and Make will not generate its own data for this module.
 	ModuleInfoJSON() *ModuleInfoJSON
 
+	// Simiar to ModuleInfoJSON, ExtraModuleInfoJSON also returns a pointer to the ModuleInfoJSON struct.
+	// This should only be called by a module that generates multiple AndroidMkEntries struct.
+	ExtraModuleInfoJSON() *ModuleInfoJSON
+
 	// SetOutputFiles stores the outputFiles to outputFiles property, which is used
 	// to set the OutputFilesProvider later.
 	SetOutputFiles(outputFiles Paths, tag string)
@@ -296,7 +300,7 @@
 
 	// moduleInfoJSON can be filled out by GenerateAndroidBuildActions to write a JSON file that will
 	// be included in the final module-info.json produced by Make.
-	moduleInfoJSON *ModuleInfoJSON
+	moduleInfoJSON []*ModuleInfoJSON
 
 	// containersInfo stores the information about the containers and the information of the
 	// apexes the module belongs to.
@@ -624,8 +628,8 @@
 		skipInstall:           m.skipInstall(),
 		aconfigPaths:          uniquelist.Make(m.getAconfigPaths()),
 		archType:              m.target.Arch.ArchType,
-        overrides:             uniquelist.Make(overrides),
-        owner:                 owner,
+		overrides:             uniquelist.Make(overrides),
+		owner:                 owner,
 	}
 	m.packagingSpecs = append(m.packagingSpecs, spec)
 	return spec
@@ -759,8 +763,8 @@
 		skipInstall:      m.skipInstall(),
 		aconfigPaths:     uniquelist.Make(m.getAconfigPaths()),
 		archType:         m.target.Arch.ArchType,
-        overrides:        uniquelist.Make(overrides),
-        owner:            owner,
+		overrides:        uniquelist.Make(overrides),
+		owner:            owner,
 	})
 
 	return fullInstallPath
@@ -807,8 +811,8 @@
 		skipInstall:      m.skipInstall(),
 		aconfigPaths:     uniquelist.Make(m.getAconfigPaths()),
 		archType:         m.target.Arch.ArchType,
-        overrides:        uniquelist.Make(overrides),
-        owner:            owner,
+		overrides:        uniquelist.Make(overrides),
+		owner:            owner,
 	})
 
 	return fullInstallPath
@@ -846,11 +850,20 @@
 }
 
 func (m *moduleContext) ModuleInfoJSON() *ModuleInfoJSON {
-	if moduleInfoJSON := m.moduleInfoJSON; moduleInfoJSON != nil {
-		return moduleInfoJSON
+	if len(m.moduleInfoJSON) == 0 {
+		moduleInfoJSON := &ModuleInfoJSON{}
+		m.moduleInfoJSON = append(m.moduleInfoJSON, moduleInfoJSON)
 	}
+	return m.moduleInfoJSON[0]
+}
+
+func (m *moduleContext) ExtraModuleInfoJSON() *ModuleInfoJSON {
+	if len(m.moduleInfoJSON) == 0 {
+		panic("call ModuleInfoJSON() instead")
+	}
+
 	moduleInfoJSON := &ModuleInfoJSON{}
-	m.moduleInfoJSON = moduleInfoJSON
+	m.moduleInfoJSON = append(m.moduleInfoJSON, moduleInfoJSON)
 	return moduleInfoJSON
 }