add plugins to javaLibraryAttributes
Test: go test ./bp2build Change-Id: I8e4c3f373c62c60ea5013cd8c585915a366c1f81
This commit is contained in:
@@ -22,11 +22,15 @@ import (
|
||||
"android/soong/java"
|
||||
)
|
||||
|
||||
func runJavaLibraryTestCase(t *testing.T, tc bp2buildTestCase) {
|
||||
func runJavaLibraryTestCaseWithRegistrationCtxFunc(t *testing.T, tc bp2buildTestCase, registrationCtxFunc func(ctx android.RegistrationContext)) {
|
||||
t.Helper()
|
||||
(&tc).moduleTypeUnderTest = "java_library"
|
||||
(&tc).moduleTypeUnderTestFactory = java.LibraryFactory
|
||||
runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, tc)
|
||||
runBp2BuildTestCase(t, registrationCtxFunc, tc)
|
||||
}
|
||||
|
||||
func runJavaLibraryTestCase(t *testing.T, tc bp2buildTestCase) {
|
||||
runJavaLibraryTestCaseWithRegistrationCtxFunc(t, tc, func(ctx android.RegistrationContext) {})
|
||||
}
|
||||
|
||||
func TestJavaLibrary(t *testing.T) {
|
||||
@@ -129,3 +133,26 @@ java_library {
|
||||
expectedBazelTargets: []string{},
|
||||
})
|
||||
}
|
||||
|
||||
func TestJavaLibraryPlugins(t *testing.T) {
|
||||
runJavaLibraryTestCaseWithRegistrationCtxFunc(t, bp2buildTestCase{
|
||||
blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
plugins: ["java-plugin-1"],
|
||||
bazel_module: { bp2build_available: true },
|
||||
}
|
||||
|
||||
java_plugin {
|
||||
name: "java-plugin-1",
|
||||
srcs: ["a.java"],
|
||||
bazel_module: { bp2build_available: false },
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("java_library", "java-lib-1", attrNameToString{
|
||||
"plugins": `[":java-plugin-1"]`,
|
||||
}),
|
||||
},
|
||||
}, func(ctx android.RegistrationContext) {
|
||||
ctx.RegisterModuleType("java_plugin", java.PluginFactory)
|
||||
})
|
||||
}
|
||||
|
@@ -2026,6 +2026,7 @@ func addCLCFromDep(ctx android.ModuleContext, depModule android.Module,
|
||||
|
||||
type javaCommonAttributes struct {
|
||||
Srcs bazel.LabelListAttribute
|
||||
Plugins bazel.LabelListAttribute
|
||||
Javacopts bazel.StringListAttribute
|
||||
}
|
||||
|
||||
@@ -2061,6 +2062,9 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext)
|
||||
|
||||
commonAttrs := &javaCommonAttributes{
|
||||
Srcs: srcPartitions[javaSrcPartition],
|
||||
Plugins: bazel.MakeLabelListAttribute(
|
||||
android.BazelLabelForModuleDeps(ctx, m.properties.Plugins),
|
||||
),
|
||||
}
|
||||
|
||||
if m.properties.Javacflags != nil {
|
||||
|
Reference in New Issue
Block a user