Converge on --jdeps_output instead of --output when invoking ImportDepsChecker

PiperOrigin-RevId: 211756658
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AarImport.java b/src/main/java/com/google/devtools/build/lib/rules/android/AarImport.java
index 775a2e9..36d71ab 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AarImport.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AarImport.java
@@ -161,26 +161,23 @@
             .build());
 
     JavaConfiguration javaConfig = ruleContext.getFragment(JavaConfiguration.class);
-    Artifact depsCheckerResult =
-        createAarArtifact(ruleContext, "aar_import_deps_checker_result.txt");
     ImportDepsCheckActionBuilder.newBuilder()
         .bootclasspath(getBootclasspath(ruleContext))
         .declareDeps(getCompileTimeJarsFromCollection(targets, /*isDirect=*/ true))
         .transitiveDeps(getCompileTimeJarsFromCollection(targets, /*isDirect=*/ false))
         .checkJars(NestedSetBuilder.<Artifact>stableOrder().add(mergedJar).build())
-        .outputArtifact(depsCheckerResult)
         .importDepsCheckingLevel(javaConfig.getImportDepsCheckingLevel())
         .jdepsOutputArtifact(jdepsArtifact)
         .ruleLabel(ruleContext.getLabel())
         .buildAndRegister(ruleContext);
 
-    // We pass depsCheckerResult to create the action of extracting ANDROID_MANIFEST. Note that
-    // this action does not need depsCheckerResult. The only reason is that we need to check the
+    // We pass jdepsArtifact to create the action of extracting ANDROID_MANIFEST. Note that
+    // this action does not need jdepsArtifact. The only reason is that we need to check the
     // dependencies of this aar_import, and we need to put its result on the build graph so that the
     // dependency checking action is called.
     ruleContext.registerAction(
         createSingleFileExtractorActions(
-            ruleContext, aar, ANDROID_MANIFEST, depsCheckerResult, androidManifestArtifact));
+            ruleContext, aar, ANDROID_MANIFEST, jdepsArtifact, androidManifestArtifact));
 
     JavaCompilationArgsProvider javaCompilationArgsProvider =
         common.collectJavaCompilationArgs(
@@ -213,9 +210,9 @@
             new AndroidNativeLibsInfo(
                 AndroidCommon.collectTransitiveNativeLibs(ruleContext).add(nativeLibs).build()))
         .addNativeDeclaredProvider(javaInfoBuilder.build());
-    if (depsCheckerResult != null) {
+    if (jdepsArtifact != null) {
       // Add the deps check result so that we can unit test it.
-      ruleBuilder.addOutputGroup(OutputGroupInfo.HIDDEN_TOP_LEVEL, depsCheckerResult);
+      ruleBuilder.addOutputGroup(OutputGroupInfo.HIDDEN_TOP_LEVEL, jdepsArtifact);
     }
     return ruleBuilder.build();
   }
