use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class MavenProjectImporter method collectIncompatibleModulesWithProjects.
/**
* Collects modules that need to change module type
* @return the first List in returned Pair contains already mavenized modules, the second List - not mavenized
*/
private Pair<List<Pair<MavenProject, Module>>, List<Pair<MavenProject, Module>>> collectIncompatibleModulesWithProjects() {
List<Pair<MavenProject, Module>> incompatibleMavenized = new ArrayList<>();
List<Pair<MavenProject, Module>> incompatibleNotMavenized = new ArrayList<>();
MavenProjectsManager manager = MavenProjectsManager.getInstance(myProject);
for (MavenProject each : myAllProjects) {
Module module = myFileToModuleMapping.get(each.getFile());
if (module == null)
continue;
if (shouldCreateModuleFor(each) && !(ModuleType.get(module).equals(each.getModuleType()))) {
(manager.isMavenizedModule(module) ? incompatibleMavenized : incompatibleNotMavenized).add(Pair.create(each, module));
}
}
return Pair.create(incompatibleMavenized, incompatibleNotMavenized);
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class MavenProjectImporter method importProject.
@Nullable
public List<MavenProjectsProcessorTask> importProject() {
List<MavenProjectsProcessorTask> postTasks = new ArrayList<>();
boolean hasChanges;
// in the case projects are changed during importing we must memorise them
myAllProjects = new LinkedHashSet<>(myProjectsTree.getProjects());
// some projects may already have been removed from the tree
myAllProjects.addAll(myProjectsToImportWithChanges.keySet());
hasChanges = deleteIncompatibleModules();
myProjectsToImportWithChanges = collectProjectsToImport(myProjectsToImportWithChanges);
mapMavenProjectsToModulesAndNames();
if (myProject.isDisposed())
return null;
final boolean projectsHaveChanges = projectsToImportHaveChanges();
if (projectsHaveChanges) {
hasChanges = true;
importModules(postTasks);
scheduleRefreshResolvedArtifacts(postTasks);
}
if (projectsHaveChanges || myImportModuleGroupsRequired) {
hasChanges = true;
configModuleGroups();
}
if (myProject.isDisposed())
return null;
try {
boolean modulesDeleted = deleteObsoleteModules();
hasChanges |= modulesDeleted;
if (hasChanges) {
removeUnusedProjectLibraries();
}
} catch (ProcessCanceledException e) {
throw e;
} catch (Exception e) {
disposeModifiableModels();
LOG.error(e);
return null;
}
if (hasChanges) {
MavenUtil.invokeAndWaitWriteAction(myProject, () -> {
myModelsProvider.commit();
if (projectsHaveChanges) {
removeOutdatedCompilerConfigSettings();
for (MavenProject mavenProject : myAllProjects) {
Module module = myMavenProjectToModule.get(mavenProject);
if (module != null && module.isDisposed()) {
module = null;
}
for (MavenModuleConfigurer configurer : MavenModuleConfigurer.getConfigurers()) {
configurer.configure(mavenProject, myProject, module);
}
}
}
});
} else {
disposeModifiableModels();
}
return postTasks;
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class MavenProjectImporter method formatProjectsWithModules.
private static String formatProjectsWithModules(List<Pair<MavenProject, Module>> projectsWithModules) {
return StringUtil.join(projectsWithModules, each -> {
MavenProject project = each.first;
Module module = each.second;
return ModuleType.get(module).getName() + " '" + module.getName() + "' for Maven project " + project.getMavenId().getDisplayString();
}, "<br>");
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class SelectInMavenNavigatorTarget method getMavenProject.
private static MavenProject getMavenProject(SelectInContext context) {
VirtualFile file = context.getVirtualFile();
MavenProjectsManager manager = MavenProjectsManager.getInstance(context.getProject());
Module module = ProjectRootManager.getInstance(context.getProject()).getFileIndex().getModuleForFile(file);
return module == null ? null : manager.findProject(module);
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class TestNGTestDiscoveryRunnableState method createSearchingForTestsTask.
@Override
public SearchingForTestsTask createSearchingForTestsTask() {
return new SearchingForTestsTask(myServerSocket, getConfiguration(), myTempFile) {
@Override
protected void search() throws CantRunException {
myClasses.clear();
final TestData data = getConfiguration().getPersistantData();
final Pair<String, String> position = data.TEST_OBJECT.equals(TestType.SOURCE.getType()) ? Pair.create(data.getMainClassName(), data.getMethodName()) : null;
final Set<String> patterns = TestDiscoverySearchHelper.search(getProject(), position, data.getChangeList(), getConfiguration().getFrameworkPrefix());
final Module module = getConfiguration().getConfigurationModule().getModule();
final GlobalSearchScope searchScope = module != null ? GlobalSearchScope.moduleWithDependenciesScope(module) : GlobalSearchScope.projectScope(getProject());
TestNGTestPattern.fillTestObjects(myClasses, patterns, TestSearchScope.MODULE_WITH_DEPENDENCIES, getConfiguration(), searchScope);
}
@Override
protected void onFound() {
super.onFound();
writeClassesPerModule(myClasses);
}
};
}
Aggregations