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?

2 comments
Comment actions Permalink

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!"

0
Comment actions Permalink

Thank you very much Nikolay. That's exaclty what I wanted. :)

0

Please sign in to leave a comment.