Make javac rules output a jar with soong_zip

Make javac rules output a jar file instead of a classes.list.
Combine the output jar, static jar dependencies, and resources
into the final jar using a separate rule.  For now, use a shell
command with unzip and soong_zip to create the final jar,
eventually it will be done with a zip2zip-style jar combiner.

Bug: 64691570
Test: java_test.go
Change-Id: Id8e6313e0097b78947d88e86e47b56ad08caca1a
diff --git a/java/java_test.go b/java/java_test.go
index 6d9445b..4f5c0ec 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -69,6 +69,7 @@
 		bp += fmt.Sprintf(`
 			java_library {
 				name: "%s",
+				srcs: ["a.java"],
 				no_standard_libs: true,
 			}
 		`, extra)
@@ -112,20 +113,25 @@
 		`)
 
 	javac := ctx.ModuleForTests("foo", "").Rule("javac")
-	jar := ctx.ModuleForTests("foo", "").Rule("jar")
+	combineJar := ctx.ModuleForTests("foo", "").Rule("combineJar")
 
 	if len(javac.Inputs) != 1 || javac.Inputs[0].String() != "a.java" {
 		t.Errorf(`foo inputs %v != ["a.java"]`, javac.Inputs)
 	}
 
-	bar := filepath.Join(buildDir, ".intermediates", "bar", "classes-full-debug.jar")
+	bar := filepath.Join(buildDir, ".intermediates", "bar", "classes.jar")
+	baz := filepath.Join(buildDir, ".intermediates", "baz", "classes.jar")
+
 	if !strings.Contains(javac.Args["classpath"], bar) {
 		t.Errorf("foo classpath %v does not contain %q", javac.Args["classpath"], bar)
 	}
 
-	baz := filepath.Join(buildDir, ".intermediates", "baz", "classes.list")
-	if !strings.Contains(jar.Args["jarArgs"], baz) {
-		t.Errorf("foo jarArgs %v does not contain %q", jar.Args["jarArgs"], baz)
+	if !strings.Contains(javac.Args["classpath"], baz) {
+		t.Errorf("foo classpath %v does not contain %q", javac.Args["classpath"], baz)
+	}
+
+	if len(combineJar.Inputs) != 2 || combineJar.Inputs[1].String() != baz {
+		t.Errorf("foo combineJar inputs %v does not contain %q", combineJar.Inputs, baz)
 	}
 }
 
@@ -176,7 +182,7 @@
 
 	check := func(module string, depType depType, deps ...string) {
 		for i := range deps {
-			deps[i] = filepath.Join(buildDir, ".intermediates", deps[i], "classes-full-debug.jar")
+			deps[i] = filepath.Join(buildDir, ".intermediates", deps[i], "classes.jar")
 		}
 		dep := strings.Join(deps, ":")
 
@@ -229,16 +235,15 @@
 		`)
 
 	javac := ctx.ModuleForTests("foo", "").Rule("javac")
-	jar := ctx.ModuleForTests("foo", "").Rule("jar")
+	combineJar := ctx.ModuleForTests("foo", "").Rule("combineJar")
 
 	bar := "a.jar"
 	if !strings.Contains(javac.Args["classpath"], bar) {
 		t.Errorf("foo classpath %v does not contain %q", javac.Args["classpath"], bar)
 	}
 
-	baz := filepath.Join(buildDir, ".intermediates", "baz", "extracted0", "classes.list")
-	if !strings.Contains(jar.Args["jarArgs"], baz) {
-		t.Errorf("foo jarArgs %v does not contain %q", jar.Args["jarArgs"], baz)
+	if len(combineJar.Inputs) != 2 || combineJar.Inputs[1].String() != "b.jar" {
+		t.Errorf("foo combineJar inputs %v does not contain %q", combineJar.Inputs, "b.jar")
 	}
 }
 
@@ -268,20 +273,20 @@
 		`)
 
 	javac := ctx.ModuleForTests("foo", "").Rule("javac")
-	jar := ctx.ModuleForTests("foo", "").Rule("jar")
+	combineJar := ctx.ModuleForTests("foo", "").Rule("combineJar")
 
 	if len(javac.Inputs) != 1 || javac.Inputs[0].String() != "a.java" {
 		t.Errorf(`foo inputs %v != ["a.java"]`, javac.Inputs)
 	}
 
-	bar := filepath.Join(buildDir, ".intermediates", "bar", "classes-full-debug.jar")
+	bar := filepath.Join(buildDir, ".intermediates", "bar", "classes.jar")
 	if !strings.Contains(javac.Args["classpath"], bar) {
 		t.Errorf("foo classpath %v does not contain %q", javac.Args["classpath"], bar)
 	}
 
-	baz := filepath.Join(buildDir, ".intermediates", "baz", "classes.list")
-	if !strings.Contains(jar.Args["jarArgs"], baz) {
-		t.Errorf("foo jarArgs %v does not contain %q", jar.Args["jarArgs"], baz)
+	baz := filepath.Join(buildDir, ".intermediates", "baz", "classes.jar")
+	if len(combineJar.Inputs) != 2 || combineJar.Inputs[1].String() != baz {
+		t.Errorf("foo combineJar inputs %v does not contain %q", combineJar.Inputs, baz)
 	}
 }