Add exported_plugins to java.Library.
The behaviour is similar to go/be#java_library.exported_plugins. Plugins added to exported_plugins of library X are not applied to the library itself, but rather to libraries that directly depend on the library X. Test: m checkbuild Bug: 139740873 Change-Id: I4042bd482ad9cb12d6fbaac51f039d38b1b7a428
This commit is contained in:
50
java/java.go
50
java/java.go
@@ -145,6 +145,9 @@ type CompilerProperties struct {
|
||||
// List of modules to use as annotation processors
|
||||
Plugins []string
|
||||
|
||||
// List of modules to export to libraries that directly depend on this library as annotation processors
|
||||
Exported_plugins []string
|
||||
|
||||
// The number of Java source entries each Javac instance can process
|
||||
Javac_shard_size *int64
|
||||
|
||||
@@ -360,10 +363,16 @@ type Module struct {
|
||||
// manifest file to use instead of properties.Manifest
|
||||
overrideManifest android.OptionalPath
|
||||
|
||||
// list of SDK lib names that this java moudule is exporting
|
||||
// list of SDK lib names that this java module is exporting
|
||||
exportedSdkLibs []string
|
||||
|
||||
// list of source files, collected from srcFiles with uniqie java and all kt files,
|
||||
// list of plugins that this java module is exporting
|
||||
exportedPluginJars android.Paths
|
||||
|
||||
// list of plugins that this java module is exporting
|
||||
exportedPluginClasses []string
|
||||
|
||||
// list of source files, collected from srcFiles with unique java and all kt files,
|
||||
// will be used by android.IDEInfo struct
|
||||
expandIDEInfoCompiledSrcs []string
|
||||
|
||||
@@ -410,6 +419,7 @@ type Dependency interface {
|
||||
DexJar() android.Path
|
||||
AidlIncludeDirs() android.Paths
|
||||
ExportedSdkLibs() []string
|
||||
ExportedPlugins() (android.Paths, []string)
|
||||
SrcJarArgs() ([]string, android.Paths)
|
||||
BaseModuleName() string
|
||||
}
|
||||
@@ -452,6 +462,7 @@ var (
|
||||
libTag = dependencyTag{name: "javalib"}
|
||||
java9LibTag = dependencyTag{name: "java9lib"}
|
||||
pluginTag = dependencyTag{name: "plugin"}
|
||||
exportedPluginTag = dependencyTag{name: "exported-plugin"}
|
||||
bootClasspathTag = dependencyTag{name: "bootclasspath"}
|
||||
systemModulesTag = dependencyTag{name: "system modules"}
|
||||
frameworkResTag = dependencyTag{name: "framework-res"}
|
||||
@@ -561,6 +572,7 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
|
||||
ctx.AddVariationDependencies(nil, staticLibTag, j.properties.Static_libs...)
|
||||
|
||||
ctx.AddFarVariationDependencies(ctx.Config().BuildOSCommonTarget.Variations(), pluginTag, j.properties.Plugins...)
|
||||
ctx.AddFarVariationDependencies(ctx.Config().BuildOSCommonTarget.Variations(), exportedPluginTag, j.properties.Exported_plugins...)
|
||||
|
||||
android.ProtoDeps(ctx, &j.protoProperties)
|
||||
if j.hasSrcExt(".proto") {
|
||||
@@ -800,6 +812,8 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
|
||||
// sdk lib names from dependencies are re-exported
|
||||
j.exportedSdkLibs = append(j.exportedSdkLibs, dep.ExportedSdkLibs()...)
|
||||
deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...)
|
||||
pluginJars, pluginClasses := dep.ExportedPlugins()
|
||||
addPlugins(&deps, pluginJars, pluginClasses...)
|
||||
case java9LibTag:
|
||||
deps.java9Classpath = append(deps.java9Classpath, dep.HeaderJars()...)
|
||||
case staticLibTag:
|
||||
@@ -810,16 +824,31 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
|
||||
// sdk lib names from dependencies are re-exported
|
||||
j.exportedSdkLibs = append(j.exportedSdkLibs, dep.ExportedSdkLibs()...)
|
||||
deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...)
|
||||
pluginJars, pluginClasses := dep.ExportedPlugins()
|
||||
addPlugins(&deps, pluginJars, pluginClasses...)
|
||||
case pluginTag:
|
||||
if plugin, ok := dep.(*Plugin); ok {
|
||||
deps.processorPath = append(deps.processorPath, dep.ImplementationAndResourcesJars()...)
|
||||
if plugin.pluginProperties.Processor_class != nil {
|
||||
deps.processorClasses = append(deps.processorClasses, *plugin.pluginProperties.Processor_class)
|
||||
addPlugins(&deps, plugin.ImplementationAndResourcesJars(), *plugin.pluginProperties.Processor_class)
|
||||
} else {
|
||||
addPlugins(&deps, plugin.ImplementationAndResourcesJars())
|
||||
}
|
||||
deps.disableTurbine = deps.disableTurbine || Bool(plugin.pluginProperties.Generates_api)
|
||||
} else {
|
||||
ctx.PropertyErrorf("plugins", "%q is not a java_plugin module", otherName)
|
||||
}
|
||||
case exportedPluginTag:
|
||||
if plugin, ok := dep.(*Plugin); ok {
|
||||
if plugin.pluginProperties.Generates_api != nil && *plugin.pluginProperties.Generates_api {
|
||||
ctx.PropertyErrorf("exported_plugins", "Cannot export plugins with generates_api = true, found %v", otherName)
|
||||
}
|
||||
j.exportedPluginJars = append(j.exportedPluginJars, plugin.ImplementationAndResourcesJars()...)
|
||||
if plugin.pluginProperties.Processor_class != nil {
|
||||
j.exportedPluginClasses = append(j.exportedPluginClasses, *plugin.pluginProperties.Processor_class)
|
||||
}
|
||||
} else {
|
||||
ctx.PropertyErrorf("exported_plugins", "%q is not a java_plugin module", otherName)
|
||||
}
|
||||
case frameworkApkTag:
|
||||
if ctx.ModuleName() == "android_stubs_current" ||
|
||||
ctx.ModuleName() == "android_system_stubs_current" ||
|
||||
@@ -875,6 +904,11 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
|
||||
return deps
|
||||
}
|
||||
|
||||
func addPlugins(deps *deps, pluginJars android.Paths, pluginClasses ...string) {
|
||||
deps.processorPath = append(deps.processorPath, pluginJars...)
|
||||
deps.processorClasses = append(deps.processorClasses, pluginClasses...)
|
||||
}
|
||||
|
||||
func getJavaVersion(ctx android.ModuleContext, javaVersion string, sdkContext sdkContext) javaVersion {
|
||||
v := sdkContext.sdkVersion()
|
||||
// For PDK builds, use the latest SDK version instead of "current"
|
||||
@@ -1569,6 +1603,10 @@ func (j *Module) ExportedSdkLibs() []string {
|
||||
return j.exportedSdkLibs
|
||||
}
|
||||
|
||||
func (j *Module) ExportedPlugins() (android.Paths, []string) {
|
||||
return j.exportedPluginJars, j.exportedPluginClasses
|
||||
}
|
||||
|
||||
func (j *Module) SrcJarArgs() ([]string, android.Paths) {
|
||||
return j.srcJarArgs, j.srcJarDeps
|
||||
}
|
||||
@@ -2143,6 +2181,10 @@ func (j *Import) ExportedSdkLibs() []string {
|
||||
return j.exportedSdkLibs
|
||||
}
|
||||
|
||||
func (j *Import) ExportedPlugins() (android.Paths, []string) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (j *Import) SrcJarArgs() ([]string, android.Paths) {
|
||||
return nil, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user