Convert java.Dependency to JavaInfo provider
Export information about java dependencies through a Provider instead of accessing the module directly. Test: java_test.go Test: no changes to build.ninja Change-Id: Ifc5d566bf6f6ebc0ad399e948effaa1ef6a22876
This commit is contained in:
parent
a6cfcac727
commit
dcf71b299c
|
@ -1949,3 +1949,28 @@ type DataPath struct {
|
||||||
// The install path of the data file, relative to the install root.
|
// The install path of the data file, relative to the install root.
|
||||||
RelativeInstallPath string
|
RelativeInstallPath string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PathsIfNonNil returns a Paths containing only the non-nil input arguments.
|
||||||
|
func PathsIfNonNil(paths ...Path) Paths {
|
||||||
|
if len(paths) == 0 {
|
||||||
|
// Fast path for empty argument list
|
||||||
|
return nil
|
||||||
|
} else if len(paths) == 1 {
|
||||||
|
// Fast path for a single argument
|
||||||
|
if paths[0] != nil {
|
||||||
|
return paths
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ret := make(Paths, 0, len(paths))
|
||||||
|
for _, path := range paths {
|
||||||
|
if path != nil {
|
||||||
|
ret = append(ret, path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(ret) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
|
@ -4364,7 +4364,7 @@ func TestPrebuiltExportDexImplementationJars(t *testing.T) {
|
||||||
|
|
||||||
checkDexJarBuildPath := func(t *testing.T, ctx *android.TestContext, name string) {
|
checkDexJarBuildPath := func(t *testing.T, ctx *android.TestContext, name string) {
|
||||||
// Make sure the import has been given the correct path to the dex jar.
|
// Make sure the import has been given the correct path to the dex jar.
|
||||||
p := ctx.ModuleForTests(name, "android_common_myapex").Module().(java.Dependency)
|
p := ctx.ModuleForTests(name, "android_common_myapex").Module().(java.UsesLibraryDependency)
|
||||||
dexJarBuildPath := p.DexJarBuildPath()
|
dexJarBuildPath := p.DexJarBuildPath()
|
||||||
if expected, actual := ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar", android.NormalizePathForTesting(dexJarBuildPath); actual != expected {
|
if expected, actual := ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar", android.NormalizePathForTesting(dexJarBuildPath); actual != expected {
|
||||||
t.Errorf("Incorrect DexJarBuildPath value '%s', expected '%s'", actual, expected)
|
t.Errorf("Incorrect DexJarBuildPath value '%s', expected '%s'", actual, expected)
|
||||||
|
|
|
@ -28,7 +28,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type AndroidLibraryDependency interface {
|
type AndroidLibraryDependency interface {
|
||||||
Dependency
|
|
||||||
ExportPackage() android.Path
|
ExportPackage() android.Path
|
||||||
ExportedProguardFlagFiles() android.Paths
|
ExportedProguardFlagFiles() android.Paths
|
||||||
ExportedRRODirs() []rroDir
|
ExportedRRODirs() []rroDir
|
||||||
|
@ -796,9 +795,13 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
|
|
||||||
aapt2Link(ctx, a.exportPackage, srcJar, proguardOptionsFile, rTxt, a.extraAaptPackagesFile,
|
aapt2Link(ctx, a.exportPackage, srcJar, proguardOptionsFile, rTxt, a.extraAaptPackagesFile,
|
||||||
linkFlags, linkDeps, nil, overlayRes, transitiveAssets, nil)
|
linkFlags, linkDeps, nil, overlayRes, transitiveAssets, nil)
|
||||||
}
|
|
||||||
|
|
||||||
var _ Dependency = (*AARImport)(nil)
|
ctx.SetProvider(JavaInfoProvider, JavaInfo{
|
||||||
|
HeaderJars: android.PathsIfNonNil(a.classpathFile),
|
||||||
|
ImplementationAndResourcesJars: android.PathsIfNonNil(a.classpathFile),
|
||||||
|
ImplementationJars: android.PathsIfNonNil(a.classpathFile),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func (a *AARImport) HeaderJars() android.Paths {
|
func (a *AARImport) HeaderJars() android.Paths {
|
||||||
return android.Paths{a.classpathFile}
|
return android.Paths{a.classpathFile}
|
||||||
|
|
|
@ -97,15 +97,15 @@ func (d *DeviceHostConverter) GenerateAndroidBuildActions(ctx android.ModuleCont
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.VisitDirectDepsWithTag(deviceHostConverterDepTag, func(m android.Module) {
|
ctx.VisitDirectDepsWithTag(deviceHostConverterDepTag, func(m android.Module) {
|
||||||
if dep, ok := m.(Dependency); ok {
|
if ctx.OtherModuleHasProvider(m, JavaInfoProvider) {
|
||||||
d.headerJars = append(d.headerJars, dep.HeaderJars()...)
|
dep := ctx.OtherModuleProvider(m, JavaInfoProvider).(JavaInfo)
|
||||||
d.implementationJars = append(d.implementationJars, dep.ImplementationJars()...)
|
d.headerJars = append(d.headerJars, dep.HeaderJars...)
|
||||||
d.implementationAndResourceJars = append(d.implementationAndResourceJars, dep.ImplementationAndResourcesJars()...)
|
d.implementationJars = append(d.implementationJars, dep.ImplementationJars...)
|
||||||
d.resourceJars = append(d.resourceJars, dep.ResourceJars()...)
|
d.implementationAndResourceJars = append(d.implementationAndResourceJars, dep.ImplementationAndResourcesJars...)
|
||||||
|
d.resourceJars = append(d.resourceJars, dep.ResourceJars...)
|
||||||
|
|
||||||
srcJarArgs, srcJarDeps := dep.SrcJarArgs()
|
d.srcJarArgs = append(d.srcJarArgs, dep.SrcJarArgs...)
|
||||||
d.srcJarArgs = append(d.srcJarArgs, srcJarArgs...)
|
d.srcJarDeps = append(d.srcJarDeps, dep.SrcJarDeps...)
|
||||||
d.srcJarDeps = append(d.srcJarDeps, srcJarDeps...)
|
|
||||||
} else {
|
} else {
|
||||||
ctx.PropertyErrorf("libs", "module %q cannot be used as a dependency", ctx.OtherModuleName(m))
|
ctx.PropertyErrorf("libs", "module %q cannot be used as a dependency", ctx.OtherModuleName(m))
|
||||||
}
|
}
|
||||||
|
@ -131,9 +131,16 @@ func (d *DeviceHostConverter) GenerateAndroidBuildActions(ctx android.ModuleCont
|
||||||
d.combinedHeaderJar = d.headerJars[0]
|
d.combinedHeaderJar = d.headerJars[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
ctx.SetProvider(JavaInfoProvider, JavaInfo{
|
||||||
|
HeaderJars: d.headerJars,
|
||||||
|
ImplementationAndResourcesJars: d.implementationAndResourceJars,
|
||||||
|
ImplementationJars: d.implementationJars,
|
||||||
|
ResourceJars: d.resourceJars,
|
||||||
|
SrcJarArgs: d.srcJarArgs,
|
||||||
|
SrcJarDeps: d.srcJarDeps,
|
||||||
|
})
|
||||||
|
|
||||||
var _ Dependency = (*DeviceHostConverter)(nil)
|
}
|
||||||
|
|
||||||
func (d *DeviceHostConverter) HeaderJars() android.Paths {
|
func (d *DeviceHostConverter) HeaderJars() android.Paths {
|
||||||
return d.headerJars
|
return d.headerJars
|
||||||
|
|
|
@ -204,8 +204,9 @@ func (d *dexer) r8Flags(ctx android.ModuleContext, flags javaBuilderFlags) (r8Fl
|
||||||
// - prevent ProGuard stripping subclass in the support library that extends class added in the higher SDK version.
|
// - prevent ProGuard stripping subclass in the support library that extends class added in the higher SDK version.
|
||||||
// See b/20667396
|
// See b/20667396
|
||||||
var proguardRaiseDeps classpath
|
var proguardRaiseDeps classpath
|
||||||
ctx.VisitDirectDepsWithTag(proguardRaiseTag, func(dep android.Module) {
|
ctx.VisitDirectDepsWithTag(proguardRaiseTag, func(m android.Module) {
|
||||||
proguardRaiseDeps = append(proguardRaiseDeps, dep.(Dependency).HeaderJars()...)
|
dep := ctx.OtherModuleProvider(m, JavaInfoProvider).(JavaInfo)
|
||||||
|
proguardRaiseDeps = append(proguardRaiseDeps, dep.HeaderJars...)
|
||||||
})
|
})
|
||||||
|
|
||||||
r8Flags = append(r8Flags, proguardRaiseDeps.FormJavaClassPath("-libraryjars"))
|
r8Flags = append(r8Flags, proguardRaiseDeps.FormJavaClassPath("-libraryjars"))
|
||||||
|
|
|
@ -470,8 +470,9 @@ func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps {
|
||||||
|
|
||||||
switch tag {
|
switch tag {
|
||||||
case bootClasspathTag:
|
case bootClasspathTag:
|
||||||
if dep, ok := module.(Dependency); ok {
|
if ctx.OtherModuleHasProvider(module, JavaInfoProvider) {
|
||||||
deps.bootClasspath = append(deps.bootClasspath, dep.ImplementationJars()...)
|
dep := ctx.OtherModuleProvider(module, JavaInfoProvider).(JavaInfo)
|
||||||
|
deps.bootClasspath = append(deps.bootClasspath, dep.ImplementationJars...)
|
||||||
} else if sm, ok := module.(SystemModulesProvider); ok {
|
} else if sm, ok := module.(SystemModulesProvider); ok {
|
||||||
// A system modules dependency has been added to the bootclasspath
|
// A system modules dependency has been added to the bootclasspath
|
||||||
// so add its libs to the bootclasspath.
|
// so add its libs to the bootclasspath.
|
||||||
|
@ -480,23 +481,23 @@ func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps {
|
||||||
panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName()))
|
panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName()))
|
||||||
}
|
}
|
||||||
case libTag:
|
case libTag:
|
||||||
switch dep := module.(type) {
|
if dep, ok := module.(SdkLibraryDependency); ok {
|
||||||
case SdkLibraryDependency:
|
|
||||||
deps.classpath = append(deps.classpath, dep.SdkHeaderJars(ctx, j.sdkVersion())...)
|
deps.classpath = append(deps.classpath, dep.SdkHeaderJars(ctx, j.sdkVersion())...)
|
||||||
case Dependency:
|
} else if ctx.OtherModuleHasProvider(module, JavaInfoProvider) {
|
||||||
deps.classpath = append(deps.classpath, dep.HeaderJars()...)
|
dep := ctx.OtherModuleProvider(module, JavaInfoProvider).(JavaInfo)
|
||||||
deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...)
|
deps.classpath = append(deps.classpath, dep.HeaderJars...)
|
||||||
case android.SourceFileProducer:
|
deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs...)
|
||||||
|
} else if dep, ok := module.(android.SourceFileProducer); ok {
|
||||||
checkProducesJars(ctx, dep)
|
checkProducesJars(ctx, dep)
|
||||||
deps.classpath = append(deps.classpath, dep.Srcs()...)
|
deps.classpath = append(deps.classpath, dep.Srcs()...)
|
||||||
default:
|
} else {
|
||||||
ctx.ModuleErrorf("depends on non-java module %q", otherName)
|
ctx.ModuleErrorf("depends on non-java module %q", otherName)
|
||||||
}
|
}
|
||||||
case java9LibTag:
|
case java9LibTag:
|
||||||
switch dep := module.(type) {
|
if ctx.OtherModuleHasProvider(module, JavaInfoProvider) {
|
||||||
case Dependency:
|
dep := ctx.OtherModuleProvider(module, JavaInfoProvider).(JavaInfo)
|
||||||
deps.java9Classpath = append(deps.java9Classpath, dep.HeaderJars()...)
|
deps.java9Classpath = append(deps.java9Classpath, dep.HeaderJars...)
|
||||||
default:
|
} else {
|
||||||
ctx.ModuleErrorf("depends on non-java module %q", otherName)
|
ctx.ModuleErrorf("depends on non-java module %q", otherName)
|
||||||
}
|
}
|
||||||
case systemModulesTag:
|
case systemModulesTag:
|
||||||
|
|
|
@ -223,7 +223,7 @@ func stubFlagsRule(ctx android.SingletonContext) {
|
||||||
|
|
||||||
ctx.VisitAllModules(func(module android.Module) {
|
ctx.VisitAllModules(func(module android.Module) {
|
||||||
// Collect dex jar paths for the modules listed above.
|
// Collect dex jar paths for the modules listed above.
|
||||||
if j, ok := module.(Dependency); ok {
|
if j, ok := module.(UsesLibraryDependency); ok {
|
||||||
name := ctx.ModuleName(module)
|
name := ctx.ModuleName(module)
|
||||||
for moduleList, pathList := range moduleListToPathList {
|
for moduleList, pathList := range moduleListToPathList {
|
||||||
if i := android.IndexList(name, *moduleList); i != -1 {
|
if i := android.IndexList(name, *moduleList); i != -1 {
|
||||||
|
|
151
java/java.go
151
java/java.go
|
@ -533,6 +533,53 @@ func (j *Module) OutputFiles(tag string) (android.Paths, error) {
|
||||||
|
|
||||||
var _ android.OutputFileProducer = (*Module)(nil)
|
var _ android.OutputFileProducer = (*Module)(nil)
|
||||||
|
|
||||||
|
// JavaInfo contains information about a java module for use by modules that depend on it.
|
||||||
|
type JavaInfo struct {
|
||||||
|
// HeaderJars is a list of jars that can be passed as the javac classpath in order to link
|
||||||
|
// against this module. If empty, ImplementationJars should be used instead.
|
||||||
|
HeaderJars android.Paths
|
||||||
|
|
||||||
|
// ImplementationAndResourceJars is a list of jars that contain the implementations of classes
|
||||||
|
// in the module as well as any resources included in the module.
|
||||||
|
ImplementationAndResourcesJars android.Paths
|
||||||
|
|
||||||
|
// ImplementationJars is a list of jars that contain the implementations of classes in the
|
||||||
|
//module.
|
||||||
|
ImplementationJars android.Paths
|
||||||
|
|
||||||
|
// ResourceJars is a list of jars that contain the resources included in the module.
|
||||||
|
ResourceJars android.Paths
|
||||||
|
|
||||||
|
// AidlIncludeDirs is a list of directories that should be passed to the aidl tool when
|
||||||
|
// depending on this module.
|
||||||
|
AidlIncludeDirs android.Paths
|
||||||
|
|
||||||
|
// SrcJarArgs is a list of arguments to pass to soong_zip to package the sources of this
|
||||||
|
// module.
|
||||||
|
SrcJarArgs []string
|
||||||
|
|
||||||
|
// SrcJarDeps is a list of paths to depend on when packaging the sources of this module.
|
||||||
|
SrcJarDeps android.Paths
|
||||||
|
|
||||||
|
// ExportedPlugins is a list of paths that should be used as annotation processors for any
|
||||||
|
// module that depends on this module.
|
||||||
|
ExportedPlugins android.Paths
|
||||||
|
|
||||||
|
// ExportedPluginClasses is a list of classes that should be run as annotation processors for
|
||||||
|
// any module that depends on this module.
|
||||||
|
ExportedPluginClasses []string
|
||||||
|
|
||||||
|
// ExportedPluginDisableTurbine is true if this module's annotation processors generate APIs,
|
||||||
|
// requiring disbling turbine for any modules that depend on it.
|
||||||
|
ExportedPluginDisableTurbine bool
|
||||||
|
|
||||||
|
// JacocoReportClassesFile is the path to a jar containing uninstrumented classes that will be
|
||||||
|
// instrumented by jacoco.
|
||||||
|
JacocoReportClassesFile android.Path
|
||||||
|
}
|
||||||
|
|
||||||
|
var JavaInfoProvider = blueprint.NewProvider(JavaInfo{})
|
||||||
|
|
||||||
// Methods that need to be implemented for a module that is added to apex java_libs property.
|
// Methods that need to be implemented for a module that is added to apex java_libs property.
|
||||||
type ApexDependency interface {
|
type ApexDependency interface {
|
||||||
HeaderJars() android.Paths
|
HeaderJars() android.Paths
|
||||||
|
@ -546,18 +593,6 @@ type UsesLibraryDependency interface {
|
||||||
ClassLoaderContexts() dexpreopt.ClassLoaderContextMap
|
ClassLoaderContexts() dexpreopt.ClassLoaderContextMap
|
||||||
}
|
}
|
||||||
|
|
||||||
type Dependency interface {
|
|
||||||
ApexDependency
|
|
||||||
UsesLibraryDependency
|
|
||||||
ImplementationJars() android.Paths
|
|
||||||
ResourceJars() android.Paths
|
|
||||||
AidlIncludeDirs() android.Paths
|
|
||||||
ExportedPlugins() (android.Paths, []string, bool)
|
|
||||||
SrcJarArgs() ([]string, android.Paths)
|
|
||||||
BaseModuleName() string
|
|
||||||
JacocoReportClassesFile() android.Path
|
|
||||||
}
|
|
||||||
|
|
||||||
type xref interface {
|
type xref interface {
|
||||||
XrefJavaFiles() android.Paths
|
XrefJavaFiles() android.Paths
|
||||||
}
|
}
|
||||||
|
@ -1111,44 +1146,42 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
switch dep := module.(type) {
|
if dep, ok := module.(SdkLibraryDependency); ok {
|
||||||
case SdkLibraryDependency:
|
|
||||||
switch tag {
|
switch tag {
|
||||||
case libTag:
|
case libTag:
|
||||||
deps.classpath = append(deps.classpath, dep.SdkHeaderJars(ctx, j.sdkVersion())...)
|
deps.classpath = append(deps.classpath, dep.SdkHeaderJars(ctx, j.sdkVersion())...)
|
||||||
case staticLibTag:
|
case staticLibTag:
|
||||||
ctx.ModuleErrorf("dependency on java_sdk_library %q can only be in libs", otherName)
|
ctx.ModuleErrorf("dependency on java_sdk_library %q can only be in libs", otherName)
|
||||||
}
|
}
|
||||||
case Dependency:
|
} else if ctx.OtherModuleHasProvider(module, JavaInfoProvider) {
|
||||||
|
dep := ctx.OtherModuleProvider(module, JavaInfoProvider).(JavaInfo)
|
||||||
switch tag {
|
switch tag {
|
||||||
case bootClasspathTag:
|
case bootClasspathTag:
|
||||||
deps.bootClasspath = append(deps.bootClasspath, dep.HeaderJars()...)
|
deps.bootClasspath = append(deps.bootClasspath, dep.HeaderJars...)
|
||||||
case libTag, instrumentationForTag:
|
case libTag, instrumentationForTag:
|
||||||
deps.classpath = append(deps.classpath, dep.HeaderJars()...)
|
deps.classpath = append(deps.classpath, dep.HeaderJars...)
|
||||||
deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...)
|
deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs...)
|
||||||
pluginJars, pluginClasses, disableTurbine := dep.ExportedPlugins()
|
addPlugins(&deps, dep.ExportedPlugins, dep.ExportedPluginClasses...)
|
||||||
addPlugins(&deps, pluginJars, pluginClasses...)
|
deps.disableTurbine = deps.disableTurbine || dep.ExportedPluginDisableTurbine
|
||||||
deps.disableTurbine = deps.disableTurbine || disableTurbine
|
|
||||||
case java9LibTag:
|
case java9LibTag:
|
||||||
deps.java9Classpath = append(deps.java9Classpath, dep.HeaderJars()...)
|
deps.java9Classpath = append(deps.java9Classpath, dep.HeaderJars...)
|
||||||
case staticLibTag:
|
case staticLibTag:
|
||||||
deps.classpath = append(deps.classpath, dep.HeaderJars()...)
|
deps.classpath = append(deps.classpath, dep.HeaderJars...)
|
||||||
deps.staticJars = append(deps.staticJars, dep.ImplementationJars()...)
|
deps.staticJars = append(deps.staticJars, dep.ImplementationJars...)
|
||||||
deps.staticHeaderJars = append(deps.staticHeaderJars, dep.HeaderJars()...)
|
deps.staticHeaderJars = append(deps.staticHeaderJars, dep.HeaderJars...)
|
||||||
deps.staticResourceJars = append(deps.staticResourceJars, dep.ResourceJars()...)
|
deps.staticResourceJars = append(deps.staticResourceJars, dep.ResourceJars...)
|
||||||
deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...)
|
deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs...)
|
||||||
pluginJars, pluginClasses, disableTurbine := dep.ExportedPlugins()
|
addPlugins(&deps, dep.ExportedPlugins, dep.ExportedPluginClasses...)
|
||||||
addPlugins(&deps, pluginJars, pluginClasses...)
|
|
||||||
// Turbine doesn't run annotation processors, so any module that uses an
|
// Turbine doesn't run annotation processors, so any module that uses an
|
||||||
// annotation processor that generates API is incompatible with the turbine
|
// annotation processor that generates API is incompatible with the turbine
|
||||||
// optimization.
|
// optimization.
|
||||||
deps.disableTurbine = deps.disableTurbine || disableTurbine
|
deps.disableTurbine = deps.disableTurbine || dep.ExportedPluginDisableTurbine
|
||||||
case pluginTag:
|
case pluginTag:
|
||||||
if plugin, ok := dep.(*Plugin); ok {
|
if plugin, ok := module.(*Plugin); ok {
|
||||||
if plugin.pluginProperties.Processor_class != nil {
|
if plugin.pluginProperties.Processor_class != nil {
|
||||||
addPlugins(&deps, plugin.ImplementationAndResourcesJars(), *plugin.pluginProperties.Processor_class)
|
addPlugins(&deps, dep.ImplementationAndResourcesJars, *plugin.pluginProperties.Processor_class)
|
||||||
} else {
|
} else {
|
||||||
addPlugins(&deps, plugin.ImplementationAndResourcesJars())
|
addPlugins(&deps, dep.ImplementationAndResourcesJars)
|
||||||
}
|
}
|
||||||
// Turbine doesn't run annotation processors, so any module that uses an
|
// Turbine doesn't run annotation processors, so any module that uses an
|
||||||
// annotation processor that generates API is incompatible with the turbine
|
// annotation processor that generates API is incompatible with the turbine
|
||||||
|
@ -1158,14 +1191,14 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
|
||||||
ctx.PropertyErrorf("plugins", "%q is not a java_plugin module", otherName)
|
ctx.PropertyErrorf("plugins", "%q is not a java_plugin module", otherName)
|
||||||
}
|
}
|
||||||
case errorpronePluginTag:
|
case errorpronePluginTag:
|
||||||
if plugin, ok := dep.(*Plugin); ok {
|
if _, ok := module.(*Plugin); ok {
|
||||||
deps.errorProneProcessorPath = append(deps.errorProneProcessorPath, plugin.ImplementationAndResourcesJars()...)
|
deps.errorProneProcessorPath = append(deps.errorProneProcessorPath, dep.ImplementationAndResourcesJars...)
|
||||||
} else {
|
} else {
|
||||||
ctx.PropertyErrorf("plugins", "%q is not a java_plugin module", otherName)
|
ctx.PropertyErrorf("plugins", "%q is not a java_plugin module", otherName)
|
||||||
}
|
}
|
||||||
case exportedPluginTag:
|
case exportedPluginTag:
|
||||||
if plugin, ok := dep.(*Plugin); ok {
|
if plugin, ok := module.(*Plugin); ok {
|
||||||
j.exportedPluginJars = append(j.exportedPluginJars, plugin.ImplementationAndResourcesJars()...)
|
j.exportedPluginJars = append(j.exportedPluginJars, dep.ImplementationAndResourcesJars...)
|
||||||
if plugin.pluginProperties.Processor_class != nil {
|
if plugin.pluginProperties.Processor_class != nil {
|
||||||
j.exportedPluginClasses = append(j.exportedPluginClasses, *plugin.pluginProperties.Processor_class)
|
j.exportedPluginClasses = append(j.exportedPluginClasses, *plugin.pluginProperties.Processor_class)
|
||||||
}
|
}
|
||||||
|
@ -1177,12 +1210,11 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
|
||||||
ctx.PropertyErrorf("exported_plugins", "%q is not a java_plugin module", otherName)
|
ctx.PropertyErrorf("exported_plugins", "%q is not a java_plugin module", otherName)
|
||||||
}
|
}
|
||||||
case kotlinStdlibTag:
|
case kotlinStdlibTag:
|
||||||
deps.kotlinStdlib = append(deps.kotlinStdlib, dep.HeaderJars()...)
|
deps.kotlinStdlib = append(deps.kotlinStdlib, dep.HeaderJars...)
|
||||||
case kotlinAnnotationsTag:
|
case kotlinAnnotationsTag:
|
||||||
deps.kotlinAnnotations = dep.HeaderJars()
|
deps.kotlinAnnotations = dep.HeaderJars
|
||||||
}
|
}
|
||||||
|
} else if dep, ok := module.(android.SourceFileProducer); ok {
|
||||||
case android.SourceFileProducer:
|
|
||||||
switch tag {
|
switch tag {
|
||||||
case libTag:
|
case libTag:
|
||||||
checkProducesJars(ctx, dep)
|
checkProducesJars(ctx, dep)
|
||||||
|
@ -1193,7 +1225,7 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
|
||||||
deps.staticJars = append(deps.staticJars, dep.Srcs()...)
|
deps.staticJars = append(deps.staticJars, dep.Srcs()...)
|
||||||
deps.staticHeaderJars = append(deps.staticHeaderJars, dep.Srcs()...)
|
deps.staticHeaderJars = append(deps.staticHeaderJars, dep.Srcs()...)
|
||||||
}
|
}
|
||||||
default:
|
} else {
|
||||||
switch tag {
|
switch tag {
|
||||||
case bootClasspathTag:
|
case bootClasspathTag:
|
||||||
// If a system modules dependency has been added to the bootclasspath
|
// If a system modules dependency has been added to the bootclasspath
|
||||||
|
@ -1866,6 +1898,20 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
|
||||||
|
|
||||||
ctx.CheckbuildFile(outputFile)
|
ctx.CheckbuildFile(outputFile)
|
||||||
|
|
||||||
|
ctx.SetProvider(JavaInfoProvider, JavaInfo{
|
||||||
|
HeaderJars: android.PathsIfNonNil(j.headerJarFile),
|
||||||
|
ImplementationAndResourcesJars: android.PathsIfNonNil(j.implementationAndResourcesJar),
|
||||||
|
ImplementationJars: android.PathsIfNonNil(j.implementationJarFile),
|
||||||
|
ResourceJars: android.PathsIfNonNil(j.resourceJar),
|
||||||
|
AidlIncludeDirs: j.exportAidlIncludeDirs,
|
||||||
|
SrcJarArgs: j.srcJarArgs,
|
||||||
|
SrcJarDeps: j.srcJarDeps,
|
||||||
|
ExportedPlugins: j.exportedPluginJars,
|
||||||
|
ExportedPluginClasses: j.exportedPluginClasses,
|
||||||
|
ExportedPluginDisableTurbine: j.exportedDisableTurbine,
|
||||||
|
JacocoReportClassesFile: j.jacocoReportClassesFile,
|
||||||
|
})
|
||||||
|
|
||||||
// Save the output file with no relative path so that it doesn't end up in a subdirectory when used as a resource
|
// Save the output file with no relative path so that it doesn't end up in a subdirectory when used as a resource
|
||||||
j.outputFile = outputFile.WithoutRel()
|
j.outputFile = outputFile.WithoutRel()
|
||||||
}
|
}
|
||||||
|
@ -1973,8 +2019,6 @@ func (j *Module) instrument(ctx android.ModuleContext, flags javaBuilderFlags,
|
||||||
return instrumentedJar
|
return instrumentedJar
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ Dependency = (*Module)(nil)
|
|
||||||
|
|
||||||
func (j *Module) HeaderJars() android.Paths {
|
func (j *Module) HeaderJars() android.Paths {
|
||||||
if j.headerJarFile == nil {
|
if j.headerJarFile == nil {
|
||||||
return nil
|
return nil
|
||||||
|
@ -2886,15 +2930,15 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
ctx.VisitDirectDeps(func(module android.Module) {
|
ctx.VisitDirectDeps(func(module android.Module) {
|
||||||
tag := ctx.OtherModuleDependencyTag(module)
|
tag := ctx.OtherModuleDependencyTag(module)
|
||||||
|
|
||||||
switch dep := module.(type) {
|
if ctx.OtherModuleHasProvider(module, JavaInfoProvider) {
|
||||||
case Dependency:
|
dep := ctx.OtherModuleProvider(module, JavaInfoProvider).(JavaInfo)
|
||||||
switch tag {
|
switch tag {
|
||||||
case libTag, staticLibTag:
|
case libTag, staticLibTag:
|
||||||
flags.classpath = append(flags.classpath, dep.HeaderJars()...)
|
flags.classpath = append(flags.classpath, dep.HeaderJars...)
|
||||||
case bootClasspathTag:
|
case bootClasspathTag:
|
||||||
flags.bootClasspath = append(flags.bootClasspath, dep.HeaderJars()...)
|
flags.bootClasspath = append(flags.bootClasspath, dep.HeaderJars...)
|
||||||
}
|
}
|
||||||
case SdkLibraryDependency:
|
} else if dep, ok := module.(SdkLibraryDependency); ok {
|
||||||
switch tag {
|
switch tag {
|
||||||
case libTag:
|
case libTag:
|
||||||
flags.classpath = append(flags.classpath, dep.SdkHeaderJars(ctx, j.sdkVersion())...)
|
flags.classpath = append(flags.classpath, dep.SdkHeaderJars(ctx, j.sdkVersion())...)
|
||||||
|
@ -2973,6 +3017,13 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
j.dexJarFile = dexOutputFile
|
j.dexJarFile = dexOutputFile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx.SetProvider(JavaInfoProvider, JavaInfo{
|
||||||
|
HeaderJars: android.PathsIfNonNil(j.combinedClasspathFile),
|
||||||
|
ImplementationAndResourcesJars: android.PathsIfNonNil(j.combinedClasspathFile),
|
||||||
|
ImplementationJars: android.PathsIfNonNil(j.combinedClasspathFile),
|
||||||
|
AidlIncludeDirs: j.exportAidlIncludeDirs,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *Import) OutputFiles(tag string) (android.Paths, error) {
|
func (j *Import) OutputFiles(tag string) (android.Paths, error) {
|
||||||
|
@ -2986,8 +3037,6 @@ func (j *Import) OutputFiles(tag string) (android.Paths, error) {
|
||||||
|
|
||||||
var _ android.OutputFileProducer = (*Import)(nil)
|
var _ android.OutputFileProducer = (*Import)(nil)
|
||||||
|
|
||||||
var _ Dependency = (*Import)(nil)
|
|
||||||
|
|
||||||
func (j *Import) HeaderJars() android.Paths {
|
func (j *Import) HeaderJars() android.Paths {
|
||||||
if j.combinedClasspathFile == nil {
|
if j.combinedClasspathFile == nil {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -87,8 +87,9 @@ func (j *jdepsGeneratorSingleton) GenerateBuildActions(ctx android.SingletonCont
|
||||||
dpInfo.Classes = append(dpInfo.Classes, data.Class)
|
dpInfo.Classes = append(dpInfo.Classes, data.Class)
|
||||||
}
|
}
|
||||||
|
|
||||||
if dep, ok := module.(Dependency); ok {
|
if ctx.ModuleHasProvider(module, JavaInfoProvider) {
|
||||||
dpInfo.Installed_paths = append(dpInfo.Installed_paths, dep.ImplementationJars().Strings()...)
|
dep := ctx.ModuleProvider(module, JavaInfoProvider).(JavaInfo)
|
||||||
|
dpInfo.Installed_paths = append(dpInfo.Installed_paths, dep.ImplementationJars.Strings()...)
|
||||||
}
|
}
|
||||||
dpInfo.Classes = android.FirstUniqueStrings(dpInfo.Classes)
|
dpInfo.Classes = android.FirstUniqueStrings(dpInfo.Classes)
|
||||||
dpInfo.Installed_paths = android.FirstUniqueStrings(dpInfo.Installed_paths)
|
dpInfo.Installed_paths = android.FirstUniqueStrings(dpInfo.Installed_paths)
|
||||||
|
|
|
@ -276,8 +276,9 @@ func (l *linter) lint(ctx android.ModuleContext) {
|
||||||
|
|
||||||
extraLintCheckModules := ctx.GetDirectDepsWithTag(extraLintCheckTag)
|
extraLintCheckModules := ctx.GetDirectDepsWithTag(extraLintCheckTag)
|
||||||
for _, extraLintCheckModule := range extraLintCheckModules {
|
for _, extraLintCheckModule := range extraLintCheckModules {
|
||||||
if dep, ok := extraLintCheckModule.(Dependency); ok {
|
if ctx.OtherModuleHasProvider(extraLintCheckModule, JavaInfoProvider) {
|
||||||
l.extraLintCheckJars = append(l.extraLintCheckJars, dep.ImplementationAndResourcesJars()...)
|
dep := ctx.OtherModuleProvider(extraLintCheckModule, JavaInfoProvider).(JavaInfo)
|
||||||
|
l.extraLintCheckJars = append(l.extraLintCheckJars, dep.ImplementationAndResourcesJars...)
|
||||||
} else {
|
} else {
|
||||||
ctx.PropertyErrorf("lint.extra_check_modules",
|
ctx.PropertyErrorf("lint.extra_check_modules",
|
||||||
"%s is not a java module", ctx.OtherModuleName(extraLintCheckModule))
|
"%s is not a java module", ctx.OtherModuleName(extraLintCheckModule))
|
||||||
|
|
|
@ -148,10 +148,10 @@ func (r *robolectricTest) GenerateAndroidBuildActions(ctx android.ModuleContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, dep := range ctx.GetDirectDepsWithTag(libTag) {
|
for _, dep := range ctx.GetDirectDepsWithTag(libTag) {
|
||||||
m := dep.(Dependency)
|
m := ctx.OtherModuleProvider(dep, JavaInfoProvider).(JavaInfo)
|
||||||
r.libs = append(r.libs, m.BaseModuleName())
|
r.libs = append(r.libs, ctx.OtherModuleName(dep))
|
||||||
if !android.InList(m.BaseModuleName(), config.FrameworkLibraries) {
|
if !android.InList(ctx.OtherModuleName(dep), config.FrameworkLibraries) {
|
||||||
combinedJarJars = append(combinedJarJars, m.ImplementationAndResourcesJars()...)
|
combinedJarJars = append(combinedJarJars, m.ImplementationAndResourcesJars...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,10 +245,10 @@ func (r *robolectricTest) generateRoboSrcJar(ctx android.ModuleContext, outputFi
|
||||||
srcJarDeps := append(android.Paths(nil), instrumentedApp.srcJarDeps...)
|
srcJarDeps := append(android.Paths(nil), instrumentedApp.srcJarDeps...)
|
||||||
|
|
||||||
for _, m := range ctx.GetDirectDepsWithTag(roboCoverageLibsTag) {
|
for _, m := range ctx.GetDirectDepsWithTag(roboCoverageLibsTag) {
|
||||||
if dep, ok := m.(Dependency); ok {
|
if ctx.OtherModuleHasProvider(m, JavaInfoProvider) {
|
||||||
depSrcJarArgs, depSrcJarDeps := dep.SrcJarArgs()
|
dep := ctx.OtherModuleProvider(m, JavaInfoProvider).(JavaInfo)
|
||||||
srcJarArgs = append(srcJarArgs, depSrcJarArgs...)
|
srcJarArgs = append(srcJarArgs, dep.SrcJarArgs...)
|
||||||
srcJarDeps = append(srcJarDeps, depSrcJarDeps...)
|
srcJarDeps = append(srcJarDeps, dep.SrcJarDeps...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -566,10 +566,11 @@ func createFrameworkAidl(stubsModules []string, path android.OutputPath, ctx and
|
||||||
|
|
||||||
ctx.VisitAllModules(func(module android.Module) {
|
ctx.VisitAllModules(func(module android.Module) {
|
||||||
// Collect dex jar paths for the modules listed above.
|
// Collect dex jar paths for the modules listed above.
|
||||||
if j, ok := module.(Dependency); ok {
|
if ctx.ModuleHasProvider(module, JavaInfoProvider) {
|
||||||
|
j := ctx.ModuleProvider(module, JavaInfoProvider).(JavaInfo)
|
||||||
name := ctx.ModuleName(module)
|
name := ctx.ModuleName(module)
|
||||||
if i := android.IndexList(name, stubsModules); i != -1 {
|
if i := android.IndexList(name, stubsModules); i != -1 {
|
||||||
stubsJars[i] = j.HeaderJars()
|
stubsJars[i] = j.HeaderJars
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -60,12 +60,12 @@ type scopeDependencyTag struct {
|
||||||
apiScope *apiScope
|
apiScope *apiScope
|
||||||
|
|
||||||
// Function for extracting appropriate path information from the dependency.
|
// Function for extracting appropriate path information from the dependency.
|
||||||
depInfoExtractor func(paths *scopePaths, dep android.Module) error
|
depInfoExtractor func(paths *scopePaths, ctx android.ModuleContext, dep android.Module) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract tag specific information from the dependency.
|
// Extract tag specific information from the dependency.
|
||||||
func (tag scopeDependencyTag) extractDepInfo(ctx android.ModuleContext, dep android.Module, paths *scopePaths) {
|
func (tag scopeDependencyTag) extractDepInfo(ctx android.ModuleContext, dep android.Module, paths *scopePaths) {
|
||||||
err := tag.depInfoExtractor(paths, dep)
|
err := tag.depInfoExtractor(paths, ctx, dep)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.ModuleErrorf("has an invalid {scopeDependencyTag: %s} dependency on module %s: %s", tag.name, ctx.OtherModuleName(dep), err.Error())
|
ctx.ModuleErrorf("has an invalid {scopeDependencyTag: %s} dependency on module %s: %s", tag.name, ctx.OtherModuleName(dep), err.Error())
|
||||||
}
|
}
|
||||||
|
@ -539,13 +539,14 @@ type scopePaths struct {
|
||||||
stubsSrcJar android.OptionalPath
|
stubsSrcJar android.OptionalPath
|
||||||
}
|
}
|
||||||
|
|
||||||
func (paths *scopePaths) extractStubsLibraryInfoFromDependency(dep android.Module) error {
|
func (paths *scopePaths) extractStubsLibraryInfoFromDependency(ctx android.ModuleContext, dep android.Module) error {
|
||||||
if lib, ok := dep.(Dependency); ok {
|
if ctx.OtherModuleHasProvider(dep, JavaInfoProvider) {
|
||||||
paths.stubsHeaderPath = lib.HeaderJars()
|
lib := ctx.OtherModuleProvider(dep, JavaInfoProvider).(JavaInfo)
|
||||||
paths.stubsImplPath = lib.ImplementationJars()
|
paths.stubsHeaderPath = lib.HeaderJars
|
||||||
|
paths.stubsImplPath = lib.ImplementationJars
|
||||||
return nil
|
return nil
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("expected module that implements Dependency, e.g. java_library")
|
return fmt.Errorf("expected module that has JavaInfoProvider, e.g. java_library")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -572,7 +573,7 @@ func (paths *scopePaths) extractApiInfoFromApiStubsProvider(provider ApiStubsPro
|
||||||
paths.removedApiFilePath = android.OptionalPathForPath(provider.RemovedApiFilePath())
|
paths.removedApiFilePath = android.OptionalPathForPath(provider.RemovedApiFilePath())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (paths *scopePaths) extractApiInfoFromDep(dep android.Module) error {
|
func (paths *scopePaths) extractApiInfoFromDep(ctx android.ModuleContext, dep android.Module) error {
|
||||||
return paths.treatDepAsApiStubsProvider(dep, func(provider ApiStubsProvider) {
|
return paths.treatDepAsApiStubsProvider(dep, func(provider ApiStubsProvider) {
|
||||||
paths.extractApiInfoFromApiStubsProvider(provider)
|
paths.extractApiInfoFromApiStubsProvider(provider)
|
||||||
})
|
})
|
||||||
|
@ -582,13 +583,13 @@ func (paths *scopePaths) extractStubsSourceInfoFromApiStubsProviders(provider Ap
|
||||||
paths.stubsSrcJar = android.OptionalPathForPath(provider.StubsSrcJar())
|
paths.stubsSrcJar = android.OptionalPathForPath(provider.StubsSrcJar())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (paths *scopePaths) extractStubsSourceInfoFromDep(dep android.Module) error {
|
func (paths *scopePaths) extractStubsSourceInfoFromDep(ctx android.ModuleContext, dep android.Module) error {
|
||||||
return paths.treatDepAsApiStubsSrcProvider(dep, func(provider ApiStubsSrcProvider) {
|
return paths.treatDepAsApiStubsSrcProvider(dep, func(provider ApiStubsSrcProvider) {
|
||||||
paths.extractStubsSourceInfoFromApiStubsProviders(provider)
|
paths.extractStubsSourceInfoFromApiStubsProviders(provider)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (paths *scopePaths) extractStubsSourceAndApiInfoFromApiStubsProvider(dep android.Module) error {
|
func (paths *scopePaths) extractStubsSourceAndApiInfoFromApiStubsProvider(ctx android.ModuleContext, dep android.Module) error {
|
||||||
return paths.treatDepAsApiStubsProvider(dep, func(provider ApiStubsProvider) {
|
return paths.treatDepAsApiStubsProvider(dep, func(provider ApiStubsProvider) {
|
||||||
paths.extractApiInfoFromApiStubsProvider(provider)
|
paths.extractApiInfoFromApiStubsProvider(provider)
|
||||||
paths.extractStubsSourceInfoFromApiStubsProviders(provider)
|
paths.extractStubsSourceInfoFromApiStubsProviders(provider)
|
||||||
|
@ -951,7 +952,6 @@ type SdkLibrary struct {
|
||||||
commonToSdkLibraryAndImport
|
commonToSdkLibraryAndImport
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ Dependency = (*SdkLibrary)(nil)
|
|
||||||
var _ SdkLibraryDependency = (*SdkLibrary)(nil)
|
var _ SdkLibraryDependency = (*SdkLibrary)(nil)
|
||||||
|
|
||||||
func (module *SdkLibrary) generateTestAndSystemScopesByDefault() bool {
|
func (module *SdkLibrary) generateTestAndSystemScopesByDefault() bool {
|
||||||
|
|
|
@ -160,8 +160,8 @@ func (system *SystemModules) GenerateAndroidBuildActions(ctx android.ModuleConte
|
||||||
var jars android.Paths
|
var jars android.Paths
|
||||||
|
|
||||||
ctx.VisitDirectDepsWithTag(systemModulesLibsTag, func(module android.Module) {
|
ctx.VisitDirectDepsWithTag(systemModulesLibsTag, func(module android.Module) {
|
||||||
dep, _ := module.(Dependency)
|
dep, _ := ctx.OtherModuleProvider(module, JavaInfoProvider).(JavaInfo)
|
||||||
jars = append(jars, dep.HeaderJars()...)
|
jars = append(jars, dep.HeaderJars...)
|
||||||
})
|
})
|
||||||
|
|
||||||
system.headerJars = jars
|
system.headerJars = jars
|
||||||
|
|
Loading…
Reference in New Issue