Skip to content

Commit

Permalink
Remove merging of java_outputs in JavaPluginInfo.
Browse files Browse the repository at this point in the history
JavaPluginInfo merging of java_outputs caused a significant regression when a large number of plugins is present.

This value is not used by native code and it does not get exposed to Starlark. The only use case for java_outputs is IDE integrations, where the value is used from a single java_plugin target.

Fixes #14287

Closes #14288.

PiperOrigin-RevId: 410502716
  • Loading branch information
comius authored and copybara-github committed Nov 17, 2021
1 parent a6c8818 commit 5cf1d6e
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ private JavaPluginInfo collectPlugins() {
Iterables.addAll(result, getDirectJavaPluginInfoForAttribute(ruleContext, ":java_plugins"));
Iterables.addAll(result, getDirectJavaPluginInfoForAttribute(ruleContext, "plugins"));
Iterables.addAll(result, getExportedJavaPluginInfoForAttribute(ruleContext, "deps"));
return JavaPluginInfo.merge(result);
return JavaPluginInfo.mergeWithoutJavaOutputs(result);
}

private static Iterable<JavaPluginInfo> getDirectJavaPluginInfoForAttribute(
Expand Down Expand Up @@ -841,7 +841,7 @@ private static ImmutableSet<String> getProcessorClasses(RuleContext ruleContext)
}

public static JavaPluginInfo getTransitivePlugins(RuleContext ruleContext) {
return JavaPluginInfo.merge(
return JavaPluginInfo.mergeWithoutJavaOutputs(
Iterables.concat(
getDirectJavaPluginInfoForAttribute(ruleContext, "exported_plugins"),
getExportedJavaPluginInfoForAttribute(ruleContext, "exports")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public static JavaInfo merge(List<JavaInfo> providers, boolean withExportsProvid
.addProvider(
JavaRuleOutputJarsProvider.class,
JavaRuleOutputJarsProvider.merge(javaRuleOutputJarsProviders))
.javaPluginInfo(JavaPluginInfo.merge(javaPluginInfos))
.javaPluginInfo(JavaPluginInfo.mergeWithoutJavaOutputs(javaPluginInfos))
.addProvider(JavaCcInfoProvider.class, JavaCcInfoProvider.merge(javaCcInfoProviders))
// TODO(b/65618333): add merge function to JavaGenJarsProvider. See #3769
// TODO(iirina): merge or remove JavaCompilationInfoProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ private JavaExportsProvider createJavaExportsProvider(Iterable<JavaInfo> exports

private JavaPluginInfo mergeExportedJavaPluginInfo(
Iterable<JavaPluginInfo> plugins, Iterable<JavaInfo> javaInfos) {
return JavaPluginInfo.merge(
return JavaPluginInfo.mergeWithoutJavaOutputs(
concat(
plugins,
stream(javaInfos)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,21 +162,21 @@ private JavaPluginData disableAnnotationProcessing() {
}
}

public static JavaPluginInfo merge(JavaPluginInfo a, JavaPluginInfo b) {
return a.isEmpty() ? b : b.isEmpty() ? a : merge(ImmutableList.of(a, b));
public static JavaPluginInfo mergeWithoutJavaOutputs(JavaPluginInfo a, JavaPluginInfo b) {
return a.isEmpty() ? b : b.isEmpty() ? a : mergeWithoutJavaOutputs(ImmutableList.of(a, b));
}

public static JavaPluginInfo merge(Iterable<JavaPluginInfo> providers) {
public static JavaPluginInfo mergeWithoutJavaOutputs(Iterable<JavaPluginInfo> providers) {
List<JavaPluginData> plugins = new ArrayList<>();
List<JavaPluginData> apiGeneratingPlugins = new ArrayList<>();
ImmutableList.Builder<JavaOutput> outputs = ImmutableList.builder();
for (JavaPluginInfo provider : providers) {
plugins.add(provider.plugins());
apiGeneratingPlugins.add(provider.apiGeneratingPlugins());
outputs.addAll(provider.getJavaOutputs());
}
return new AutoValue_JavaPluginInfo(
outputs.build(), JavaPluginData.merge(plugins), JavaPluginData.merge(apiGeneratingPlugins));
ImmutableList.of(),
JavaPluginData.merge(plugins),
JavaPluginData.merge(apiGeneratingPlugins));
}

public static JavaPluginInfo create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public ConfiguredTarget create(RuleContext ruleContext)
}

JavaPluginInfo javaPluginInfo =
JavaPluginInfo.merge(
JavaPluginInfo.mergeWithoutJavaOutputs(
ruleContext.getPrerequisites(":java_plugins", JavaPluginInfo.PROVIDER));

return new RuleConfiguredTargetBuilder(ruleContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public Builder addResourceJars(NestedSet<Artifact> resourceJars) {

public Builder addPlugin(JavaPluginInfo plugins) {
Preconditions.checkArgument(!built);
this.plugins = JavaPluginInfo.merge(this.plugins, plugins);
this.plugins = JavaPluginInfo.mergeWithoutJavaOutputs(this.plugins, plugins);
return this;
}

Expand Down

0 comments on commit 5cf1d6e

Please sign in to comment.