@@ -245,7 +242,7 @@
 
   /**
    * Create an action to extract a file (specified by the parameter filename) from an AAR file. Note
-   * that the parameter depsCheckerResult is not necessary for this action. Conversely, the action
+   * that the parameter jdepsOutputArtifact is not necessary for this action. Conversely, the action
    * of checking dependencies for aar_import needs this action instead. Therefore we add the output
    * artifact of import_deps_checker to this extraction action as input. Therefore, the dependency
    * checking will run each time.
@@ -254,7 +251,7 @@
       RuleContext ruleContext,
       Artifact aar,
       String filename,
-      Artifact depsCheckerResult,
+      Artifact jdepsOutputArtifact,
       Artifact outputArtifact) {
     SpawnAction.Builder builder =
         new SpawnAction.Builder()
@@ -271,8 +268,8 @@
                     .addPath("-d", outputArtifact.getExecPath().getParentDirectory())
                     .addDynamicString(filename)
                     .build());
-    if (depsCheckerResult != null) {
-      builder.addInput(depsCheckerResult);
+    if (jdepsOutputArtifact != null) {
+      builder.addInput(jdepsOutputArtifact);
     }
     return builder.build(ruleContext);
   }
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/ImportDepsCheckActionBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/java/ImportDepsCheckActionBuilder.java
index ff7693a..bf245a2 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/ImportDepsCheckActionBuilder.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/ImportDepsCheckActionBuilder.java
@@ -34,7 +34,6 @@
     return new ImportDepsCheckActionBuilder();
   }
 
-  private Artifact outputArtifact;
   private Artifact jdepsArtifact;
   private Label ruleLabel;
   private NestedSet<Artifact> jarsToCheck;
@@ -51,12 +50,6 @@
     return this;
   }
 
-  public ImportDepsCheckActionBuilder outputArtifact(Artifact outputArtifact) {
-    checkState(this.outputArtifact == null);
-    this.outputArtifact = checkNotNull(outputArtifact);
-    return this;
-  }
-
   public ImportDepsCheckActionBuilder ruleLabel(Label ruleLabel) {
     checkState(this.ruleLabel == null);
     this.ruleLabel = checkNotNull(ruleLabel);
@@ -95,7 +88,6 @@
   }
 
   public void buildAndRegister(RuleContext ruleContext) {
-    checkNotNull(outputArtifact);
     checkNotNull(jarsToCheck);
     checkNotNull(bootclasspath);
     checkNotNull(declaredDeps);
@@ -112,7 +104,6 @@
             .addTransitiveInputs(declaredDeps)
             .addTransitiveInputs(transitiveDeps)
             .addTransitiveInputs(bootclasspath)
-            .addOutput(outputArtifact)
             .addOutput(jdepsArtifact)
             .setMnemonic("ImportDepsChecker")
             .setProgressMessage(
@@ -128,7 +119,6 @@
 
   private CustomCommandLine buildCommandLine() {
     return CustomCommandLine.builder()
-        .addExecPath("--output", outputArtifact)
         .addExecPaths(VectorArg.addBefore("--input").each(jarsToCheck))
         .addExecPaths(VectorArg.addBefore("--directdep").each(declaredDeps))
         .addExecPaths(VectorArg.addBefore("--classpath_entry").each(transitiveDeps))
diff --git a/src/test/java/com/google/devtools/build/lib/rules/android/AarImportTest.java b/src/test/java/com/google/devtools/build/lib/rules/android/AarImportTest.java
index 67e0460..62fb8a3 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/android/AarImportTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/android/AarImportTest.java
@@ -230,11 +230,10 @@
     assertThat(outputGroup).contains(mergedAssetsZip);
 
     // Get the other artifact from the output group
-    Artifact artifact = ActionsTestUtil.getFirstArtifactEndingWith(outputGroup, ".txt");
+    Artifact artifact = ActionsTestUtil.getFirstArtifactEndingWith(outputGroup, "jdeps.proto");
 
     assertThat(artifact.isTreeArtifact()).isFalse();
-    assertThat(artifact.getExecPathString())
-        .endsWith("_aar/last/aar_import_deps_checker_result.txt");
+    assertThat(artifact.getExecPathString()).endsWith("_aar/last/jdeps.proto");
 
     SpawnAction checkerAction = getGeneratingSpawnAction(artifact);
     List<String> arguments = checkerAction.getArguments();
@@ -244,7 +243,6 @@
             "--classpath_entry",
             "--directdep",
             "--input",
-            "--output",
             "--checking_mode=error",
             "--rule_label",
             "//a:last",
@@ -282,15 +280,14 @@
     assertThat(outputGroup).contains(mergedAssetsZip);
 
     // Get the other artifact from the output group
-    Artifact artifact = ActionsTestUtil.getFirstArtifactEndingWith(outputGroup, ".txt");
+    Artifact artifact = ActionsTestUtil.getFirstArtifactEndingWith(outputGroup, "jdeps.proto");
     checkDepsCheckerOutputArtifact(artifact, expectedCheckingMode);
   }
 
   private void checkDepsCheckerOutputArtifact(Artifact artifact, String expectedCheckingMode)
       throws CommandLineExpansionException {
     assertThat(artifact.isTreeArtifact()).isFalse();
-    assertThat(artifact.getExecPathString())
-        .endsWith("_aar/bar/aar_import_deps_checker_result.txt");
+    assertThat(artifact.getExecPathString()).endsWith("_aar/bar/jdeps.proto");
 
     SpawnAction checkerAction = getGeneratingSpawnAction(artifact);
     List<String> arguments = checkerAction.getArguments();
@@ -299,7 +296,6 @@
             "--bootclasspath_entry",
             "--classpath_entry",
             "--input",
-            "--output",
             "--rule_label",
             "--jdeps_output",
             "--checking_mode=" + expectedCheckingMode);