void () { File root = new File(FileUtil.getTempDirectory()); File dir1 = new File(root, "dir1"); assertTrue(dir1.mkdirs()); VirtualFile contentRoot = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(dir1); assertNotNull(contentRoot); Module moduleA = createModule("a.iml"); ModuleRootModificationUtil.addContentRoot(moduleA, contentRoot.getPath()); String excludedUrl = contentRoot.getUrl() + "/excluded"; String sourceUrl = contentRoot.getUrl() + "/src"; String testSourceUrl = contentRoot.getUrl() + "/testSrc"; String outputUrl = contentRoot.getUrl() + "/out"; String testOutputUrl = contentRoot.getUrl() + "/testOut"; String resourceUrl = contentRoot.getUrl() + "/res"; String testResourceUrl = contentRoot.getUrl() + "/testRes"; ModuleRootModificationUtil.updateModel(moduleA, model -> { ContentEntry entry = ContainerUtil.find(model.getContentEntries(), e-> contentRoot.equals(e.getFile())); entry.addExcludeFolder(excludedUrl); entry.addSourceFolder(sourceUrl, false); entry.addSourceFolder(testSourceUrl, true); entry.addSourceFolder(resourceUrl, JavaResourceRootType.RESOURCE); entry.addSourceFolder(testResourceUrl, JavaResourceRootType.TEST_RESOURCE); CompilerModuleExtension moduleExtension = model.getModuleExtension(CompilerModuleExtension.class); moduleExtension.inheritCompilerOutputPath(false); moduleExtension.setCompilerOutputPath(outputUrl); moduleExtension.setCompilerOutputPathForTests(testOutputUrl); }); checkRootChangedOnDirCreationDeletion(contentRoot, excludedUrl, 1); checkRootChangedOnDirCreationDeletion(contentRoot, sourceUrl, 1); checkRootChangedOnDirCreationDeletion(contentRoot, testSourceUrl, 1); checkRootChangedOnDirCreationDeletion(contentRoot, resourceUrl, 1); checkRootChangedOnDirCreationDeletion(contentRoot, testResourceUrl, 1); checkRootChangedOnDirCreationDeletion(contentRoot, outputUrl, 1); checkRootChangedOnDirCreationDeletion(contentRoot, testOutputUrl, 1); checkRootChangedOnDirCreationDeletion(contentRoot, "xxx", 0); }