New Project from existing Directory not showing Directories
Hi,
i programmatically clone a repository from git and want to open it afterwards. The steps are basically:
-
GitCommandResult clone =
getIdeaGit().clone(
ProjectManager.getInstance().getDefaultProject(),
new File(projectDir),
repository.gitHttpTransportUrl(),
repository.getName()
); -
projectManager.newProject(repository.getName(), projectDir, true, false);
-
project.save();
-
ProjectUtil.updateLastProjectLocation(projectDir);
-
projectManager.openProject(project);
The Project opens but only the files, not the directories are visible in project structure. For example i have a repository with a .gitignore file and a folder which contains all the resources and code. Only the .gitignore file is visible but not the folder (and also the .idea folder is not there, although it exists on disk).
Is there a way to automatically detect all (sub-)folders when opening a project?
Greetings, Moritz
请先登录再写评论。
Hello,
if you're creating a project from a directory you should also create a module and add a content root in it (see our help for details). You can use ModuleManager to create a module and ModuleRootManager to setup a content root in it.
Also note that 'ProjectManagerEx#openProject' which takes 'Project' instance is an internal method and it isn't supposed to be used by plugins. If you want to reopen a project you should call ProjectManager#loadAndOpenProject and pass projectDir to it.