diff options
author | 2022-10-10 13:45:06 -0700 | |
---|---|---|
committer | 2022-10-27 11:19:53 -0700 | |
commit | ca65b40fa02f7103363772c2d020dec04a8f93ec (patch) | |
tree | 16b7db84c348fccee194be806c0725190ef6243f /java/java_test.go | |
parent | 3bd8f0a6e6884137525905a4cf125147a0a0a2d9 (diff) |
Generate a default wrapper for device java_binary
Any device java_binary that doesn't have a specific wrapper must
have a main_class property, which is used to generate its default
wrapper. Otherwise its build should fail.
Bug: 250851599
Test: TestDeviceBinaryWrapperGeneration in java_test.go
Change-Id: Ice4c580bcfc1b92f95e217b39e984c55d25a3a02
Diffstat (limited to 'java/java_test.go')
-rw-r--r-- | java/java_test.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/java/java_test.go b/java/java_test.go index 3b86f9aa4..f06b520d5 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -1783,3 +1783,26 @@ func TestGenAidlIncludeFlagsForMixedBuilds(t *testing.T) { t.Errorf("expected flags to be %q; was %q", expectedFlags, flags) } } + +func TestDeviceBinaryWrapperGeneration(t *testing.T) { + // Scenario 1: java_binary has main_class property in its bp + ctx, _ := testJava(t, ` + java_binary { + name: "foo", + srcs: ["foo.java"], + main_class: "foo.bar.jb", + } + `) + wrapperPath := fmt.Sprint(ctx.ModuleForTests("foo", "android_arm64_armv8-a").AllOutputs()) + if !strings.Contains(wrapperPath, "foo.sh") { + t.Errorf("wrapper file foo.sh is not generated") + } + + // Scenario 2: java_binary has neither wrapper nor main_class, its build + // is expected to be failed. + testJavaError(t, "main_class property is required for device binary if no default wrapper is assigned", ` + java_binary { + name: "foo", + srcs: ["foo.java"], + }`) +} |