Merge "Log whether the build is using soong-only mode to the metrics." into main
diff --git a/cmd/kotlinc_incremental/Android.bp b/cmd/kotlinc_incremental/Android.bp
new file mode 100644
index 0000000..7816553
--- /dev/null
+++ b/cmd/kotlinc_incremental/Android.bp
@@ -0,0 +1,65 @@
+//
+// Copyright (C) 2025 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+package {
+    default_team: "trendy_team_system_ui_please_use_a_more_specific_subteam_if_possible_",
+    default_applicable_licenses: [
+        "Android-Apache-2.0",
+        "Kotlin_Incremental_license",
+    ],
+}
+
+license {
+    name: "Kotlin_Incremental_license",
+    visibility: [":__subpackages__"],
+    license_kinds: ["legacy_proprietary"],
+}
+
+java_library_host {
+    name: "kotlin-incremental-client-lib",
+    srcs: [
+        "src/com/**/*.kt",
+    ],
+    static_libs: [
+        "kotlin-compiler-embeddable",
+        "kotlin-compiler-runner",
+        "kotlin-daemon-client",
+    ],
+
+    plugins: [],
+
+    kotlincflags: [
+        "-Werror",
+    ],
+}
+
+java_binary_host {
+    name: "kotlin-incremental-client",
+    manifest: "kotlin-incremental-client.mf",
+    static_libs: ["kotlin-incremental-client-lib"],
+}
+
+java_test_host {
+    name: "kotlin-incremental-client-tests",
+    srcs: [
+        "tests/src/com/**/*.kt",
+    ],
+    static_libs: [
+        "kotlin-incremental-client-lib",
+        "junit",
+        "truth",
+    ],
+}
diff --git a/cmd/kotlinc_incremental/kotlin-incremental-client.mf b/cmd/kotlinc_incremental/kotlin-incremental-client.mf
new file mode 100644
index 0000000..b84c86a
--- /dev/null
+++ b/cmd/kotlinc_incremental/kotlin-incremental-client.mf
@@ -0,0 +1 @@
+Main-Class: com.android.kotlin.compiler.client.MainKt
diff --git a/cmd/kotlinc_incremental/src/com/android/kotlin/compiler/client/Main.kt b/cmd/kotlinc_incremental/src/com/android/kotlin/compiler/client/Main.kt
new file mode 100644
index 0000000..4938641
--- /dev/null
+++ b/cmd/kotlinc_incremental/src/com/android/kotlin/compiler/client/Main.kt
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2025 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.kotlin.compiler.client
+
+fun main(args: Array<String>) {
+  println("compiling")
+}
diff --git a/cmd/kotlinc_incremental/tests/src/com/android/kotlin/compiler/client/MainTest.kt b/cmd/kotlinc_incremental/tests/src/com/android/kotlin/compiler/client/MainTest.kt
new file mode 100644
index 0000000..3354aa4
--- /dev/null
+++ b/cmd/kotlinc_incremental/tests/src/com/android/kotlin/compiler/client/MainTest.kt
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2025 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.kotlin.compiler.client
+
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+
+class MainTest {
+    @Test
+    fun testMain() {
+        assertThat(true).isTrue()
+    }
+}
\ No newline at end of file
diff --git a/filesystem/android_device.go b/filesystem/android_device.go
index eb2e036..3e2f61f 100644
--- a/filesystem/android_device.go
+++ b/filesystem/android_device.go
@@ -15,6 +15,7 @@
 package filesystem
 
 import (
+	"fmt"
 	"strings"
 	"sync/atomic"
 
@@ -150,7 +151,7 @@
 		}
 	}
 
-	a.buildTargetFilesZip(ctx)
+	//a.buildTargetFilesZip(ctx) TODO(b/393203512): re-enable target_files.zip
 	var deps []android.Path
 	if proptools.String(a.partitionProps.Super_partition_name) != "" {
 		superImage := ctx.GetDirectDepProxyWithTag(*a.partitionProps.Super_partition_name, superPartitionDepTag)
@@ -221,6 +222,8 @@
 
 	// Checkbuilding it causes soong to make a phony, so you can say `m <module name>`
 	ctx.CheckbuildFile(allImagesStamp)
+
+	a.setVbmetaPhonyTargets(ctx)
 }
 
 // Helper structs for target_files.zip creation
@@ -406,3 +409,20 @@
 	}
 	return fsInfo
 }
+
+func (a *androidDevice) setVbmetaPhonyTargets(ctx android.ModuleContext) {
+	if !proptools.Bool(a.deviceProps.Main_device) {
+		return
+	}
+
+	if !ctx.Config().KatiEnabled() {
+		for _, vbmetaPartitionName := range a.partitionProps.Vbmeta_partitions {
+			img := ctx.GetDirectDepProxyWithTag(vbmetaPartitionName, filesystemDepTag)
+			if provider, ok := android.OtherModuleProvider(ctx, img, vbmetaPartitionProvider); ok {
+				// make generates `vbmetasystemimage` phony target instead of `vbmeta_systemimage` phony target.
+				partitionName := strings.ReplaceAll(provider.Name, "_", "")
+				ctx.Phony(fmt.Sprintf("%simage", partitionName), provider.Output)
+			}
+		}
+	}
+}
diff --git a/filesystem/android_device_product_out.go b/filesystem/android_device_product_out.go
index 916c45a..a6177e3 100644
--- a/filesystem/android_device_product_out.go
+++ b/filesystem/android_device_product_out.go
@@ -16,6 +16,7 @@
 
 import (
 	"android/soong/android"
+	"fmt"
 
 	"github.com/google/blueprint"
 	"github.com/google/blueprint/proptools"
@@ -72,10 +73,13 @@
 			},
 		})
 
