Skip to content

Commit 01a46f0

Browse files
comiuscopybara-github
authored andcommitted
Remove incompatible_enable_exports_provider flag and JavaExportsProvider.
RELNOTES[inc]: JavaInfo.transitive_exports has been removed (collect export labels using an aspect). PiperOrigin-RevId: 413404779
1 parent dde1b4a commit 01a46f0

File tree

13 files changed

+6
-274
lines changed

13 files changed

+6
-274
lines changed

src/main/java/com/google/devtools/build/lib/packages/semantics/BuildLanguageOptions.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,6 @@ public final class BuildLanguageOptions extends OptionsBase {
145145
help = "If set to true, enables the APIs required to support the Android Starlark migration.")
146146
public boolean experimentalEnableAndroidMigrationApis;
147147

148-
@Option(
149-
name = "incompatible_enable_exports_provider",
150-
defaultValue = "false",
151-
documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS,
152-
effectTags = {OptionEffectTag.BUILD_FILE_SEMANTICS, OptionEffectTag.LOADING_AND_ANALYSIS},
153-
metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE},
154-
help = "This flag enables exports provider and JavaInfo.transitive_exports call.")
155-
public boolean incompatibleEnableExportsProvider;
156-
157148
@Option(
158149
name = "incompatible_existing_rules_immutable_view",
159150
defaultValue = "false",
@@ -569,7 +560,6 @@ public StarlarkSemantics toStarlarkSemantics() {
569560
.set(EXPERIMENTAL_BUILTINS_INJECTION_OVERRIDE, experimentalBuiltinsInjectionOverride)
570561
.setBool(
571562
EXPERIMENTAL_ENABLE_ANDROID_MIGRATION_APIS, experimentalEnableAndroidMigrationApis)
572-
.setBool(INCOMPATIBLE_ENABLE_EXPORTS_PROVIDER, incompatibleEnableExportsProvider)
573563
.setBool(
574564
INCOMPATIBLE_EXISTING_RULES_IMMUTABLE_VIEW, incompatibleExistingRulesImmutableView)
575565
.setBool(EXPERIMENTAL_GOOGLE_LEGACY_API, experimentalGoogleLegacyApi)
@@ -640,8 +630,6 @@ public StarlarkSemantics toStarlarkSemantics() {
640630
"-experimental_disable_external_package";
641631
public static final String EXPERIMENTAL_ENABLE_ANDROID_MIGRATION_APIS =
642632
"-experimental_enable_android_migration_apis";
643-
public static final String INCOMPATIBLE_ENABLE_EXPORTS_PROVIDER =
644-
"-incompatible_enable_exports_provider";
645633
public static final String INCOMPATIBLE_EXISTING_RULES_IMMUTABLE_VIEW =
646634
"-incompatible_existing_rules_immutable_view";
647635
public static final String EXPERIMENTAL_GOOGLE_LEGACY_API = "-experimental_google_legacy_api";

src/main/java/com/google/devtools/build/lib/rules/java/BUILD

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ java_library(
7272
"//src/main/java/com/google/devtools/build/lib/collect/nestedset",
7373
"//src/main/java/com/google/devtools/build/lib/concurrent",
7474
"//src/main/java/com/google/devtools/build/lib/packages",
75-
"//src/main/java/com/google/devtools/build/lib/packages/semantics",
7675
"//src/main/java/com/google/devtools/build/lib/rules/apple",
7776
"//src/main/java/com/google/devtools/build/lib/rules/cpp",
7877
"//src/main/java/com/google/devtools/build/lib/rules/proto",
@@ -129,7 +128,6 @@ java_library(
129128
"JavaCompileActionContext.java",
130129
"JavaCompileOutputs.java",
131130
"JavaConfiguration.java",
132-
"JavaExportsProvider.java",
133131
"JavaGenJarsProvider.java",
134132
"JavaHeaderCompileActionBuilder.java",
135133
"JavaHelper.java",
@@ -197,7 +195,6 @@ java_library(
197195
"//src/main/java/com/google/devtools/build/lib/concurrent",
198196
"//src/main/java/com/google/devtools/build/lib/exec:spawn_strategy_resolver",
199197
"//src/main/java/com/google/devtools/build/lib/packages",
200-
"//src/main/java/com/google/devtools/build/lib/packages/semantics",
201198
"//src/main/java/com/google/devtools/build/lib/rules/cpp",
202199
"//src/main/java/com/google/devtools/build/lib/shell",
203200
"//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec",

src/main/java/com/google/devtools/build/lib/rules/java/JavaCommon.java

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
package com.google.devtools.build.lib.rules.java;
1515

1616
import static com.google.common.collect.ImmutableList.toImmutableList;
17-
import static com.google.devtools.build.lib.packages.semantics.BuildLanguageOptions.INCOMPATIBLE_ENABLE_EXPORTS_PROVIDER;
1817

1918
import com.google.common.base.Preconditions;
2019
import com.google.common.collect.ImmutableList;
@@ -37,7 +36,6 @@
3736
import com.google.devtools.build.lib.analysis.test.InstrumentedFilesCollector;
3837
import com.google.devtools.build.lib.analysis.test.InstrumentedFilesCollector.InstrumentationSpec;
3938
import com.google.devtools.build.lib.analysis.test.InstrumentedFilesInfo;
40-
import com.google.devtools.build.lib.cmdline.Label;
4139
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
4240
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
4341
import com.google.devtools.build.lib.collect.nestedset.Order;
@@ -337,24 +335,6 @@ public NestedSet<Artifact> collectTransitiveSourceJars(Iterable<Artifact> target
337335
return builder.build();
338336
}
339337

340-
/** Collects labels of targets and artifacts reached transitively via the "exports" attribute. */
341-
protected JavaExportsProvider collectTransitiveExports() {
342-
NestedSetBuilder<Label> builder = NestedSetBuilder.stableOrder();
343-
List<TransitiveInfoCollection> currentRuleExports = getExports(ruleContext);
344-
345-
builder.addAll(Iterables.transform(currentRuleExports, TransitiveInfoCollection::getLabel));
346-
347-
for (TransitiveInfoCollection dep : currentRuleExports) {
348-
JavaExportsProvider exportsProvider = JavaInfo.getProvider(JavaExportsProvider.class, dep);
349-
350-
if (exportsProvider != null) {
351-
builder.addTransitive(exportsProvider.getTransitiveExports());
352-
}
353-
}
354-
355-
return new JavaExportsProvider(builder.build());
356-
}
357-
358338
public final void initializeJavacOpts() {
359339
Preconditions.checkState(javacOpts == null);
360340
javacOpts = computeJavacOpts(getCompatibleJavacOptions());
@@ -667,7 +647,6 @@ public void addTransitiveInfoProviders(
667647

668648
JavaCompilationInfoProvider compilationInfoProvider = createCompilationInfoProvider();
669649

670-
671650
builder
672651
.addNativeDeclaredProvider(
673652
getInstrumentationFilesProvider(
@@ -678,13 +657,6 @@ public void addTransitiveInfoProviders(
678657
coverageSupportFiles))
679658
.addOutputGroup(OutputGroupInfo.FILES_TO_COMPILE, getFilesToCompile(classJar));
680659

681-
if (ruleContext
682-
.getAnalysisEnvironment()
683-
.getStarlarkSemantics()
684-
.getBool(INCOMPATIBLE_ENABLE_EXPORTS_PROVIDER)) {
685-
JavaExportsProvider exportsProvider = collectTransitiveExports();
686-
javaInfoBuilder.addProvider(JavaExportsProvider.class, exportsProvider);
687-
}
688660
javaInfoBuilder.addProvider(JavaCompilationInfoProvider.class, compilationInfoProvider);
689661

690662
addCcRelatedProviders(javaInfoBuilder);

src/main/java/com/google/devtools/build/lib/rules/java/JavaExportsProvider.java

Lines changed: 0 additions & 54 deletions
This file was deleted.

src/main/java/com/google/devtools/build/lib/rules/java/JavaInfo.java

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
package com.google.devtools.build.lib.rules.java;
1515

1616
import static com.google.common.collect.ImmutableList.toImmutableList;
17-
import static com.google.devtools.build.lib.packages.semantics.BuildLanguageOptions.INCOMPATIBLE_ENABLE_EXPORTS_PROVIDER;
1817

1918
import com.google.common.base.Preconditions;
2019
import com.google.common.collect.ImmutableList;
@@ -26,7 +25,6 @@
2625
import com.google.devtools.build.lib.analysis.TransitiveInfoProvider;
2726
import com.google.devtools.build.lib.analysis.TransitiveInfoProviderMap;
2827
import com.google.devtools.build.lib.analysis.TransitiveInfoProviderMapBuilder;
29-
import com.google.devtools.build.lib.cmdline.Label;
3028
import com.google.devtools.build.lib.collect.nestedset.Depset;
3129
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
3230
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
@@ -77,7 +75,6 @@ private static <T> T nullIfNone(Object object, Class<T> type) {
7775
JavaSourceJarsProvider.class,
7876
JavaRuleOutputJarsProvider.class,
7977
JavaGenJarsProvider.class,
80-
JavaExportsProvider.class,
8178
JavaCompilationInfoProvider.class,
8279
JavaCcInfoProvider.class);
8380

@@ -123,7 +120,7 @@ public JavaPluginInfo getJavaPluginInfo() {
123120
* Merges the given providers into one {@link JavaInfo}. All the providers with the same type in
124121
* the given list are merged into one provider that is added to the resulting {@link JavaInfo}.
125122
*/
126-
public static JavaInfo merge(List<JavaInfo> providers, boolean withExportsProvider) {
123+
public static JavaInfo merge(List<JavaInfo> providers) {
127124
List<JavaCompilationArgsProvider> javaCompilationArgsProviders =
128125
JavaInfo.fetchProvidersFromList(providers, JavaCompilationArgsProvider.class);
129126
List<JavaSourceJarsProvider> javaSourceJarsProviders =
@@ -163,13 +160,6 @@ public static JavaInfo merge(List<JavaInfo> providers, boolean withExportsProvid
163160
.setRuntimeJars(runtimeJars.build())
164161
.setJavaConstraints(javaConstraints.build());
165162

166-
if (withExportsProvider) {
167-
List<JavaExportsProvider> javaExportsProviders =
168-
JavaInfo.fetchProvidersFromList(providers, JavaExportsProvider.class);
169-
javaInfoBuilder.addProvider(
170-
JavaExportsProvider.class, JavaExportsProvider.merge(javaExportsProviders));
171-
}
172-
173163
return javaInfoBuilder.build();
174164
}
175165

@@ -375,14 +365,6 @@ public NestedSet<Artifact> getTransitiveOnlyRuntimeJars() {
375365
JavaSourceJarsProvider.class, JavaSourceJarsProvider::getTransitiveSourceJars));
376366
}
377367

378-
@Override
379-
public Depset /*<Label>*/ getTransitiveExports() {
380-
return Depset.of(
381-
Depset.ElementType.of(Label.class),
382-
getProviderAsNestedSet(
383-
JavaExportsProvider.class, JavaExportsProvider::getTransitiveExports));
384-
}
385-
386368
/** Returns the transitive set of CC native libraries required by the target. */
387369
public NestedSet<LibraryToLink> getTransitiveNativeLibraries() {
388370
return getProviderAsNestedSet(
@@ -514,8 +496,7 @@ public JavaInfo javaInfo(
514496
Sequence.cast(exports, JavaInfo.class, "exports"),
515497
Sequence.cast(exportedPlugins, JavaPluginInfo.class, "exported_plugins"),
516498
Sequence.cast(nativeLibraries, CcInfo.class, "native_libraries"),
517-
thread.getCallerLocation(),
518-
thread.getSemantics().getBool(INCOMPATIBLE_ENABLE_EXPORTS_PROVIDER));
499+
thread.getCallerLocation());
519500
}
520501
}
521502

src/main/java/com/google/devtools/build/lib/rules/java/JavaInfoBuildHelper.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import static com.google.common.collect.ImmutableList.toImmutableList;
1717
import static com.google.common.collect.Iterables.concat;
1818
import static com.google.common.collect.Streams.stream;
19-
import static com.google.devtools.build.lib.packages.semantics.BuildLanguageOptions.INCOMPATIBLE_ENABLE_EXPORTS_PROVIDER;
2019
import static com.google.devtools.build.lib.rules.java.JavaCompilationArgsProvider.ClasspathType.BOTH;
2120
import static com.google.devtools.build.lib.rules.java.JavaCompilationArgsProvider.ClasspathType.COMPILE_ONLY;
2221
import static com.google.devtools.build.lib.rules.java.JavaCompilationArgsProvider.ClasspathType.RUNTIME_ONLY;
@@ -88,8 +87,7 @@ JavaInfo createJavaInfo(
8887
Sequence<JavaInfo> exports,
8988
Sequence<JavaPluginInfo> exportedPlugins,
9089
Sequence<CcInfo> nativeLibraries,
91-
Location location,
92-
boolean withExportsProvider) {
90+
Location location) {
9391
JavaInfo.Builder javaInfoBuilder = JavaInfo.Builder.create();
9492
javaInfoBuilder.setLocation(location);
9593

@@ -125,10 +123,6 @@ JavaInfo createJavaInfo(
125123
javaInfoBuilder.addProvider(
126124
JavaCompilationArgsProvider.class, javaCompilationArgsBuilder.build());
127125

128-
if (withExportsProvider) {
129-
javaInfoBuilder.addProvider(JavaExportsProvider.class, createJavaExportsProvider(exports));
130-
}
131-
132126
javaInfoBuilder.javaPluginInfo(mergeExportedJavaPluginInfo(exportedPlugins, exports));
133127

134128
javaInfoBuilder.addProvider(
@@ -228,11 +222,6 @@ private Stream<NestedSet<Artifact>> fetchSourceJars(Iterable<JavaInfo> javaInfos
228222
return concat(transitiveSourceJars, sourceJars);
229223
}
230224

231-
private JavaExportsProvider createJavaExportsProvider(Iterable<JavaInfo> exports) {
232-
return JavaExportsProvider.merge(
233-
JavaInfo.fetchProvidersFromList(exports, JavaExportsProvider.class));
234-
}
235-
236225
private JavaPluginInfo mergeExportedJavaPluginInfo(
237226
Iterable<JavaPluginInfo> plugins, Iterable<JavaInfo> javaInfos) {
238227
return JavaPluginInfo.mergeWithoutJavaOutputs(
@@ -348,9 +337,6 @@ public JavaInfo createJavaCompileAction(
348337
streamProviders(deps, JavaCcInfoProvider.class),
349338
Stream.of(new JavaCcInfoProvider(CcInfo.merge(nativeLibraries))))
350339
.collect(toImmutableList());
351-
if (thread.getSemantics().getBool(INCOMPATIBLE_ENABLE_EXPORTS_PROVIDER)) {
352-
javaInfoBuilder.addProvider(JavaExportsProvider.class, createJavaExportsProvider(exports));
353-
}
354340
return javaInfoBuilder
355341
.addProvider(JavaCompilationArgsProvider.class, javaCompilationArgsProvider)
356342
.addProvider(

src/main/java/com/google/devtools/build/lib/rules/java/JavaPluginInfo.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ public JavaPluginInfoApi<Artifact, JavaPluginData, JavaOutput> javaPluginInfo(
6262
? NestedSetBuilder.emptySet(Order.NAIVE_LINK_ORDER)
6363
: NestedSetBuilder.create(Order.NAIVE_LINK_ORDER, (String) processorClass);
6464
JavaInfo javaInfos =
65-
JavaInfo.merge(
66-
Sequence.cast(runtimeDeps, JavaInfo.class, "runtime_deps"),
67-
/*withExportsProvider=*/ false);
65+
JavaInfo.merge(Sequence.cast(runtimeDeps, JavaInfo.class, "runtime_deps"));
6866

6967
NestedSet<Artifact> processorClasspath =
7068
javaInfos.getProvider(JavaCompilationArgsProvider.class).getRuntimeJars();

src/main/java/com/google/devtools/build/lib/rules/java/JavaStarlarkCommon.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
package com.google.devtools.build.lib.rules.java;
1515

1616
import static com.google.common.collect.ImmutableList.toImmutableList;
17-
import static com.google.devtools.build.lib.packages.semantics.BuildLanguageOptions.INCOMPATIBLE_ENABLE_EXPORTS_PROVIDER;
1817

1918
import com.google.common.collect.ImmutableList;
2019
import com.google.common.collect.ImmutableSet;
@@ -217,9 +216,7 @@ public ImmutableList<String> getDefaultJavacOpts(JavaToolchainProvider javaToolc
217216
public JavaInfo mergeJavaProviders(
218217
Sequence<?> providers, /* <JavaInfo> expected. */ StarlarkThread thread)
219218
throws EvalException {
220-
return JavaInfo.merge(
221-
Sequence.cast(providers, JavaInfo.class, "providers"),
222-
thread.getSemantics().getBool(INCOMPATIBLE_ENABLE_EXPORTS_PROVIDER));
219+
return JavaInfo.merge(Sequence.cast(providers, JavaInfo.class, "providers"));
223220
}
224221

225222
// TODO(b/65113771): Remove this method because it's incorrect.

src/main/java/com/google/devtools/build/lib/starlarkbuildapi/java/JavaInfoApi.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
package com.google.devtools.build.lib.starlarkbuildapi.java;
1616

17-
import static com.google.devtools.build.lib.packages.semantics.BuildLanguageOptions.INCOMPATIBLE_ENABLE_EXPORTS_PROVIDER;
18-
1917
import com.google.devtools.build.docgen.annot.DocCategory;
2018
import com.google.devtools.build.docgen.annot.StarlarkConstructor;
2119
import com.google.devtools.build.lib.collect.nestedset.Depset;
@@ -154,13 +152,6 @@ public interface JavaInfoApi<
154152
structField = true)
155153
Depset /*<FileT>*/ getTransitiveSourceJars();
156154

157-
@StarlarkMethod(
158-
name = "transitive_exports",
159-
structField = true,
160-
enableOnlyWithFlag = INCOMPATIBLE_ENABLE_EXPORTS_PROVIDER,
161-
doc = "Returns a set of labels that are being exported from this rule transitively.")
162-
Depset /*<Label>*/ getTransitiveExports();
163-
164155
@StarlarkMethod(
165156
name = "transitive_native_libraries",
166157
structField = true,

src/test/java/com/google/devtools/build/lib/rules/java/JavaInfoRoundtripTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import net.starlark.java.eval.Starlark;
2828
import net.starlark.java.eval.StarlarkList;
2929
import org.junit.Before;
30-
import org.junit.Ignore;
3130
import org.junit.Test;
3231
import org.junit.runner.RunWith;
3332
import org.junit.runners.JUnit4;
@@ -237,9 +236,7 @@ public void roundtipJavaInfo_runtimeDeps() throws Exception {
237236
assertThat((Map<?, ?>) javaInfoB).isEqualTo(javaInfoA);
238237
}
239238

240-
// TODO(b/159269546): enable once JavaInfo call is fixed to return JavaExportsProvider")
241239
@Test
242-
@Ignore
243240
public void roundtipJavaInfo_exports() throws Exception {
244241
scratch.file("bar/BUILD", "java_library(name = 'exportlib', srcs = ['A.java'])");
245242

0 commit comments

Comments
 (0)