Ejemplo n.º 1
0
  @VisibleForTesting
  List<Module> createModulesForProjectConfigs() throws IOException {
    DependencyGraph dependencyGraph = partialGraph.getDependencyGraph();
    List<Module> modules = Lists.newArrayList();

    // Convert the project_config() targets into modules and find the union of all jars passed to
    // no_dx.
    ImmutableSet.Builder<Path> noDxJarsBuilder = ImmutableSet.builder();
    for (BuildTarget target : partialGraph.getTargets()) {
      BuildRule buildRule = dependencyGraph.findBuildRuleByTarget(target);
      ProjectConfig projectConfig = (ProjectConfig) buildRule.getBuildable();

      BuildRule srcRule = projectConfig.getSrcRule();
      if (srcRule != null) {
        Buildable buildable = srcRule.getBuildable();
        if (buildable instanceof AndroidBinary) {
          AndroidBinary androidBinary = (AndroidBinary) buildable;
          AndroidDexTransitiveDependencies binaryDexTransitiveDependencies =
              androidBinary.findDexTransitiveDependencies();
          noDxJarsBuilder.addAll(binaryDexTransitiveDependencies.noDxClasspathEntries);
        }
      }

      Module module = createModuleForProjectConfig(projectConfig);
      modules.add(module);
    }
    ImmutableSet<Path> noDxJars = noDxJarsBuilder.build();

    // Update module dependencies to apply scope="PROVIDED", where appropriate.
    markNoDxJarsAsProvided(modules, noDxJars);

    return modules;
  }
Ejemplo n.º 2
0
 public Project(
     PartialGraph partialGraph,
     Map<String, String> basePathToAliasMap,
     JavaPackageFinder javaPackageFinder,
     ExecutionContext executionContext,
     ProjectFilesystem projectFilesystem,
     Optional<String> pathToDefaultAndroidManifest) {
   this.partialGraph = Preconditions.checkNotNull(partialGraph);
   this.buildFileTree = new BuildFileTree(partialGraph.getTargets());
   this.basePathToAliasMap = ImmutableMap.copyOf(basePathToAliasMap);
   this.javaPackageFinder = Preconditions.checkNotNull(javaPackageFinder);
   this.executionContext = Preconditions.checkNotNull(executionContext);
   this.projectFilesystem = Preconditions.checkNotNull(projectFilesystem);
   this.pathToDefaultAndroidManifest = Preconditions.checkNotNull(pathToDefaultAndroidManifest);
   this.libraryJars = Sets.newHashSet();
 }