Do not add the same output artifact twice to the outputs of a
JavaCompileAction.
RELNOTES: None.
PiperOrigin-RevId: 235184595
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileAction.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileAction.java
index cdfc4a7..fa39881 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileAction.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileAction.java
@@ -95,7 +95,7 @@
private final ImmutableList<Artifact> sourceJars;
private final JavaPluginInfo plugins;
- private final ImmutableList<? extends ActionInput> outputFiles;
+ private final ImmutableSet<? extends ActionInput> outputFiles;
private final NestedSet<Artifact> directJars;
private final NestedSet<Artifact> mandatoryInputs;
private final NestedSet<Artifact> transitiveInputs;
@@ -148,9 +148,12 @@
this.dependencyArtifacts = dependencyArtifacts;
this.outputDepsProto = outputDepsProto;
this.classpathMode = classpathMode;
- ImmutableList.Builder<ActionInput> outputsBuilder = ImmutableList.builder();
+ ImmutableSet.Builder<ActionInput> outputsBuilder = ImmutableSet.builder();
outputsBuilder.addAll(outputs);
if (outputDepsProto != null) {
+ // If the outputDepsProto is a proper Artifact, it is already in outputs and has thus been
+ // declared as an output of the action above. Adding it again won't hurt as this is a set.
+ // If we are reading deps protos in memory, add the virtual action output here.
outputsBuilder.add(outputDepsProto);
}
outputFiles = outputsBuilder.build();