src/com/facebook/buck/infer/InferNullsafe.java
/**
   * Builds {@link InferNullsafe} rule with a properly setup dependency on base library.
   *
   * <p>Requires {@code javacOptions} to have fully configured {code bootclasspath}. For Android
   * bootclasspath usually provided separately via {@code extraClasspathProviderSupplier}.
   */
Builds  InferNullsafe rule with a properly setup dependency on base library.
Requires  javacOptions to have fully configured {code bootclasspath}. For Android
bootclasspath usually provided separately via  extraClasspathProviderSupplier.
Builds InferNullsafe rule with a properly setup dependency on base library . Requires javacOptions to have fully configured { code bootclasspath } . For Android bootclasspath usually provided separately via extraClasspathProviderSupplier .
public static InferNullsafe create(
      BuildTarget buildTarget,
      ProjectFilesystem projectFilesystem,
      ActionGraphBuilder graphBuilder,
      JavacOptions javacOptions,
      Optional<ExtraClasspathProvider> extraClasspathProvider,
      UnresolvedInferPlatform unresolvedInferPlatform,
      InferConfig config) {
    BuildTarget unflavored = buildTarget.withoutFlavors();
    JavaLibrary baseLibrary = (JavaLibrary) graphBuilder.requireRule(unflavored);
    ImmutableSortedSet<SourcePath> sources = baseLibrary.getJavaSrcs();
    ImmutableSortedSet.Builder<SourcePath> directClasspathBuilder =
        ImmutableSortedSet.naturalOrder();
    baseLibrary
        .getDepsForTransitiveClasspathEntries()
        .forEach(
            dep -> {
              if (dep instanceof JavaLibrary) {
                directClasspathBuilder.addAll(
                    JavaLibraryClasspathProvider.getOutputClasspathJars(
                        (JavaLibrary) dep, Optional.ofNullable(dep.getSourcePathToOutput())));
              }
            });
    directClasspathBuilder.addAll(
        JavaLibraryClasspathProvider.getOutputClasspathJars(baseLibrary, Optional.empty()));
    ImmutableSortedSet<SourcePath> directClasspath = directClasspathBuilder.build();
    SourcePath outputJar = baseLibrary.getSourcePathToOutput();
    InferPlatform platform =
        unresolvedInferPlatform.resolve(graphBuilder, buildTarget.getTargetConfiguration());
    return new InferNullsafe(
        buildTarget,
        projectFilesystem,
        graphBuilder,
        new Impl(
            platform,
            config.getNullsafeArgs(),
            sources,
            directClasspath,
            javacOptions,
            extraClasspathProvider,
            outputJar));
  }
public static InferNullsafe create ( BuildTarget buildTarget , ProjectFilesystem projectFilesystem , ActionGraphBuilder graphBuilder , JavacOptions javacOptions , Optional < ExtraClasspathProvider > extraClasspathProvider , UnresolvedInferPlatform unresolvedInferPlatform , InferConfig config ) { BuildTarget unflavored = buildTarget . withoutFlavors ( ) ; JavaLibrary baseLibrary = ( JavaLibrary ) graphBuilder . requireRule ( unflavored ) ; ImmutableSortedSet < SourcePath > sources = baseLibrary . getJavaSrcs ( ) ; ImmutableSortedSet . Builder < SourcePath > directClasspathBuilder = ImmutableSortedSet . naturalOrder ( ) ; baseLibrary . getDepsForTransitiveClasspathEntries ( ) . forEach ( dep -> { if ( dep instanceof JavaLibrary ) { directClasspathBuilder . addAll ( JavaLibraryClasspathProvider . getOutputClasspathJars ( ( JavaLibrary ) dep , Optional . ofNullable ( dep . getSourcePathToOutput ( ) ) ) ) ; } } ) ; directClasspathBuilder . addAll ( JavaLibraryClasspathProvider . getOutputClasspathJars ( baseLibrary , Optional . empty ( ) ) ) ; ImmutableSortedSet < SourcePath > directClasspath = directClasspathBuilder . build ( ) ; SourcePath outputJar = baseLibrary . getSourcePathToOutput ( ) ; InferPlatform platform = unresolvedInferPlatform . resolve ( graphBuilder , buildTarget . getTargetConfiguration ( ) ) ; return new InferNullsafe ( buildTarget , projectFilesystem , graphBuilder , new Impl ( platform , config . getNullsafeArgs ( ) , sources , directClasspath , javacOptions , extraClasspathProvider , outputJar ) ) ; }
Builds {@link InferNullsafe} rule with a properly setup dependency on base library.
Builds { @link InferNullsafe } rule with a properly setup dependency on base library .
// Add only those dependencies that contribute to "direct" classpath of base library. // This includes direct deps and exported deps of direct deps. // Add exported deps of base lib into classpath (since 2nd argument is empty the result doesn't // include the lib itself).