Create full API surface java_library in combined_apis

This change renames the full api surface stub jar generating
java_library modules by adding ".from-source" suffix and creating the
modules in combined_apis. Either the ".from-source" module or the
".from-text" module is added as static libs based on the build config.

Bug: 284150060
Bug: 284995489
Bug: 285410821
Test: m && m --build-from-text-stub and verify no ninja path between android_stubs_current and android_stubs_current.from-source
Change-Id: I1419af0cd0ca2199e82e3337717b6391a51267c4
diff --git a/api/api.go b/api/api.go
index af817b5..c568a45 100644
--- a/api/api.go
+++ b/api/api.go
@@ -96,6 +96,7 @@
 	Sdk_version *string
 	Static_libs []string
 	Visibility  []string
+	Defaults    []string
 }
 
 type fgProps struct {
@@ -362,6 +363,30 @@
 	}
 }
 
+func createFullApiLibraries(ctx android.LoadHookContext) {
+	javaLibraryNames := []string{
+		"android_stubs_current",
+		"android_system_stubs_current",
+		"android_test_stubs_current",
+		"android_module_lib_stubs_current",
+		"android_system_server_stubs_current",
+	}
+
+	for _, libraryName := range javaLibraryNames {
+		props := libraryProps{}
+		props.Name = proptools.StringPtr(libraryName)
+		staticLib := libraryName + ".from-source"
+		if ctx.Config().BuildFromTextStub() {
+			staticLib = libraryName + ".from-text"
+		}
+		props.Static_libs = []string{staticLib}
+		props.Defaults = []string{"android.jar_defaults"}
+		props.Visibility = []string{"//visibility:public"}
+
+		ctx.CreateModule(java.LibraryFactory, &props)
+	}
+}
+
 func (a *CombinedApis) createInternalModules(ctx android.LoadHookContext) {
 	bootclasspath := a.properties.Bootclasspath
 	system_server_classpath := a.properties.System_server_classpath
@@ -382,6 +407,8 @@
 	createPublicStubsSourceFilegroup(ctx, bootclasspath)
 
 	createApiContributionDefaults(ctx, bootclasspath)
+
+	createFullApiLibraries(ctx)
 }
 
 func combinedApisModuleFactory() android.Module {