How to mark Modules when opening a project
Answered
The project I need to work on has such a directory structure, where `moduleA` and `moduleB` are directories that need to be marked as module.
root
- projects/
- moduleA
- package.toml
- moduleB
- package.toml
- workspace.toml
I hope that when I open this directory for the first time (no `.idea/` or `*.iml` is generated), I hope to detect whether it belongs to my framework, and if so, mark modules.
I'm going to use
ModuleManager.getInstance(project).newModule(path, myModuleType)
to mark module, but I don't know which endpoint should be used to listen for the event of opening the project for the first time.
Please sign in to leave a comment.
Write actions are not a problem, try
WriteCommandAction.runWriteCommandAction(project) { }
Hi,
Try to wrap it into `com.intellij.openapi.application.CoroutinesKt#writeAction`.
Write command action suggested by Marcin is for running actions that are undoable, which I believe you don't want here.
You might use
postStartupActivity
extension and then maybe useproject.isNewProject()
. But I didn't test that.It seems that
newModule
cannot be called inProjectActivity
, because Write access is allowed inside write-action only.Impliments:
Error Message: