diff --git a/apex/apex_test.go b/apex/apex_test.go index 18409001e..bb6e026cc 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -305,7 +305,7 @@ func testApexContext(t *testing.T, bp string, handlers ...testCustomizer) (*andr ctx.RegisterModuleType("sh_binary", android.ShBinaryFactory) ctx.RegisterModuleType("filegroup", android.FileGroupFactory) java.RegisterJavaBuildComponents(ctx) - ctx.RegisterModuleType("java_system_modules", java.SystemModulesFactory) + java.RegisterSystemModulesBuildComponents(ctx) java.RegisterAppBuildComponents(ctx) ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators) diff --git a/java/java_test.go b/java/java_test.go index d9a43f593..adc5ad181 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -67,14 +67,13 @@ func testContext() *android.TestContext { RegisterAppBuildComponents(ctx) RegisterAARBuildComponents(ctx) RegisterGenRuleBuildComponents(ctx) - ctx.RegisterModuleType("java_system_modules", SystemModulesFactory) + RegisterSystemModulesBuildComponents(ctx) ctx.RegisterModuleType("java_plugin", PluginFactory) ctx.RegisterModuleType("filegroup", android.FileGroupFactory) ctx.RegisterModuleType("genrule", genrule.GenRuleFactory) RegisterDocsBuildComponents(ctx) RegisterStubsBuildComponents(ctx) - ctx.RegisterModuleType("java_sdk_library", SdkLibraryFactory) - ctx.RegisterModuleType("java_sdk_library_import", sdkLibraryImportFactory) + RegisterSdkLibraryBuildComponents(ctx) ctx.RegisterModuleType("prebuilt_apis", PrebuiltApisFactory) ctx.PreArchMutators(android.RegisterPrebuiltsPreArchMutators) ctx.PreArchMutators(android.RegisterPrebuiltsPostDepsMutators) diff --git a/java/sdk_library.go b/java/sdk_library.go index e204659e8..32b2d1ac2 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -68,8 +68,7 @@ var ( // 2) HTML generation func init() { - android.RegisterModuleType("java_sdk_library", SdkLibraryFactory) - android.RegisterModuleType("java_sdk_library_import", sdkLibraryImportFactory) + RegisterSdkLibraryBuildComponents(android.InitRegistrationContext) android.RegisterMakeVarsProvider(pctx, func(ctx android.MakeVarsContext) { javaSdkLibraries := javaSdkLibraries(ctx.Config()) @@ -78,6 +77,11 @@ func init() { }) } +func RegisterSdkLibraryBuildComponents(ctx android.RegistrationContext) { + ctx.RegisterModuleType("java_sdk_library", SdkLibraryFactory) + ctx.RegisterModuleType("java_sdk_library_import", sdkLibraryImportFactory) +} + type sdkLibraryProperties struct { // List of Java libraries that will be in the classpath when building stubs Stub_only_libs []string `android:"arch_variant"` diff --git a/java/system_modules.go b/java/system_modules.go index b56a401d3..ed2fc1856 100644 --- a/java/system_modules.go +++ b/java/system_modules.go @@ -28,11 +28,15 @@ import ( // system modules in a runtime image using the jmod and jlink tools. func init() { - android.RegisterModuleType("java_system_modules", SystemModulesFactory) + RegisterSystemModulesBuildComponents(android.InitRegistrationContext) pctx.SourcePathVariable("moduleInfoJavaPath", "build/soong/scripts/jars-to-module-info-java.sh") } +func RegisterSystemModulesBuildComponents(ctx android.RegistrationContext) { + ctx.RegisterModuleType("java_system_modules", SystemModulesFactory) +} + var ( jarsTosystemModules = pctx.AndroidStaticRule("jarsTosystemModules", blueprint.RuleParams{ Command: `rm -rf ${outDir} ${workDir} && mkdir -p ${workDir}/jmod && ` + diff --git a/sysprop/sysprop_test.go b/sysprop/sysprop_test.go index d44f4cf2f..d24262dde 100644 --- a/sysprop/sysprop_test.go +++ b/sysprop/sysprop_test.go @@ -58,7 +58,8 @@ func testContext(config android.Config) *android.TestContext { ctx := android.NewTestArchContext() java.RegisterJavaBuildComponents(ctx) java.RegisterAppBuildComponents(ctx) - ctx.RegisterModuleType("java_system_modules", java.SystemModulesFactory) + java.RegisterSystemModulesBuildComponents(ctx) + ctx.PreArchMutators(android.RegisterPrebuiltsPreArchMutators) ctx.PreArchMutators(android.RegisterPrebuiltsPostDepsMutators) ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)