Create resources root in a module and add new file


I need to add a special resources file to a user project (for example, MockMaker file from this tutorial  

So I have an instance of test module (com.intellij.openapi.module) and I need:

- to create test resources root if not exists

- mark it as test resources root

- add a file to this test resources root

What is a best way to do it?

1 comment

Hi Egor,

You may be interested in the following APIs:

  • Standard Java API for creating new files
  • ModuleRootManager and related classes/methods mentioned in this comment for manipulating source roots

Please sign in to leave a comment.