private boolean validateCompilerConfiguration()

in src/main/java/com/intellij/compiler/impl/InternalCompileDriver.java [573:666]


    private boolean validateCompilerConfiguration(final CompileScope scope) {
        try {
            final Module[] scopeModules = scope.getAffectedModules();
            final List<String> modulesWithoutOutputPathSpecified = new ArrayList<>();
            final List<String> modulesWithoutJdkAssigned = new ArrayList<>();
            final CompilerManager compilerManager = CompilerManager.getInstance(myProject);
            boolean projectSdkNotSpecified = false;
            boolean projectOutputNotSpecified = false;
            for (final Module module : scopeModules) {
                if (!compilerManager.isValidationEnabled(module)) {
                    continue;
                }
                final boolean hasSources = hasSources(module, JavaSourceRootType.SOURCE);
                final boolean hasTestSources = hasSources(module, JavaSourceRootType.TEST_SOURCE);
                if (!hasSources && !hasTestSources) {
                    // If module contains no sources, shouldn't have to select JDK or output directory (SCR #19333)
                    // todo still there may be problems with this approach if some generated files are attributed by this module
                    continue;
                }
                final Sdk jdk = ModuleRootManager.getInstance(module).getSdk();
                if (jdk == null) {
                    projectSdkNotSpecified |= ModuleRootManager.getInstance(module).isSdkInherited();
                    modulesWithoutJdkAssigned.add(module.getName());
                }
                final String outputPath = getModuleOutputPath(module, false);
                final String testsOutputPath = getModuleOutputPath(module, true);
                if (outputPath == null && testsOutputPath == null) {
                    CompilerModuleExtension compilerExtension = CompilerModuleExtension.getInstance(module);
                    projectOutputNotSpecified |= compilerExtension != null && compilerExtension.isCompilerOutputPathInherited();
                    modulesWithoutOutputPathSpecified.add(module.getName());
                }
                else {
                    if (outputPath == null) {
                        if (hasSources) {
                            modulesWithoutOutputPathSpecified.add(module.getName());
                        }
                    }
                    if (testsOutputPath == null) {
                        if (hasTestSources) {
                            modulesWithoutOutputPathSpecified.add(module.getName());
                        }
                    }
                }
            }
            if (!modulesWithoutJdkAssigned.isEmpty()) {
                System.err.println(String.format("The following modules do not have assigned jdk [%s]", modulesWithoutJdkAssigned));
                return false;
            }

            if (!modulesWithoutOutputPathSpecified.isEmpty()) {
                System.err.println(String.format("The following modules do not have specified path [%s]", modulesWithoutOutputPathSpecified));
                return false;
            }

            final List<Chunk<ModuleSourceSet>> chunks = ModuleCompilerUtil.getCyclicDependencies(myProject, Arrays.asList(scopeModules));
            for (final Chunk<ModuleSourceSet> chunk : chunks) {
                final Set<ModuleSourceSet> sourceSets = chunk.getNodes();
                if (sourceSets.size() <= 1) {
                    continue; // no need to check one-module chunks
                }
                Sdk jdk = null;
                LanguageLevel languageLevel = null;
                for (final ModuleSourceSet sourceSet : sourceSets) {
                    Module module = sourceSet.getModule();
                    final Sdk moduleJdk = ModuleRootManager.getInstance(module).getSdk();
                    if (jdk == null) {
                        jdk = moduleJdk;
                    }
                    else {
                        if (!jdk.equals(moduleJdk)) {
                            showCyclicModulesHaveDifferentJdksError(ModuleSourceSet.getModules(sourceSets));
                            return false;
                        }
                    }

                    LanguageLevel moduleLanguageLevel = EffectiveLanguageLevelUtil.getEffectiveLanguageLevel(module);
                    if (languageLevel == null) {
                        languageLevel = moduleLanguageLevel;
                    }
                    else {
                        if (!languageLevel.equals(moduleLanguageLevel)) {
                            showCyclicModulesHaveDifferentLanguageLevel(ModuleSourceSet.getModules(sourceSets));
                            return false;
                        }
                    }
                }
            }
            return true;
        }
        catch (Throwable e) {
            LOG.info(e);
            return false;
        }
    }