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?


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

That was it, thanks Madis!

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



Digging through idea's source code :(


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.



Please sign in to leave a comment.