public static Set<JpsModule> getModulesWithDependentsRecursively( final JpsModule module, final boolean includeTests) { return JpsJavaExtensionService.dependencies(module) .includedIn(JpsJavaClasspathKind.compile(includeTests)) .recursively() .getModules(); }
/** * @param chunk * @return mapping "sourceRoot" -> "package prefix" Package prefix uses slashes instead of dots * and ends with trailing slash */ public static Map<File, String> getSourceRootsWithDependents(ModuleChunk chunk) { final boolean includeTests = chunk.containsTests(); final Map<File, String> result = new LinkedHashMap<File, String>(); processModulesRecursively( chunk, JpsJavaClasspathKind.compile(includeTests), new Consumer<JpsModule>() { @Override public void consume(JpsModule module) { for (JpsModuleSourceRoot root : module.getSourceRoots()) { if (root.getRootType().equals(JavaSourceRootType.SOURCE) || includeTests && root.getRootType().equals(JavaSourceRootType.TEST_SOURCE)) { JavaSourceRootProperties properties = (JavaSourceRootProperties) ((JpsSimpleElement<?>) root.getProperties()).getData(); String prefix = properties.getPackagePrefix(); if (!prefix.isEmpty()) { prefix = prefix.replace('.', '/'); if (!prefix.endsWith("/")) { prefix += "/"; } } else { prefix = null; } result.put(JpsPathUtil.urlToFile(root.getUrl()), prefix); } } } }); return result; }
public Collection<File> getCompilationClasspath( ModuleChunk chunk, boolean excludeMainModuleOutput) { return getClasspathFiles( chunk, JpsJavaClasspathKind.compile(chunk.containsTests()), excludeMainModuleOutput, ClasspathPart.AFTER_JDK, true); }
public List<String> moduleRuntimeClasspath(JpsModule module, boolean forTests) { JpsJavaDependenciesEnumerator enumerator = JpsJavaExtensionService.dependencies(module) .recursively() .includedIn(JpsJavaClasspathKind.runtime(forTests)); Collection<File> roots = enumerator.classes().getRoots(); List<String> result = new ArrayList<String>(); for (File root : roots) { result.add(root.getAbsolutePath()); } return result; }
private static Set<String> getModuleDependencies(JpsModule module, boolean includeTests) { Set<JpsModule> modules = JpsJavaExtensionService.dependencies(module) .recursively() .includedIn(JpsJavaClasspathKind.compile(includeTests)) .getModules(); Set<String> names = new HashSet<String>(); for (JpsModule depModule : modules) { names.add(depModule.getName()); } return names; }
public Collection<File> getCompilationClasspathFiles( ModuleChunk chunk, boolean includeTests, final boolean excludeMainModuleOutput, final boolean exportedOnly) { return getClasspathFiles( chunk, JpsJavaClasspathKind.compile(includeTests), excludeMainModuleOutput, ClasspathPart.WHOLE, exportedOnly); }
public static void markDirtyRecursively( CompileContext context, final CompilationRound round, ModuleChunk chunk, @Nullable FileFilter filter) throws IOException { Set<JpsModule> modules = chunk.getModules(); Set<ModuleBuildTarget> targets = chunk.getTargets(); final Set<ModuleBuildTarget> dirtyTargets = new HashSet<ModuleBuildTarget>(targets); // now mark all modules that depend on dirty modules final JpsJavaClasspathKind classpathKind = JpsJavaClasspathKind.compile(chunk.containsTests()); boolean found = false; for (BuildTargetChunk targetChunk : context.getProjectDescriptor().getBuildTargetIndex().getSortedTargetChunks(context)) { if (!found) { if (targetChunk.getTargets().equals(chunk.getTargets())) { found = true; } } else { for (final BuildTarget<?> target : targetChunk.getTargets()) { if (target instanceof ModuleBuildTarget) { final Set<JpsModule> deps = getDependentModulesRecursively( ((ModuleBuildTarget) target).getModule(), classpathKind); if (ContainerUtil.intersects(deps, modules)) { for (BuildTarget<?> buildTarget : targetChunk.getTargets()) { if (buildTarget instanceof ModuleBuildTarget) { dirtyTargets.add((ModuleBuildTarget) buildTarget); } } break; } } } } } removeTargetsAlreadyMarkedDirty(context, dirtyTargets); final Timestamps timestamps = context.getProjectDescriptor().timestamps.getStorage(); for (ModuleBuildTarget target : dirtyTargets) { markDirtyFiles(context, target, round, timestamps, true, null, filter); } if (JavaBuilderUtil.isCompileJavaIncrementally(context)) { // mark as non-incremental only the module that triggered non-incremental change for (ModuleBuildTarget target : targets) { context.markNonIncremental(target); } } }
public static Collection<File> getOutputPathsWithDependents(final ModuleChunk chunk) { final boolean forTests = chunk.containsTests(); final Set<File> sourcePaths = new LinkedHashSet<File>(); processModulesRecursively( chunk, JpsJavaClasspathKind.compile(forTests), new Consumer<JpsModule>() { @Override public void consume(JpsModule module) { addFile( sourcePaths, JpsJavaExtensionService.getInstance().getOutputUrl(module, forTests)); } }); return sourcePaths; }