Search in sources :

Example 1 with JpsJavaClasspathKind

use of org.jetbrains.jps.model.java.JpsJavaClasspathKind in project intellij-community by JetBrains.

the class FSOperations method markDirtyRecursively.

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<>(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;
                    }
                }
            }
        }
    }
    if (JavaBuilderUtil.isCompileJavaIncrementally(context)) {
        // mark as non-incremental only the module that triggered non-incremental change
        for (ModuleBuildTarget target : targets) {
            if (!isMarkedDirty(context, target)) {
                // if the target was marked dirty already, all its files were compiled, so
                // it makes no sense to mark it non-incremental
                context.markNonIncremental(target);
            }
        }
    }
    removeTargetsAlreadyMarkedDirty(context, dirtyTargets);
    final Timestamps timestamps = context.getProjectDescriptor().timestamps.getStorage();
    for (ModuleBuildTarget target : dirtyTargets) {
        markDirtyFiles(context, target, round, timestamps, true, null, filter);
    }
}
Also used : Timestamps(org.jetbrains.jps.incremental.storage.Timestamps) JpsModule(org.jetbrains.jps.model.module.JpsModule) BuildTargetChunk(org.jetbrains.jps.builders.impl.BuildTargetChunk) JpsJavaClasspathKind(org.jetbrains.jps.model.java.JpsJavaClasspathKind) THashSet(gnu.trove.THashSet) HashSet(java.util.HashSet)

Aggregations

THashSet (gnu.trove.THashSet)1 HashSet (java.util.HashSet)1 BuildTargetChunk (org.jetbrains.jps.builders.impl.BuildTargetChunk)1 Timestamps (org.jetbrains.jps.incremental.storage.Timestamps)1 JpsJavaClasspathKind (org.jetbrains.jps.model.java.JpsJavaClasspathKind)1 JpsModule (org.jetbrains.jps.model.module.JpsModule)1