Merge "Migrate api lint report dist rules to Soong" into main
diff --git a/android/androidmk.go b/android/androidmk.go
index cf1589d..f2e1c10 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -892,13 +892,7 @@
 				}
 			}
 		} else {
-			mctx := &makeVarsContext{
-				SingletonContext: ctx.(SingletonContext),
-				config:           ctx.Config(),
-				pctx:             pctx,
-			}
-			switch x := mod.(type) {
-			case AndroidMkDataProvider:
+			if x, ok := mod.(AndroidMkDataProvider); ok {
 				data := x.AndroidMk()
 
 				if data.Include == "" {
@@ -915,7 +909,8 @@
 				if contribution := data.Entries.getDistContributions(mod); contribution != nil {
 					allDistContributions = append(allDistContributions, *contribution)
 				}
-			case AndroidMkEntriesProvider:
+			}
+			if x, ok := mod.(AndroidMkEntriesProvider); ok {
 				entriesList := x.AndroidMkEntries()
 				for _, entries := range entriesList {
 					entries.fillInEntries(ctx, mod)
@@ -929,7 +924,13 @@
 						allDistContributions = append(allDistContributions, *contribution)
 					}
 				}
-			case ModuleMakeVarsProvider:
+			}
+			if x, ok := mod.(ModuleMakeVarsProvider); ok {
+				mctx := &makeVarsContext{
+					SingletonContext: ctx.(SingletonContext),
+					config:           ctx.Config(),
+					pctx:             pctx,
+				}
 				if !x.Enabled(ctx) {
 					continue
 				}
@@ -937,15 +938,17 @@
 				if contribution := getMakeVarsDistContributions(mctx); contribution != nil {
 					allDistContributions = append(allDistContributions, *contribution)
 				}
-
-			case SingletonMakeVarsProvider:
+			}
+			if x, ok := mod.(SingletonMakeVarsProvider); ok {
+				mctx := &makeVarsContext{
+					SingletonContext: ctx.(SingletonContext),
+					config:           ctx.Config(),
+					pctx:             pctx,
+				}
 				x.MakeVars(mctx)
 				if contribution := getMakeVarsDistContributions(mctx); contribution != nil {
 					allDistContributions = append(allDistContributions, *contribution)
 				}
-
-			default:
-				// Not exported to make so no make variables to set.
 			}
 		}
 	}
diff --git a/java/androidmk.go b/java/androidmk.go
index f069e75..4305360 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -552,8 +552,6 @@
 			func(w io.Writer, name, prefix, moduleDir string) {
 				if dstubs.apiLintTimestamp != nil {
 					if dstubs.apiLintReport != nil {
-						fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", dstubs.Name()+"-api-lint",
-							dstubs.apiLintReport.String(), "apilint/"+dstubs.Name()+"-lint-report.txt")
 						fmt.Fprintf(w, "$(call declare-0p-target,%s)\n", dstubs.apiLintReport.String())
 					}
 				}
diff --git a/java/droidstubs.go b/java/droidstubs.go
index 22f4d98..c8f798a 100644
--- a/java/droidstubs.go
+++ b/java/droidstubs.go
@@ -1524,6 +1524,18 @@
 	}
 )
 
+func (d *Droidstubs) MakeVars(ctx android.MakeVarsModuleContext) {
+	if d.apiLintTimestamp != nil {
+		if d.apiLintReport != nil {
+			ctx.DistForGoalsWithFilename(
+				[]string{fmt.Sprintf("%s-api-lint", d.Name()), "droidcore"},
+				d.apiLintReport,
+				fmt.Sprintf("apilint/%s-lint-report.txt", d.Name()),
+			)
+		}
+	}
+}
+
 func StubsDefaultsFactory() android.Module {
 	module := &DocDefaults{}