use of com.google.devtools.build.lib.rules.java.JavaConfiguration.JavaClasspathMode in project bazel by bazelbuild.
the class JavaCompilationHelper method addLibrariesToAttributes.
/**
* Adds the compile time and runtime Java libraries in the transitive closure
* of the deps to the attributes.
*
* @param deps the dependencies to be included as roots of the transitive
* closure
*/
public void addLibrariesToAttributes(Iterable<? extends TransitiveInfoCollection> deps) {
// Enforcing strict Java dependencies: when the --strict_java_deps flag is
// WARN or ERROR, or is DEFAULT and strict_java_deps attribute is unset,
// we use a stricter javac compiler to perform direct deps checks.
attributes.setStrictJavaDeps(getStrictJavaDeps());
addLibrariesToAttributesInternal(deps);
JavaClasspathMode classpathMode = getJavaConfiguration().getReduceJavaClasspath();
if (isStrict() && classpathMode != JavaClasspathMode.OFF) {
List<JavaCompilationArgsProvider> compilationArgsProviders = new LinkedList<>();
for (TransitiveInfoCollection dep : deps) {
JavaCompilationArgsProvider provider = JavaProvider.getProvider(JavaCompilationArgsProvider.class, dep);
if (provider != null) {
compilationArgsProviders.add(provider);
}
}
addDependencyArtifactsToAttributes(attributes, compilationArgsProviders);
}
}
Aggregations