summaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go40
1 files changed, 32 insertions, 8 deletions
diff --git a/java/java.go b/java/java.go
index 521aef301..270f45615 100644
--- a/java/java.go
+++ b/java/java.go
@@ -1798,6 +1798,7 @@ func (al *ApiLibrary) extractApiSrcs(ctx android.ModuleContext, rule *android.Ru
Flag("-jar").
Flag("-write_if_changed").
Flag("-ignore_missing_files").
+ Flag("-quiet").
FlagWithArg("-C ", unzippedSrcJarDir.String()).
FlagWithInput("-l ", classFilesList).
FlagWithOutput("-o ", al.stubsJarWithoutStaticLibs)
@@ -2826,7 +2827,7 @@ func (m *Library) convertJavaResourcesAttributes(ctx android.TopDownMutatorConte
if resourceStripPrefix == nil && i == 0 {
resourceStripPrefix = resAttr.Resource_strip_prefix
resources = resAttr.Resources.Value
- } else {
+ } else if !resAttr.Resources.IsEmpty() {
ctx.CreateBazelTargetModule(
bazel.BazelTargetModuleProperties{
Rule_class: "java_resources",
@@ -2885,8 +2886,9 @@ type javaAidlLibraryAttributes struct {
// depending on the module type.
type bp2BuildJavaInfo struct {
// separates dependencies into dynamic dependencies and static dependencies.
- DepLabels *javaDependencyLabels
- hasKotlin bool
+ DepLabels *javaDependencyLabels
+ hasKotlin bool
+ onlyProtoInSrcs bool
}
func javaXsdTargetName(xsd android.XsdConfigBp2buildTargets) string {
@@ -2904,8 +2906,13 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext)
var staticDeps bazel.LabelListAttribute
if proptools.String(m.deviceProperties.Sdk_version) == "" && m.DeviceSupported() {
+ // TODO(b/297356704): handle platform apis in bp2build
ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_PROPERTY_UNSUPPORTED, "sdk_version unset")
return &javaCommonAttributes{}, &bp2BuildJavaInfo{}, false
+ } else if proptools.String(m.deviceProperties.Sdk_version) == "core_platform" {
+ // TODO(b/297356582): handle core_platform in bp2build
+ ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_PROPERTY_UNSUPPORTED, "sdk_version core_platform")
+ return &javaCommonAttributes{}, &bp2BuildJavaInfo{}, false
}
archVariantProps := m.GetArchVariantProperties(ctx, &CommonProperties{})
@@ -2944,6 +2951,9 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext)
staticDeps.Append(srcPartitions[xsdSrcPartition])
+ _, protoInSrcs := srcPartitions[protoSrcPartition]
+ onlyProtoInSrcs := protoInSrcs && len(srcPartitions) == 1
+
if !srcPartitions[logtagSrcPartition].IsEmpty() {
logtagsLibName := m.Name() + "_logtags"
ctx.CreateBazelTargetModule(
@@ -3081,8 +3091,9 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext)
}
bp2BuildInfo := &bp2BuildJavaInfo{
- DepLabels: depLabels,
- hasKotlin: hasKotlin,
+ DepLabels: depLabels,
+ hasKotlin: hasKotlin,
+ onlyProtoInSrcs: onlyProtoInSrcs,
}
return commonAttrs, bp2BuildInfo, true
@@ -3122,16 +3133,29 @@ func javaLibraryBp2Build(ctx android.TopDownMutatorContext, m *Library) {
depLabels := bp2BuildInfo.DepLabels
deps := depLabels.Deps
+ exports := depLabels.StaticDeps
if !commonAttrs.Srcs.IsEmpty() {
- deps.Append(depLabels.StaticDeps) // we should only append these if there are sources to use them
+ deps.Append(exports) // we should only append these if there are sources to use them
} else if !deps.IsEmpty() {
- ctx.ModuleErrorf("Module has direct dependencies but no sources. Bazel will not allow this.")
+ if bp2BuildInfo.onlyProtoInSrcs {
+ // java_library does not accept deps when there are no srcs because
+ // there is no compilation happening, but it accepts exports.
+ // bp2build converts this module to 2 java_libraries + java_xx_proto_library + proto_library
+ // the non-empty deps here are not necessary for compiling the protos, in which case
+ // they're unnecessary as deps on the java_library as well since they aren't
+ // being propagated to any dependencies.
+ // so we can put the deps to exports and drop deps here.
+ exports.Append(deps)
+ deps = bazel.LabelListAttribute{}
+ } else {
+ ctx.ModuleErrorf("Module has direct dependencies but no sources. Bazel will not allow this.")
+ }
}
var props bazel.BazelTargetModuleProperties
attrs := &javaLibraryAttributes{
javaCommonAttributes: commonAttrs,
Deps: deps,
- Exports: depLabels.StaticDeps,
+ Exports: exports,
}
name := m.Name()