|
@@ -1633,6 +1633,10 @@ type JavaApiLibraryProperties struct {
|
|
|
// List of shared java libs that this module has dependencies to and
|
|
|
// should be passed as classpath in javac invocation
|
|
|
Libs []string
|
|
|
+
|
|
|
+ // List of java libs that this module has static dependencies to and will be
|
|
|
+ // passed in metalava invocation
|
|
|
+ Static_libs []string
|
|
|
}
|
|
|
|
|
|
func ApiLibraryFactory() android.Module {
|
|
@@ -1705,6 +1709,7 @@ func (al *ApiLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|
|
ctx.AddDependency(ctx.Module(), javaApiContributionTag, apiContributionName)
|
|
|
}
|
|
|
ctx.AddVariationDependencies(nil, libTag, al.properties.Libs...)
|
|
|
+ ctx.AddVariationDependencies(nil, staticLibTag, al.properties.Static_libs...)
|
|
|
}
|
|
|
|
|
|
func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|
@@ -1724,6 +1729,7 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|
|
|
|
|
var srcFiles android.Paths
|
|
|
var classPaths android.Paths
|
|
|
+ var staticLibs android.Paths
|
|
|
ctx.VisitDirectDeps(func(dep android.Module) {
|
|
|
tag := ctx.OtherModuleDependencyTag(dep)
|
|
|
switch tag {
|
|
@@ -1737,6 +1743,9 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|
|
case libTag:
|
|
|
provider := ctx.OtherModuleProvider(dep, JavaInfoProvider).(JavaInfo)
|
|
|
classPaths = append(classPaths, provider.HeaderJars...)
|
|
|
+ case staticLibTag:
|
|
|
+ provider := ctx.OtherModuleProvider(dep, JavaInfoProvider).(JavaInfo)
|
|
|
+ staticLibs = append(staticLibs, provider.HeaderJars...)
|
|
|
}
|
|
|
})
|
|
|
|
|
@@ -1761,7 +1770,7 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|
|
FlagWithArg("-D ", stubsDir.String())
|
|
|
|
|
|
rule.Build("metalava", "metalava merged")
|
|
|
-
|
|
|
+ compiledStubs := android.PathForModuleOut(ctx, ctx.ModuleName(), "stubs.jar")
|
|
|
al.stubsJar = android.PathForModuleOut(ctx, ctx.ModuleName(), "android.jar")
|
|
|
|
|
|
var flags javaBuilderFlags
|
|
@@ -1769,9 +1778,17 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|
|
flags.javacFlags = strings.Join(al.properties.Javacflags, " ")
|
|
|
flags.classpath = classpath(classPaths)
|
|
|
|
|
|
- TransformJavaToClasses(ctx, al.stubsJar, 0, android.Paths{},
|
|
|
+ TransformJavaToClasses(ctx, compiledStubs, 0, android.Paths{},
|
|
|
android.Paths{al.stubsSrcJar}, flags, android.Paths{})
|
|
|
|
|
|
+ builder := android.NewRuleBuilder(pctx, ctx)
|
|
|
+ builder.Command().
|
|
|
+ BuiltTool("merge_zips").
|
|
|
+ Output(al.stubsJar).
|
|
|
+ Inputs(android.Paths{compiledStubs}).
|
|
|
+ Inputs(staticLibs)
|
|
|
+ builder.Build("merge_zips", "merge jar files")
|
|
|
+
|
|
|
ctx.Phony(ctx.ModuleName(), al.stubsJar)
|
|
|
|
|
|
ctx.SetProvider(JavaInfoProvider, JavaInfo{
|