Link type checking for java_library

Link type checking for java_library has not been working unintentionally.
So turn on link type checking for these types.

And also add tests for link type checking.

Bug: 145799020
Test: cherry-pick aosp/1182522 and check if build fails
Test: m nothing and there is no error(soong unittest)

Change-Id: Ifc347f657885de1028ac0076ddd103c0387b597a
This commit is contained in:
Jeongik Cha
2019-12-07 00:16:24 +09:00
parent f6739a65dd
commit e403e9e8dc
3 changed files with 178 additions and 2 deletions

View File

@@ -175,6 +175,95 @@ func TestPlatformAPIs(t *testing.T) {
`)
}
func TestAndroidAppLinkType(t *testing.T) {
testJava(t, `
android_app {
name: "foo",
srcs: ["a.java"],
libs: ["bar"],
static_libs: ["baz"],
platform_apis: true,
}
java_library {
name: "bar",
sdk_version: "current",
srcs: ["b.java"],
}
android_library {
name: "baz",
sdk_version: "system_current",
srcs: ["c.java"],
}
`)
testJavaError(t, "Adjust sdk_version: property of the source or target module so that target module is built with the same or smaller API set than the source.", `
android_app {
name: "foo",
srcs: ["a.java"],
libs: ["bar"],
sdk_version: "current",
static_libs: ["baz"],
}
java_library {
name: "bar",
sdk_version: "current",
srcs: ["b.java"],
}
android_library {
name: "baz",
sdk_version: "system_current",
srcs: ["c.java"],
}
`)
testJava(t, `
android_app {
name: "foo",
srcs: ["a.java"],
libs: ["bar"],
sdk_version: "system_current",
static_libs: ["baz"],
}
java_library {
name: "bar",
sdk_version: "current",
srcs: ["b.java"],
}
android_library {
name: "baz",
sdk_version: "system_current",
srcs: ["c.java"],
}
`)
testJavaError(t, "Adjust sdk_version: property of the source or target module so that target module is built with the same or smaller API set than the source.", `
android_app {
name: "foo",
srcs: ["a.java"],
libs: ["bar"],
sdk_version: "system_current",
static_libs: ["baz"],
}
java_library {
name: "bar",
sdk_version: "current",
srcs: ["b.java"],
}
android_library {
name: "baz",
srcs: ["c.java"],
}
`)
}
func TestResourceDirs(t *testing.T) {
testCases := []struct {
name string