Merge "support errorprone javacflags" am: ef03b3d8ba
am: 9f677ae8c7
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2029264 Change-Id: Idc594e540e7c87f06042dd4771d641ec847c0572 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
2c7155c74e
2 changed files with 74 additions and 4 deletions
|
@ -30,6 +30,7 @@ func runJavaLibraryTestCaseWithRegistrationCtxFunc(t *testing.T, tc bp2buildTest
|
|||
}
|
||||
|
||||
func runJavaLibraryTestCase(t *testing.T, tc bp2buildTestCase) {
|
||||
t.Helper()
|
||||
runJavaLibraryTestCaseWithRegistrationCtxFunc(t, tc, func(ctx android.RegistrationContext) {})
|
||||
}
|
||||
|
||||
|
@ -156,3 +157,65 @@ java_plugin {
|
|||
ctx.RegisterModuleType("java_plugin", java.PluginFactory)
|
||||
})
|
||||
}
|
||||
|
||||
func TestJavaLibraryErrorproneJavacflagsEnabledManually(t *testing.T) {
|
||||
runJavaLibraryTestCase(t, bp2buildTestCase{
|
||||
blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
srcs: ["a.java"],
|
||||
javacflags: ["-Xsuper-fast"],
|
||||
errorprone: {
|
||||
enabled: true,
|
||||
javacflags: ["-Xep:SpeedLimit:OFF"],
|
||||
},
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("java_library", "java-lib-1", attrNameToString{
|
||||
"javacopts": `[
|
||||
"-Xsuper-fast",
|
||||
"-Xep:SpeedLimit:OFF",
|
||||
]`,
|
||||
"srcs": `["a.java"]`,
|
||||
}),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestJavaLibraryErrorproneJavacflagsErrorproneDisabledByDefault(t *testing.T) {
|
||||
runJavaLibraryTestCase(t, bp2buildTestCase{
|
||||
blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
srcs: ["a.java"],
|
||||
javacflags: ["-Xsuper-fast"],
|
||||
errorprone: {
|
||||
javacflags: ["-Xep:SpeedLimit:OFF"],
|
||||
},
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("java_library", "java-lib-1", attrNameToString{
|
||||
"javacopts": `["-Xsuper-fast"]`,
|
||||
"srcs": `["a.java"]`,
|
||||
}),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestJavaLibraryErrorproneJavacflagsErrorproneDisabledManually(t *testing.T) {
|
||||
runJavaLibraryTestCase(t, bp2buildTestCase{
|
||||
blueprint: `java_library {
|
||||
name: "java-lib-1",
|
||||
srcs: ["a.java"],
|
||||
javacflags: ["-Xsuper-fast"],
|
||||
errorprone: {
|
||||
enabled: false,
|
||||
javacflags: ["-Xep:SpeedLimit:OFF"],
|
||||
},
|
||||
}`,
|
||||
expectedBazelTargets: []string{
|
||||
makeBazelTarget("java_library", "java-lib-1", attrNameToString{
|
||||
"javacopts": `["-Xsuper-fast"]`,
|
||||
"srcs": `["a.java"]`,
|
||||
}),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
15
java/java.go
15
java/java.go
|
@ -2060,15 +2060,22 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext)
|
|||
protoSrcPartition: android.ProtoSrcLabelPartition,
|
||||
})
|
||||
|
||||
var javacopts []string
|
||||
if m.properties.Javacflags != nil {
|
||||
javacopts = append(javacopts, m.properties.Javacflags...)
|
||||
}
|
||||
epEnabled := m.properties.Errorprone.Enabled
|
||||
//TODO(b/227504307) add configuration that depends on RUN_ERROR_PRONE environment variable
|
||||
if Bool(epEnabled) {
|
||||
javacopts = append(javacopts, m.properties.Errorprone.Javacflags...)
|
||||
}
|
||||
|
||||
commonAttrs := &javaCommonAttributes{
|
||||
Srcs: srcPartitions[javaSrcPartition],
|
||||
Plugins: bazel.MakeLabelListAttribute(
|
||||
android.BazelLabelForModuleDeps(ctx, m.properties.Plugins),
|
||||
),
|
||||
}
|
||||
|
||||
if m.properties.Javacflags != nil {
|
||||
commonAttrs.Javacopts = bazel.MakeStringListAttribute(m.properties.Javacflags)
|
||||
Javacopts: bazel.MakeStringListAttribute(javacopts),
|
||||
}
|
||||
|
||||
depLabels := &javaDependencyLabels{}
|
||||
|
|
Loading…
Reference in a new issue