How to set Sources Root directory and Test Sources Root directory
Hi,
I'm writing a plugin to build a module programatically and when I'm creating the module directory hierarchy I want to mark /src/main/unitfile directory as source root and /src/main/test/mytest directory as test sources root directory. Is there a way to do that?
Please sign in to leave a comment.
Hello,
use ModuleRootManager#getModifiableModel() method:
ModifiableRootModel model = ModuleRootManager.getInstance(module).getModifiableModel();
ContentEntry contentEntry = model.addContentEntry(contentRoot);
contentEntry.addSourceFolder(srcRoot, isTestRoot);
model.commit();
--
Nikolay Chashnikov
JetBrains
http://www.jetbrains.com
"Develop with pleasure!"
Thank you very much Nikolay. That's exaclty what I wanted. :)