예제 #1
0
  public static ImmutableSet<Path> createPackageLookupPathSet(IjModuleGraph moduleGraph) {
    ImmutableSet.Builder<Path> builder = ImmutableSet.builder();

    for (IjModule module : moduleGraph.getModuleNodes()) {
      for (IjFolder folder : module.getFolders()) {
        if (!folder.getWantsPackagePrefix()) {
          continue;
        }
        Optional<Path> firstJavaFile =
            FluentIterable.from(folder.getInputs())
                .filter(
                    new Predicate<Path>() {
                      @Override
                      public boolean apply(Path input) {
                        return input.getFileName().toString().endsWith(".java");
                      }
                    })
                .first();
        if (firstJavaFile.isPresent()) {
          builder.add(firstJavaFile.get());
        }
      }
    }

    return builder.build();
  }
예제 #2
0
  private static ImmutableSet<IjModule> createModulesToBeWritten(IjModuleGraph graph) {
    Path rootModuleBasePath = Paths.get("");
    boolean hasRootModule =
        FluentIterable.from(graph.getModuleNodes())
            .transform(IjModule.TO_MODULE_BASE_PATH)
            .contains(rootModuleBasePath);

    ImmutableSet<IjModule> supplementalModules = ImmutableSet.of();
    if (!hasRootModule) {
      supplementalModules =
          ImmutableSet.of(
              IjModule.builder()
                  .setModuleBasePath(rootModuleBasePath)
                  .setTargets(ImmutableSet.<TargetNode<?>>of())
                  .build());
    }

    return FluentIterable.from(graph.getModuleNodes()).append(supplementalModules).toSet();
  }
예제 #3
0
  public ImmutableSet<DependencyEntry> getDependencies(IjModule module) {
    ImmutableMap<IjProjectElement, IjModuleGraph.DependencyType> deps =
        moduleGraph.getDepsFor(module);
    IjDependencyListBuilder dependencyListBuilder = new IjDependencyListBuilder();

    for (Map.Entry<IjProjectElement, IjModuleGraph.DependencyType> entry : deps.entrySet()) {
      IjProjectElement element = entry.getKey();
      IjModuleGraph.DependencyType dependencyType = entry.getValue();
      element.addAsDependency(dependencyType, dependencyListBuilder);
    }
    return dependencyListBuilder.build();
  }
예제 #4
0
 public IjProjectTemplateDataPreparer(
     JavaPackageFinder javaPackageFinder,
     IjModuleGraph moduleGraph,
     ProjectFilesystem projectFilesystem) {
   this.javaPackageFinder = javaPackageFinder;
   this.moduleGraph = moduleGraph;
   this.projectFilesystem = projectFilesystem;
   this.sourceRootSimplifier = new IjSourceRootSimplifier(javaPackageFinder);
   this.modulesToBeWritten = createModulesToBeWritten(moduleGraph);
   this.librariesToBeWritten =
       FluentIterable.from(moduleGraph.getNodes()).filter(IjLibrary.class).toSet();
   this.filesystemTraversalBoundaryPaths =
       createFilesystemTraversalBoundaryPathSet(modulesToBeWritten);
   this.referencedFolderPaths = createReferencedFolderPathsSet(modulesToBeWritten);
 }