summaryrefslogtreecommitdiff
path: root/java/base.go
diff options
context:
space:
mode:
author Cole Faust <colefaust@google.com> 2024-12-11 16:49:18 -0800
committer Cole Faust <colefaust@google.com> 2024-12-11 16:49:18 -0800
commitf3240f4102fa9b439f9e739f17075eec0b2d39c8 (patch)
tree8474eff43a268ef0497341d978e0fb3357fb0d6b /java/base.go
parentf7bbd2fe40e43f7fda7e08d08eeb9c2a93552ad9 (diff)
Add the ability to always run errorprone inline
Currently, if you enable RUN_ERROR_PRONE=true, we create a seperate jar from the main build which runs errorprone. But errorprone builds also produce a regular built jar as a side effect, so you could use it as your main java builder action. We don't do that because if you toggled errorprone on/off, you'd invalidate all the java builds. However, on CI, we always run with errorprone on, so there, it makes more sense to always do the inline builds so that you don't have to build everything twice. Add a new environment variable to control running errorprone inline or not. Bug: 383626679 Test: Presubmits Change-Id: I262af140fdeacb8342fe801f0c86f516d8fca587
Diffstat (limited to 'java/base.go')
-rw-r--r--java/base.go35
1 files changed, 21 insertions, 14 deletions
diff --git a/java/base.go b/java/base.go
index 215285fdb..cd5550a7c 100644
--- a/java/base.go
+++ b/java/base.go
@@ -1442,20 +1442,27 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
// build.
flags = enableErrorproneFlags(flags)
} else if hasErrorproneableFiles && ctx.Config().RunErrorProne() && j.properties.Errorprone.Enabled == nil {
- // Otherwise, if the RUN_ERROR_PRONE environment variable is set, create
- // a new jar file just for compiling with the errorprone compiler to.
- // This is because we don't want to cause the java files to get completely
- // rebuilt every time the state of the RUN_ERROR_PRONE variable changes.
- // We also don't want to run this if errorprone is enabled by default for
- // this module, or else we could have duplicated errorprone messages.
- errorproneFlags := enableErrorproneFlags(flags)
- errorprone := android.PathForModuleOut(ctx, "errorprone", jarName)
- errorproneAnnoSrcJar := android.PathForModuleOut(ctx, "errorprone", "anno.srcjar")
-
- transformJavaToClasses(ctx, errorprone, -1, uniqueJavaFiles, srcJars, errorproneAnnoSrcJar, errorproneFlags, nil,
- "errorprone", "errorprone")
-
- extraJarDeps = append(extraJarDeps, errorprone)
+ if ctx.Config().RunErrorProneInline() {
+ // On CI, we're not going to toggle back/forth between errorprone and non-errorprone
+ // builds, so it's faster if we don't compile the module twice and instead always
+ // compile the module with errorprone.
+ flags = enableErrorproneFlags(flags)
+ } else {
+ // Otherwise, if the RUN_ERROR_PRONE environment variable is set, create
+ // a new jar file just for compiling with the errorprone compiler to.
+ // This is because we don't want to cause the java files to get completely
+ // rebuilt every time the state of the RUN_ERROR_PRONE variable changes.
+ // We also don't want to run this if errorprone is enabled by default for
+ // this module, or else we could have duplicated errorprone messages.
+ errorproneFlags := enableErrorproneFlags(flags)
+ errorprone := android.PathForModuleOut(ctx, "errorprone", jarName)
+ errorproneAnnoSrcJar := android.PathForModuleOut(ctx, "errorprone", "anno.srcjar")
+
+ transformJavaToClasses(ctx, errorprone, -1, uniqueJavaFiles, srcJars, errorproneAnnoSrcJar, errorproneFlags, nil,
+ "errorprone", "errorprone")
+
+ extraJarDeps = append(extraJarDeps, errorprone)
+ }
}
if enableSharding {