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(); }
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(); }
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(); }
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); }