Merge "support errorprone javacflags" am: ef03b3d8ba
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2029264 Change-Id: Ifbecefada5ac477c465bda832c2b1cbdf0264e47 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
9f677ae8c7
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