Skip to content

Commit

Permalink
Remove legacy java provider (JavaStarlarkApiProvider.java)
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 338678387
  • Loading branch information
c-mita authored and copybara-github committed Oct 23, 2020
1 parent 8946cc1 commit c58f966
Show file tree
Hide file tree
Showing 15 changed files with 0 additions and 128 deletions.
1 change: 0 additions & 1 deletion site/docs/bazel-and-java.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ when building your Java projects:

* Providers:

* [`java`](skylark/lib/JavaStarlarkApiProvider.html)
* [`JavaInfo`](skylark/lib/JavaInfo.html)

## Configuring the JDK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import com.google.devtools.build.lib.rules.java.JavaSemantics;
import com.google.devtools.build.lib.rules.java.JavaSourceInfoProvider;
import com.google.devtools.build.lib.rules.java.JavaSourceJarsProvider;
import com.google.devtools.build.lib.rules.java.JavaStarlarkApiProvider;
import com.google.devtools.build.lib.rules.java.JavaToolchainProvider;
import com.google.devtools.build.lib.starlarkbuildapi.android.DataBindingV2ProviderApi;
import com.google.devtools.build.lib.vfs.PathFragment;
Expand Down Expand Up @@ -241,8 +240,6 @@ public ConfiguredTarget create(RuleContext ruleContext)

