Search in sources :

Example 1 with JavaClasspathMode

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);
    }
}
Also used : JavaClasspathMode(com.google.devtools.build.lib.rules.java.JavaConfiguration.JavaClasspathMode) TransitiveInfoCollection(com.google.devtools.build.lib.analysis.TransitiveInfoCollection) LinkedList(java.util.LinkedList)

Aggregations

TransitiveInfoCollection (com.google.devtools.build.lib.analysis.TransitiveInfoCollection)1 JavaClasspathMode (com.google.devtools.build.lib.rules.java.JavaConfiguration.JavaClasspathMode)1 LinkedList (java.util.LinkedList)1