Merge "support errorprone javacflags"
This commit is contained in:
@@ -30,6 +30,7 @@ func runJavaLibraryTestCaseWithRegistrationCtxFunc(t *testing.T, tc bp2buildTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runJavaLibraryTestCase(t *testing.T, tc bp2buildTestCase) {
|
func runJavaLibraryTestCase(t *testing.T, tc bp2buildTestCase) {
|
||||||
|
t.Helper()
|
||||||
runJavaLibraryTestCaseWithRegistrationCtxFunc(t, tc, func(ctx android.RegistrationContext) {})
|
runJavaLibraryTestCaseWithRegistrationCtxFunc(t, tc, func(ctx android.RegistrationContext) {})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,3 +157,65 @@ java_plugin {
|
|||||||
ctx.RegisterModuleType("java_plugin", java.PluginFactory)
|
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,
|
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{
|
commonAttrs := &javaCommonAttributes{
|
||||||
Srcs: srcPartitions[javaSrcPartition],
|
Srcs: srcPartitions[javaSrcPartition],
|
||||||
Plugins: bazel.MakeLabelListAttribute(
|
Plugins: bazel.MakeLabelListAttribute(
|
||||||
android.BazelLabelForModuleDeps(ctx, m.properties.Plugins),
|
android.BazelLabelForModuleDeps(ctx, m.properties.Plugins),
|
||||||
),
|
),
|
||||||
}
|
Javacopts: bazel.MakeStringListAttribute(javacopts),
|
||||||
|
|
||||||
if m.properties.Javacflags != nil {
|
|
||||||
commonAttrs.Javacopts = bazel.MakeStringListAttribute(m.properties.Javacflags)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
depLabels := &javaDependencyLabels{}
|
depLabels := &javaDependencyLabels{}
|
||||||
|
Reference in New Issue
Block a user