Merge "move CollectDependencyAconfigFiles to android" into main
diff --git a/aconfig/codegen/java_aconfig_library.go b/aconfig/codegen/java_aconfig_library.go
index 4134893..c027815 100644
--- a/aconfig/codegen/java_aconfig_library.go
+++ b/aconfig/codegen/java_aconfig_library.go
@@ -61,10 +61,18 @@
ctx.AddDependency(ctx.Module(), declarationsTag, declarations)
}
- // Add aconfig-annotations-lib as a dependency for the optimization / code stripping annotations
- module.AddSharedLibrary("aconfig-annotations-lib")
- // TODO(b/303773055): Remove the annotation after access issue is resolved.
- module.AddSharedLibrary("unsupportedappusage")
+ // "libcore_aconfig_flags_lib" module has a circular dependency because the shared libraries
+ // are built on core_current and the module is used to flag the APIs in the core_current.
+ // http://b/316554963#comment2 has the details of the circular dependency chain.
+ // If a java_aconfig_library uses "none" sdk_version, it should include and build these
+ // annotation files as the shared library themselves.
+ var addLibraries bool = module.Library.Module.SdkVersion(ctx).Kind != android.SdkNone
+ if addLibraries {
+ // Add aconfig-annotations-lib as a dependency for the optimization / code stripping annotations
+ module.AddSharedLibrary("aconfig-annotations-lib")
+ // TODO(b/303773055): Remove the annotation after access issue is resolved.
+ module.AddSharedLibrary("unsupportedappusage")
+ }
}
func (callbacks *JavaAconfigDeclarationsLibraryCallbacks) GenerateSourceJarBuildActions(module *java.GeneratedJavaLibraryModule, ctx android.ModuleContext) android.Path {