ruleBuilder
.setFilesToBuild(filesToBuild)
.addStarlarkTransitiveInfo(
JavaStarlarkApiProvider.NAME, JavaStarlarkApiProvider.fromRuleContext())
.addProvider(RunfilesProvider.class, RunfilesProvider.EMPTY)
.addNativeDeclaredProvider(dataBindingV2Provider)
.addNativeDeclaredProvider(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
import com.google.devtools.build.lib.rules.java.JavaRuleOutputJarsProvider.OutputJar;
import com.google.devtools.build.lib.rules.java.JavaSemantics;
import com.google.devtools.build.lib.rules.java.JavaSourceJarsProvider;
import com.google.devtools.build.lib.rules.java.JavaStarlarkApiProvider;
import com.google.devtools.build.lib.rules.java.JavaTargetAttributes;
import com.google.devtools.build.lib.rules.java.JavaUtil;
import com.google.devtools.build.lib.rules.java.proto.GeneratedExtensionRegistryProvider;
Expand Down Expand Up @@ -704,8 +703,6 @@ public RuleConfiguredTargetBuilder addTransitiveInfoProviders(

return builder
.setFilesToBuild(filesToBuild)
.addStarlarkTransitiveInfo(
JavaStarlarkApiProvider.NAME, JavaStarlarkApiProvider.fromRuleContext())
.addNativeDeclaredProvider(javaInfo)
.addProvider(RunfilesProvider.class, RunfilesProvider.simple(getRunfiles()))
.addNativeDeclaredProvider(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
import com.google.devtools.build.lib.rules.java.JavaSemantics;
import com.google.devtools.build.lib.rules.java.JavaSourceInfoProvider;
import com.google.devtools.build.lib.rules.java.JavaSourceJarsProvider;
import com.google.devtools.build.lib.rules.java.JavaStarlarkApiProvider;
import com.google.devtools.build.lib.rules.java.JavaTargetAttributes;
import com.google.devtools.build.lib.rules.java.JavaToolchainProvider;
import com.google.devtools.build.lib.rules.java.OneVersionCheckActionBuilder;
Expand Down Expand Up @@ -361,8 +360,6 @@ public ConfiguredTarget create(RuleContext ruleContext)

return builder
.setFilesToBuild(filesToBuild)
.addStarlarkTransitiveInfo(
JavaStarlarkApiProvider.NAME, JavaStarlarkApiProvider.fromRuleContext())
.addNativeDeclaredProvider(javaInfo)
.addProvider(
RunfilesProvider.class,
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/google/devtools/build/lib/rules/java/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ java_library(
"JavaSemantics.java",
"JavaSourceInfoProvider.java",
"JavaSourceJarsProvider.java",
"JavaStarlarkApiProvider.java",
"JavaStarlarkCommon.java",
"JavaStrictCompilationArgsProvider.java",
"JavaTargetAttributes.java",
Expand Down Expand Up @@ -197,7 +196,6 @@ java_library(
"//src/main/java/com/google/devtools/build/lib/analysis:provider_collection",
"//src/main/java/com/google/devtools/build/lib/analysis:rule_definition_environment",
"//src/main/java/com/google/devtools/build/lib/analysis:starlark/args",
"//src/main/java/com/google/devtools/build/lib/analysis:starlark/starlark_api_provider",
"//src/main/java/com/google/devtools/build/lib/analysis:test/instrumented_files_info",
"//src/main/java/com/google/devtools/build/lib/analysis:test/test_configuration",
"//src/main/java/com/google/devtools/build/lib/analysis:transitive_info_collection",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,6 @@ public ConfiguredTarget create(RuleContext ruleContext)
return builder
.setFilesToBuild(filesToBuild)
.addNativeDeclaredProvider(javaInfo)
.addStarlarkTransitiveInfo(
JavaStarlarkApiProvider.NAME, JavaStarlarkApiProvider.fromRuleContext())
.add(RunfilesProvider.class, runfilesProvider)
// The executable to run (below) may be different from the executable for runfiles (the one
// we create the runfiles support object with). On Linux they are the same (it's the same
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ public ConfiguredTarget create(RuleContext ruleContext)

return ruleBuilder
.setFilesToBuild(filesToBuild)
.addStarlarkTransitiveInfo(
JavaStarlarkApiProvider.NAME, JavaStarlarkApiProvider.fromRuleContext())
.addNativeDeclaredProvider(javaInfo)
.add(RunfilesProvider.class, RunfilesProvider.simple(runfiles))
.addNativeDeclaredProvider(new JavaNativeLibraryInfo(transitiveJavaNativeLibraries))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,6 @@ final ConfiguredTarget init(
.build();

builder
.addStarlarkTransitiveInfo(
JavaStarlarkApiProvider.NAME, JavaStarlarkApiProvider.fromRuleContext())
.addProvider(
RunfilesProvider.simple(
JavaCommon.getRunfiles(ruleContext, semantics, javaArtifacts, neverLink)))
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import com.google.devtools.build.lib.rules.java.JavaRuleOutputJarsProvider;
import com.google.devtools.build.lib.rules.java.JavaSemantics;
import com.google.devtools.build.lib.rules.java.JavaSourceJarsProvider;
import com.google.devtools.build.lib.rules.java.JavaStarlarkApiProvider;
import com.google.devtools.build.lib.rules.proto.ProtoCompileActionBuilder;
import com.google.devtools.build.lib.rules.proto.ProtoCompileActionBuilder.Exports;
import com.google.devtools.build.lib.rules.proto.ProtoCompileActionBuilder.Services;
Expand Down Expand Up @@ -108,7 +107,6 @@ public AspectDefinition getDefinition(AspectParameters aspectParameters) {
.advertiseProvider(JavaProtoLibraryAspectProvider.class)
.advertiseProvider(
ImmutableList.of(StarlarkProviderIdentifier.forKey(JavaInfo.PROVIDER.getKey())))
.advertiseProvider(ImmutableList.of(JavaStarlarkApiProvider.STARLARK_NAME))
.add(
attr(JavaProtoAspectCommon.LITE_PROTO_TOOLCHAIN_ATTR, LABEL)
.mandatoryNativeProviders(
Expand Down Expand Up @@ -217,9 +215,7 @@ void addProviders(ConfiguredAspect.Builder aspect) throws InterruptedException {
aspect.addNativeDeclaredProvider(
createCcLinkingInfo(ruleContext, aspectCommon.getProtoRuntimeDeps()));

JavaStarlarkApiProvider starlarkApiProvider = JavaStarlarkApiProvider.fromRuleContext();
aspect
.addStarlarkTransitiveInfo(JavaStarlarkApiProvider.NAME, starlarkApiProvider)
.addNativeDeclaredProvider(javaInfo.build())
.addProvider(
new JavaProtoLibraryAspectProvider(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import com.google.devtools.build.lib.rules.java.JavaRuleOutputJarsProvider;
import com.google.devtools.build.lib.rules.java.JavaRunfilesProvider;
import com.google.devtools.build.lib.rules.java.JavaSourceJarsProvider;
import com.google.devtools.build.lib.rules.java.JavaStarlarkApiProvider;
import com.google.devtools.build.lib.rules.java.JavaStrictCompilationArgsProvider;
import com.google.devtools.build.lib.rules.java.ProguardLibrary;
import com.google.devtools.build.lib.rules.java.ProguardSpecProvider;
Expand Down Expand Up @@ -101,8 +100,6 @@ public ConfiguredTarget create(final RuleContext ruleContext)

return new RuleConfiguredTargetBuilder(ruleContext)
.setFilesToBuild(filesToBuild.build())
.addStarlarkTransitiveInfo(
JavaStarlarkApiProvider.NAME, JavaStarlarkApiProvider.fromRuleContext())
.addProvider(RunfilesProvider.withData(Runfiles.EMPTY, runfiles))
.addOutputGroup(OutputGroupInfo.DEFAULT, NestedSetBuilder.<Artifact>emptySet(STABLE_ORDER))
.addNativeDeclaredProvider(getJavaLiteRuntimeSpec(ruleContext))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import com.google.devtools.build.lib.rules.java.JavaRuleOutputJarsProvider;
import com.google.devtools.build.lib.rules.java.JavaSemantics;
import com.google.devtools.build.lib.rules.java.JavaSourceJarsProvider;
import com.google.devtools.build.lib.rules.java.JavaStarlarkApiProvider;
import com.google.devtools.build.lib.rules.proto.ProtoCompileActionBuilder;
import com.google.devtools.build.lib.rules.proto.ProtoCompileActionBuilder.Exports;
import com.google.devtools.build.lib.rules.proto.ProtoCompileActionBuilder.Services;
Expand Down Expand Up @@ -128,7 +127,6 @@ public AspectDefinition getDefinition(AspectParameters aspectParameters) {
.advertiseProvider(JavaProtoLibraryAspectProvider.class)
.advertiseProvider(
ImmutableList.of(StarlarkProviderIdentifier.forKey(JavaInfo.PROVIDER.getKey())))
.advertiseProvider(ImmutableList.of(JavaStarlarkApiProvider.STARLARK_NAME))
.add(
attr(JavaProtoAspectCommon.SPEED_PROTO_TOOLCHAIN_ATTR, LABEL)
// TODO(carmi): reinstate mandatoryNativeProviders(ProtoLangToolchainProvider)
Expand Down Expand Up @@ -249,9 +247,7 @@ void addProviders(ConfiguredAspect.Builder aspect) throws InterruptedException {
javaInfo.addProvider(JavaCompilationArgsProvider.class, generatedCompilationArgsProvider);
aspect.addNativeDeclaredProvider(
createCcLinkingInfo(ruleContext, aspectCommon.getProtoRuntimeDeps()));
JavaStarlarkApiProvider javaStarlarkApiProvider = JavaStarlarkApiProvider.fromRuleContext();
aspect
.addStarlarkTransitiveInfo(JavaStarlarkApiProvider.NAME, javaStarlarkApiProvider)
.addNativeDeclaredProvider(javaInfo.build())
.addProvider(
new JavaProtoLibraryAspectProvider(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import com.google.devtools.build.lib.rules.java.JavaRuleOutputJarsProvider;
import com.google.devtools.build.lib.rules.java.JavaRunfilesProvider;
import com.google.devtools.build.lib.rules.java.JavaSourceJarsProvider;
import com.google.devtools.build.lib.rules.java.JavaStarlarkApiProvider;
import com.google.devtools.build.lib.rules.java.JavaStrictCompilationArgsProvider;

/** Implementation of the java_proto_library rule. */
Expand Down Expand Up @@ -98,8 +97,6 @@ public ConfiguredTarget create(final RuleContext ruleContext)
RuleConfiguredTargetBuilder result =
new RuleConfiguredTargetBuilder(ruleContext)
.setFilesToBuild(filesToBuild.build())
.addStarlarkTransitiveInfo(
JavaStarlarkApiProvider.NAME, JavaStarlarkApiProvider.fromRuleContext())
.addProvider(RunfilesProvider.withData(Runfiles.EMPTY, runfiles))
.addOutputGroup(
OutputGroupInfo.DEFAULT, NestedSetBuilder.<Artifact>emptySet(STABLE_ORDER))
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -1114,29 +1114,6 @@ public void testJavaProviderFieldsAreStarlarkAccessible() throws Exception {
assertThat(myTransitiveCompileTimeJars).isEqualTo(jlTransitiveCompileTimeJars);
}

@Test
public void testStarlarkApiProviderReexported() throws Exception {
scratch.file(
"java/test/extension.bzl",
"def impl(ctx):",
" dep_java = ctx.attr.dep.java",
" return struct(java = dep_java)",
"my_rule = rule(impl, attrs = { ",
" 'dep' : attr.label(), ",
"})");
scratch.file(
"java/test/BUILD",
"load(':extension.bzl', 'my_rule')",
"java_library(name = 'jl', srcs = ['Jl.java'])",
"my_rule(name = 'my', dep = ':jl')");
// Now, get that information and ensure it is equal to what the jl java_library
// was presenting
ConfiguredTarget myConfiguredTarget = getConfiguredTarget("//java/test:my");
ConfiguredTarget javaLibraryTarget = getConfiguredTarget("//java/test:jl");

assertThat(myConfiguredTarget.get("java")).isSameInstanceAs(javaLibraryTarget.get("java"));
}

@Test
public void javaProviderExposedOnJavaLibrary() throws Exception {
scratch.file(
Expand Down

0 comments on commit c58f966

Please sign in to comment.