Java: Stops adding C++ providers directly.
unknown commit fixes the only related broken target showing up in a TGP after
this change. It seems that this provider was only ever used through
java_wrap_cc with java_library dependencies which themselves had cc_library
dependencies, i.e. java_wrap_cc -> java_library -> cc_library. This dependency
is not needed, the cc_library can be added directly to java_wrap_cc to get the
same behavior and this is the way it should be done instead of relying on
transitive dependencies.
The reason for making this change right now is that with the Skylark C++ API, I
will be adding attr("deps").mandatoryProviders(CcCompilationInfo,
CcLinkParamsInfo) to C++ rules so that they can take any Skylark rule and not
having to explicitly hard-code the name of those Skylark rules in Blaze.
However, Java meets this criteria and the change would allow C++ rules to
depend on Java. This is not something that was supported before and is not
something we plan to support.
RELNOTES:none
PiperOrigin-RevId: 187158176
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaImport.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaImport.java
index e6192fe..79e2711 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaImport.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaImport.java
@@ -30,7 +30,6 @@
import com.google.devtools.build.lib.analysis.configuredtargets.RuleConfiguredTarget.Mode;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
-import com.google.devtools.build.lib.rules.cpp.CcCompilationInfo;
import com.google.devtools.build.lib.rules.cpp.CcLinkParams;
import com.google.devtools.build.lib.rules.cpp.CcLinkParamsInfo;
import com.google.devtools.build.lib.rules.cpp.CcLinkParamsStore;
@@ -84,7 +83,6 @@
JavaCompilationArtifacts javaArtifacts = collectJavaArtifacts(jars, interfaceJars);
common.setJavaCompilationArtifacts(javaArtifacts);
- CcCompilationInfo transitiveCppDeps = common.collectTransitiveCppDeps();
NestedSet<LinkerInput> transitiveJavaNativeLibraries =
common.collectTransitiveJavaNativeLibraries();
boolean neverLink = JavaCommon.isNeverLink(ruleContext);
@@ -184,7 +182,6 @@
.add(
JavaNativeLibraryProvider.class,
new JavaNativeLibraryProvider(transitiveJavaNativeLibraries))
- .addNativeDeclaredProvider(transitiveCppDeps)
.add(JavaSourceInfoProvider.class, javaSourceInfoProvider)
.add(ProguardSpecProvider.class, new ProguardSpecProvider(proguardSpecs))
.addOutputGroup(JavaSemantics.SOURCE_JARS_OUTPUT_GROUP, transitiveJavaSourceJars)
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaLibrary.java
index 6b8aa79..ed5f32c 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaLibrary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaLibrary.java
@@ -26,7 +26,6 @@
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.collect.nestedset.Order;
-import com.google.devtools.build.lib.rules.cpp.CcCompilationInfo;
import com.google.devtools.build.lib.rules.cpp.CcLinkParams;
import com.google.devtools.build.lib.rules.cpp.CcLinkParamsInfo;
import com.google.devtools.build.lib.rules.cpp.CcLinkParamsStore;
@@ -165,7 +164,6 @@
common.setClassPathFragment(
new ClasspathConfiguredFragment(
javaArtifacts, attributes, neverLink, helper.getBootclasspathOrDefault()));
- CcCompilationInfo transitiveCppDeps = common.collectTransitiveCppDeps();
// If sources are empty, treat this library as a forwarding node for dependencies.
JavaCompilationArgs javaCompilationArgs =
@@ -250,7 +248,6 @@
RunfilesProvider.simple(
JavaCommon.getRunfiles(ruleContext, semantics, javaArtifacts, neverLink)))
.setFilesToBuild(filesToBuild)
- .addNativeDeclaredProvider(transitiveCppDeps)
.addNativeDeclaredProvider(ccLinkParamsInfo)
.addProvider(new JavaNativeLibraryProvider(transitiveJavaNativeLibraries))
.addProvider(JavaSourceInfoProvider.fromJavaTargetAttributes(attributes, semantics))