Use the Soong output as the checkbuild target

Save disk space when building checkbuild by avoiding copying the Soong
output file into the Make intermediates directory.

All the same files in out/soong that were created by m checkbuild before
this patch are still created after this patch.  In the internal branch
the total size of the out directory after m checkbuild is reduced from
1320 GB to 965 GB.

Bug: 201816050
Test: m checkbuild
Change-Id: I6370df44f9baab00fcfe30c072600fe58109954d
diff --git a/core/soong_java_prebuilt.mk b/core/soong_java_prebuilt.mk
index 1b93be2..2c909ac 100644
--- a/core/soong_java_prebuilt.mk
+++ b/core/soong_java_prebuilt.mk
@@ -25,6 +25,15 @@
   LOCAL_ADDITIONAL_CHECKED_MODULE += $(LOCAL_SOONG_AAR)
 endif
 
+# Use the Soong output as the checkbuild target instead of LOCAL_BUILT_MODULE
+# to avoid checkbuilds making an extra copy of every module.
+LOCAL_CHECKED_MODULE := $(LOCAL_PREBUILT_MODULE_FILE)
+LOCAL_ADDITIONAL_CHECKED_MODULE += $(LOCAL_SOONG_HEADER_JAR)
+LOCAL_ADDITIONAL_CHECKED_MODULE += $(LOCAL_FULL_MANIFEST_FILE)
+LOCAL_ADDITIONAL_CHECKED_MODULE += $(LOCAL_SOONG_DEXPREOPT_CONFIG)
+LOCAL_ADDITIONAL_CHECKED_MODULE += $(LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE)
+LOCAL_ADDITIONAL_CHECKED_MODULE += $(LOCAL_SOONG_DEX_JAR)
+
 #######################################
 include $(BUILD_SYSTEM)/base_rules.mk
 #######################################