Search in sources :

Example 1 with JavaModuleType

use of com.intellij.openapi.module.JavaModuleType in project android by JetBrains.

the class AndroidGradleProjectComponent method checkForSupportedModules.

/**
   * Verifies that the project, if it is an Android Gradle project, does not have any modules that are not known by Gradle. For example,
   * when adding a plain IDEA Java module.
   * Do not call this method from {@link ModuleListener#moduleAdded(Project, Module)} because the settings that this method look for are
   * not present when importing a valid Gradle-aware module, resulting in false positives.
   */
public void checkForSupportedModules() {
    Module[] modules = ModuleManager.getInstance(myProject).getModules();
    if (modules.length == 0 || !isBuildWithGradle(myProject)) {
        return;
    }
    List<Module> unsupportedModules = new ArrayList<>();
    for (Module module : modules) {
        ModuleType moduleType = ModuleType.get(module);
        if (moduleType instanceof JavaModuleType) {
            if (!GRADLE_SYSTEM_ID.getId().equals(ExternalSystemModulePropertyManager.getInstance(module).getExternalSystemId())) {
                unsupportedModules.add(module);
            }
        }
    }
    if (unsupportedModules.size() == 0) {
        return;
    }
    String s = join(unsupportedModules, Module::getName, ", ");
    AndroidGradleNotification.getInstance(myProject).showBalloon("Unsupported Modules Detected", "Compilation is not supported for following modules: " + s + ". Unfortunately you can't have non-Gradle Java modules and Android-Gradle modules in one project.", NotificationType.ERROR);
}
Also used : ModuleType(com.intellij.openapi.module.ModuleType) JavaModuleType(com.intellij.openapi.module.JavaModuleType) ArrayList(java.util.ArrayList) JavaModuleType(com.intellij.openapi.module.JavaModuleType) Module(com.intellij.openapi.module.Module)

Example 2 with JavaModuleType

use of com.intellij.openapi.module.JavaModuleType in project intellij-plugins by JetBrains.

the class GrCucumberExtension method collectAllStepDefsProviders.

@Override
protected void collectAllStepDefsProviders(@NotNull List<VirtualFile> providers, @NotNull Project project) {
    final Module[] modules = ModuleManager.getInstance(project).getModules();
    for (Module module : modules) {
        if (ModuleType.get(module) instanceof JavaModuleType) {
            final VirtualFile[] roots = ModuleRootManager.getInstance(module).getContentRoots();
            ContainerUtil.addAll(providers, roots);
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) JavaModuleType(com.intellij.openapi.module.JavaModuleType) Module(com.intellij.openapi.module.Module)

Example 3 with JavaModuleType

use of com.intellij.openapi.module.JavaModuleType in project intellij-community by JetBrains.

the class DefaultModuleEditorsProvider method createEditors.

@Override
public ModuleConfigurationEditor[] createEditors(ModuleConfigurationState state) {
    ModifiableRootModel rootModel = state.getRootModel();
    Module module = rootModel.getModule();
    if (!(ModuleType.get(module) instanceof JavaModuleType)) {
        return ModuleConfigurationEditor.EMPTY;
    }
    String moduleName = module.getName();
    List<ModuleConfigurationEditor> editors = new ArrayList<>();
    editors.add(new ContentEntriesEditor(moduleName, state));
    editors.add(new OutputEditor(state));
    editors.add(new ClasspathEditor(state));
    return editors.toArray(new ModuleConfigurationEditor[editors.size()]);
}
Also used : ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) ModuleConfigurationEditor(com.intellij.openapi.module.ModuleConfigurationEditor) JavaModuleType(com.intellij.openapi.module.JavaModuleType) ArrayList(java.util.ArrayList) Module(com.intellij.openapi.module.Module)

Example 4 with JavaModuleType

use of com.intellij.openapi.module.JavaModuleType in project intellij-community by JetBrains.

the class DotProjectFileHelper method saveDotProjectFile.

public static void saveDotProjectFile(@NotNull Module module, @NotNull String storageRoot) throws IOException {
    try {
        Document doc;
        if (ModuleType.get(module) instanceof JavaModuleType) {
            doc = JDOMUtil.loadDocument(DotProjectFileHelper.class.getResource("template.project.xml"));
        } else {
            doc = JDOMUtil.loadDocument(DotProjectFileHelper.class.getResource("template.empty.project.xml"));
        }
        doc.getRootElement().getChild(EclipseXml.NAME_TAG).setText(module.getName());
        final File projectFile = new File(storageRoot, EclipseXml.PROJECT_FILE);
        if (!FileUtil.createIfDoesntExist(projectFile)) {
            return;
        }
        EclipseJDOMUtil.output(doc.getRootElement(), projectFile, module.getProject());
        ApplicationManager.getApplication().runWriteAction(() -> {
            LocalFileSystem.getInstance().refreshAndFindFileByPath(FileUtil.toSystemIndependentName(projectFile.getPath()));
        });
    } catch (JDOMException e) {
        LOG.error(e);
    }
}
Also used : JavaModuleType(com.intellij.openapi.module.JavaModuleType) Document(org.jdom.Document) JDOMException(org.jdom.JDOMException) File(java.io.File)

Aggregations

JavaModuleType (com.intellij.openapi.module.JavaModuleType)4 Module (com.intellij.openapi.module.Module)3 ArrayList (java.util.ArrayList)2 ModuleConfigurationEditor (com.intellij.openapi.module.ModuleConfigurationEditor)1 ModuleType (com.intellij.openapi.module.ModuleType)1 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 File (java.io.File)1 Document (org.jdom.Document)1 JDOMException (org.jdom.JDOMException)1