Loading java/droiddoc.go +30 −24 Original line number Diff line number Diff line Loading @@ -294,6 +294,9 @@ type DroidstubsProperties struct { // the dirs which Metalava extracts API levels annotations from. Api_levels_annotations_dirs []string // the filename which Metalava extracts API levels annotations from. Defaults to android.jar. Api_levels_jar_filename *string // if set to true, collect the values used by the Dev tools and // write them in files packaged with the SDK. Defaults to false. Write_sdk_values *bool Loading Loading @@ -1407,7 +1410,10 @@ func (d *Droidstubs) inclusionAnnotationsFlags(ctx android.ModuleContext, cmd *a } func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand) { if Bool(d.properties.Api_levels_annotations_enabled) { if !Bool(d.properties.Api_levels_annotations_enabled) { return } d.apiVersionsXml = android.PathForModuleOut(ctx, "api-versions.xml") if len(d.properties.Api_levels_annotations_dirs) == 0 { Loading @@ -1420,21 +1426,21 @@ func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *a cmd.FlagWithArg("--current-version ", ctx.Config().PlatformSdkVersion()) cmd.FlagWithArg("--current-codename ", ctx.Config().PlatformSdkCodename()) filename := proptools.StringDefault(d.properties.Api_levels_jar_filename, "android.jar") ctx.VisitDirectDepsWithTag(metalavaAPILevelsAnnotationsDirTag, func(m android.Module) { if t, ok := m.(*ExportedDroiddocDir); ok { for _, dep := range t.deps { if strings.HasSuffix(dep.String(), "android.jar") { if strings.HasSuffix(dep.String(), filename) { cmd.Implicit(dep) } } cmd.FlagWithArg("--android-jar-pattern ", t.dir.String()+"/%/public/android.jar") cmd.FlagWithArg("--android-jar-pattern ", t.dir.String()+"/%/public/"+filename) } else { ctx.PropertyErrorf("api_levels_annotations_dirs", "module %q is not a metalava api-levels-annotations dir", ctx.OtherModuleName(m)) } }) } } func (d *Droidstubs) apiToXmlFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand) { Loading java/java_test.go +56 −0 Original line number Diff line number Diff line Loading @@ -1170,6 +1170,62 @@ func TestDroiddocArgsAndFlagsCausesError(t *testing.T) { `) } func TestDroidstubs(t *testing.T) { ctx, _ := testJavaWithFS(t, ` droiddoc_exported_dir { name: "droiddoc-templates-sdk", path: ".", } droidstubs { name: "bar-stubs", srcs: [ "bar-doc/a.java", ], api_levels_annotations_dirs: [ "droiddoc-templates-sdk", ], api_levels_annotations_enabled: true, } droidstubs { name: "bar-stubs-other", srcs: [ "bar-doc/a.java", ], api_levels_annotations_dirs: [ "droiddoc-templates-sdk", ], api_levels_annotations_enabled: true, api_levels_jar_filename: "android.other.jar", } `, map[string][]byte{ "bar-doc/a.java": nil, }) testcases := []struct { moduleName string expectedJarFilename string }{ { moduleName: "bar-stubs", expectedJarFilename: "android.jar", }, { moduleName: "bar-stubs-other", expectedJarFilename: "android.other.jar", }, } for _, c := range testcases { m := ctx.ModuleForTests(c.moduleName, "android_common") metalava := m.Rule("metalava") expected := "--android-jar-pattern ./%/public/" + c.expectedJarFilename if actual := metalava.RuleParams.Command; !strings.Contains(actual, expected) { t.Errorf("For %q, expected metalava argument %q, but was not found %q", c.moduleName, expected, actual) } } } func TestDroidstubsWithSystemModules(t *testing.T) { ctx, _ := testJava(t, ` droidstubs { Loading Loading
java/droiddoc.go +30 −24 Original line number Diff line number Diff line Loading @@ -294,6 +294,9 @@ type DroidstubsProperties struct { // the dirs which Metalava extracts API levels annotations from. Api_levels_annotations_dirs []string // the filename which Metalava extracts API levels annotations from. Defaults to android.jar. Api_levels_jar_filename *string // if set to true, collect the values used by the Dev tools and // write them in files packaged with the SDK. Defaults to false. Write_sdk_values *bool Loading Loading @@ -1407,7 +1410,10 @@ func (d *Droidstubs) inclusionAnnotationsFlags(ctx android.ModuleContext, cmd *a } func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand) { if Bool(d.properties.Api_levels_annotations_enabled) { if !Bool(d.properties.Api_levels_annotations_enabled) { return } d.apiVersionsXml = android.PathForModuleOut(ctx, "api-versions.xml") if len(d.properties.Api_levels_annotations_dirs) == 0 { Loading @@ -1420,21 +1426,21 @@ func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *a cmd.FlagWithArg("--current-version ", ctx.Config().PlatformSdkVersion()) cmd.FlagWithArg("--current-codename ", ctx.Config().PlatformSdkCodename()) filename := proptools.StringDefault(d.properties.Api_levels_jar_filename, "android.jar") ctx.VisitDirectDepsWithTag(metalavaAPILevelsAnnotationsDirTag, func(m android.Module) { if t, ok := m.(*ExportedDroiddocDir); ok { for _, dep := range t.deps { if strings.HasSuffix(dep.String(), "android.jar") { if strings.HasSuffix(dep.String(), filename) { cmd.Implicit(dep) } } cmd.FlagWithArg("--android-jar-pattern ", t.dir.String()+"/%/public/android.jar") cmd.FlagWithArg("--android-jar-pattern ", t.dir.String()+"/%/public/"+filename) } else { ctx.PropertyErrorf("api_levels_annotations_dirs", "module %q is not a metalava api-levels-annotations dir", ctx.OtherModuleName(m)) } }) } } func (d *Droidstubs) apiToXmlFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand) { Loading
java/java_test.go +56 −0 Original line number Diff line number Diff line Loading @@ -1170,6 +1170,62 @@ func TestDroiddocArgsAndFlagsCausesError(t *testing.T) { `) } func TestDroidstubs(t *testing.T) { ctx, _ := testJavaWithFS(t, ` droiddoc_exported_dir { name: "droiddoc-templates-sdk", path: ".", } droidstubs { name: "bar-stubs", srcs: [ "bar-doc/a.java", ], api_levels_annotations_dirs: [ "droiddoc-templates-sdk", ], api_levels_annotations_enabled: true, } droidstubs { name: "bar-stubs-other", srcs: [ "bar-doc/a.java", ], api_levels_annotations_dirs: [ "droiddoc-templates-sdk", ], api_levels_annotations_enabled: true, api_levels_jar_filename: "android.other.jar", } `, map[string][]byte{ "bar-doc/a.java": nil, }) testcases := []struct { moduleName string expectedJarFilename string }{ { moduleName: "bar-stubs", expectedJarFilename: "android.jar", }, { moduleName: "bar-stubs-other", expectedJarFilename: "android.other.jar", }, } for _, c := range testcases { m := ctx.ModuleForTests(c.moduleName, "android_common") metalava := m.Rule("metalava") expected := "--android-jar-pattern ./%/public/" + c.expectedJarFilename if actual := metalava.RuleParams.Command; !strings.Contains(actual, expected) { t.Errorf("For %q, expected metalava argument %q, but was not found %q", c.moduleName, expected, actual) } } } func TestDroidstubsWithSystemModules(t *testing.T) { ctx, _ := testJava(t, ` droidstubs { Loading