diff options
| author | 2023-06-20 21:00:40 +0000 | |
|---|---|---|
| committer | 2023-07-13 15:50:18 +0000 | |
| commit | b1e5c6a69a3e06819e26c6d669c3a18e4ec5db1a (patch) | |
| tree | f7343f54618846d220a8ddfb1eb3bb291e93d3c0 /java/java.go | |
| parent | c0dac52975761684e82d158e532545873bd133d8 (diff) | |
Bp2build for errorprone modules that manually enabled/disabled it
Test: go test ./bp2build
Change-Id: Ie60c0959ee9ae8ce86c11a8e85a0bc7592f63df8
Diffstat (limited to 'java/java.go')
| -rw-r--r-- | java/java.go | 42 | 
1 files changed, 26 insertions, 16 deletions
| diff --git a/java/java.go b/java/java.go index 389cdcede..445eb61c9 100644 --- a/java/java.go +++ b/java/java.go @@ -2765,11 +2765,12 @@ func (m *Library) convertJavaResourcesAttributes(ctx android.TopDownMutatorConte  type javaCommonAttributes struct {  	*javaResourcesAttributes  	*kotlinAttributes -	Srcs         bazel.LabelListAttribute -	Plugins      bazel.LabelListAttribute -	Javacopts    bazel.StringListAttribute -	Sdk_version  bazel.StringAttribute -	Java_version bazel.StringAttribute +	Srcs                    bazel.LabelListAttribute +	Plugins                 bazel.LabelListAttribute +	Javacopts               bazel.StringListAttribute +	Sdk_version             bazel.StringAttribute +	Java_version            bazel.StringAttribute +	Errorprone_force_enable bazel.BoolAttribute  }  type javaDependencyLabels struct { @@ -2911,26 +2912,35 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext)  		staticDeps.Add(&bazel.Label{Label: ":" + javaAidlLibName})  	} -	var javacopts []string +	var javacopts bazel.StringListAttribute //[]string +	plugins := bazel.MakeLabelListAttribute( +		android.BazelLabelForModuleDeps(ctx, m.properties.Plugins), +	)  	if m.properties.Javacflags != nil { -		javacopts = append(javacopts, m.properties.Javacflags...) +		javacopts = bazel.MakeStringListAttribute(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...) +	epJavacflags := m.properties.Errorprone.Javacflags +	var errorproneForceEnable bazel.BoolAttribute +	if epEnabled == nil { +		//TODO(b/227504307) add configuration that depends on RUN_ERROR_PRONE environment variable +	} else if *epEnabled { +		plugins.Append(bazel.MakeLabelListAttribute(android.BazelLabelForModuleDeps(ctx, m.properties.Errorprone.Extra_check_modules))) +		javacopts.Append(bazel.MakeStringListAttribute(epJavacflags)) +		errorproneForceEnable.Value = epEnabled +	} else { +		javacopts.Append(bazel.MakeStringListAttribute([]string{"-XepDisableAllChecks"}))  	}  	commonAttrs := &javaCommonAttributes{  		Srcs:                    javaSrcs,  		javaResourcesAttributes: m.convertJavaResourcesAttributes(ctx), -		Plugins: bazel.MakeLabelListAttribute( -			android.BazelLabelForModuleDeps(ctx, m.properties.Plugins), -		), -		Javacopts:    bazel.MakeStringListAttribute(javacopts), -		Java_version: bazel.StringAttribute{Value: m.properties.Java_version}, -		Sdk_version:  bazel.StringAttribute{Value: m.deviceProperties.Sdk_version}, +		Plugins:                 plugins, +		Javacopts:               javacopts, +		Java_version:            bazel.StringAttribute{Value: m.properties.Java_version}, +		Sdk_version:             bazel.StringAttribute{Value: m.deviceProperties.Sdk_version}, +		Errorprone_force_enable: errorproneForceEnable,  	}  	for axis, configToProps := range archVariantProps { |