void (@Nullable java.nio.file.Path defaultContentRootPath) { Map<String, SourceFolder> sourceFoldersMap = new TreeMap<>(FileUtil::comparePaths); for (String sourceRootUrl : myModel.getSourceRootUrls(true)) { String sourceRootPath = FileUtil.toSystemDependentName(VfsUtilCore.urlToPath(sourceRootUrl)); SourceFolder sourceFolder = myModel.getSourceFolder(new File(sourceRootPath)); if (sourceFolder != null) { sourceFoldersMap.put(sourceRootUrl, sourceFolder); } } ModifiableRootModel rootModel = myModel.getRootModel(); for (ContentEntry contentEntry : rootModel.getContentEntries()) { rootModel.removeContentEntry(contentEntry); } Set<String> topLevelSourceFolderUrls = new HashSet<>(); if (defaultContentRootPath != null) { String defaultContentRootUrl = MavenUtil.toPath(myMavenProject, defaultContentRootPath.toString()).toUrl().getUrl(); topLevelSourceFolderUrls.add(defaultContentRootUrl); } for (String sourceRoot : sourceFoldersMap.keySet()) { if (!ContainerUtil.exists(topLevelSourceFolderUrls, root -> FileUtil.isAncestor(root, sourceRoot, false))) { topLevelSourceFolderUrls.add(sourceRoot); } } setContentRootData(topLevelSourceFolderUrls, rootModel, sourceFoldersMap); }