Specifying Resources and Test Resources programmatically

I am currently adding source and test source directories as follows:


val modifiableModel = ModuleRootManager.getInstance(module).modifiableModel
val contentEntry = modifiableModel.addContentEntry(contentRoot)
contentEntry.addSourceFolder(srcDir, isTest)

However, I can't find how to specify a resource or test resource dir (I expected to find something like `addResourceFolder(dir, isTest: Boolean)` but no such thing.

How do I add a resource directory to my module?

 

4 comments
Use the method with signature:
addSourceFolder(@NotNull VirtualFile file, @NotNull JpsModuleSourceRootType<P> type, @NotNull P properties);
E.g:
contentEntry.addSourceFolder(resourcesRoot, JavaResourceRootType.RESOURCE, JavaResourceRootType.RESOURCE.createDefaultProperties());
0

That was it, thanks Madis!

For future reference, where in the documentation could I have found this?

 

0

Digging through idea's source code :(

0

I was afraid you'd say that...

I actually did (I have a whole project open in another window with the full IDEA source code in it) but even despite that, I wasn't able to find this information.

 

0

Please sign in to leave a comment.