-		// Make it so doing `m <moduleName>` or `m <partitionType>` will copy the files to
+		// Make it so doing `m <moduleName>` or `m <partitionType>image` will copy the files to
 		// PRODUCT_OUT
 		ctx.Phony(info.ModuleName, dirStamp, imgInstallPath)
-		ctx.Phony(partition, dirStamp, imgInstallPath)
+		if partition == "system_ext" {
+			partition = "systemext"
+		}
+		ctx.Phony(fmt.Sprintf("%simage", partition), dirStamp, imgInstallPath)
 
 		deps = append(deps, imgInstallPath, dirStamp)
 	}
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index 357ec32..815113e 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -738,22 +738,23 @@
 		Output(output).
 		Text(rootDir.String()) // directory where to find fs_config_files|dirs
 
+	// TODO (b/393203512): Re-enable hermetic img file creation for target_files.zip
 	// Add an additional cmd to create a hermetic img file. This will contain pinned timestamps e.g.
-	propFilePinnedTimestamp := android.PathForModuleOut(ctx, "for_target_files", "prop")
-	builder.Command().Textf("cat").Input(propFile).Flag(">").Output(propFilePinnedTimestamp).
-		Textf(" && echo use_fixed_timestamp=true >> %s", propFilePinnedTimestamp).
-		Textf(" && echo block_list=%s >> %s", f.getMapFile(ctx).String(), propFilePinnedTimestamp) // mapfile will be an implicit output
+	//propFilePinnedTimestamp := android.PathForModuleOut(ctx, "for_target_files", "prop")
+	//builder.Command().Textf("cat").Input(propFile).Flag(">").Output(propFilePinnedTimestamp).
+	//	Textf(" && echo use_fixed_timestamp=true >> %s", propFilePinnedTimestamp).
+	//	Textf(" && echo block_list=%s >> %s", f.getMapFile(ctx).String(), propFilePinnedTimestamp) // mapfile will be an implicit output
 
-	outputHermetic := android.PathForModuleOut(ctx, "for_target_files", f.installFileName())
-	builder.Command().
-		Textf("PATH=%s:$PATH", strings.Join(pathToolDirs, ":")).
-		BuiltTool("build_image").
-		Text(rootDir.String()). // input directory
-		Flag(propFilePinnedTimestamp.String()).
-		Implicits(toolDeps).
-		Implicit(fec).
-		Output(outputHermetic).
-		Text(rootDir.String()) // directory where to find fs_config_files|dirs
+	//outputHermetic := android.PathForModuleOut(ctx, "for_target_files", f.installFileName())
+	//builder.Command().
+	//	Textf("PATH=%s:$PATH", strings.Join(pathToolDirs, ":")).
+	//	BuiltTool("build_image").
+	//	Text(rootDir.String()). // input directory
+	//	Flag(propFilePinnedTimestamp.String()).
+	//	Implicits(toolDeps).
+	//	Implicit(fec).
+	//	Output(outputHermetic).
+	//	Text(rootDir.String()) // directory where to find fs_config_files|dirs
 
 	if f.properties.Partition_size != nil {
 		assertMaxImageSize(builder, output, *f.properties.Partition_size, false)
@@ -762,7 +763,7 @@
 	// rootDir is not deleted. Might be useful for quick inspection.
 	builder.Build("build_filesystem_image", fmt.Sprintf("Creating filesystem %s", f.BaseModuleName()))
 
-	return output, outputHermetic, propFile, toolDeps
+	return output, nil, propFile, toolDeps
 }
 
 func (f *filesystem) buildFileContexts(ctx android.ModuleContext) android.Path {
diff --git a/java/java.go b/java/java.go
index 8d10e3b..d9a6b35 100644
--- a/java/java.go
+++ b/java/java.go
@@ -1845,6 +1845,22 @@
 		}
 	}
 	moduleInfoJSON.TestMainlineModules = append(moduleInfoJSON.TestMainlineModules, j.testProperties.Test_mainline_modules...)
+
+	// Install test deps
+	if !ctx.Config().KatiEnabled() {
+		pathInTestCases := android.PathForModuleInstall(ctx, "testcases", ctx.ModuleName())
+		if j.testConfig != nil {
+			ctx.InstallFile(pathInTestCases, ctx.ModuleName()+".config", j.testConfig)
+		}
+		testDeps := append(j.data, j.extraTestConfigs...)
+		for _, data := range android.SortedUniquePaths(testDeps) {
+			dataPath := android.DataPath{SrcPath: data}
+			ctx.InstallTestData(pathInTestCases, []android.DataPath{dataPath})
+		}
+		if j.installFile != nil {
+			ctx.InstallFile(pathInTestCases, ctx.ModuleName()+".jar", j.installFile)
+		}
+	}
 }
 
 func (j *TestHelperLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
diff --git a/java/java_test.go b/java/java_test.go
index d415679..53d2f5c 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -1916,7 +1916,7 @@
 			}
 
 			actualData := entries.EntryMap["LOCAL_COMPATIBILITY_SUPPORT_FILES"]
-			android.AssertStringPathsRelativeToTopEquals(t, "LOCAL_TEST_DATA", ctx.Config, expectedData, actualData)
+			android.AssertStringPathsRelativeToTopEquals(t, "LOCAL_TEST_DATA", ctx.Config, android.SortedUniqueStrings(expectedData), android.SortedUniqueStrings(actualData))
 		})
 	}
 }