void (ModifiableRootModel model, String testDataPath, String @NotNull ... libraryPath) { LibraryTable libraryTable = model.getModuleLibraryTable(); Library library = libraryTable.createLibrary("test"); Library.ModifiableModel libraryModel = library.getModifiableModel(); for (String annotationsDir : libraryPath) { String path = testDataPath + "/libs/" + annotationsDir; VirtualFile libJarLocal = LocalFileSystem.getInstance().findFileByPath(path); assertNotNull(libJarLocal); VirtualFile jarRoot = JarFileSystem.getInstance().getJarRootForLocalFile(libJarLocal); assertNotNull(jarRoot); libraryModel.addRoot(jarRoot, jarRoot.getName().contains("-sources") ? OrderRootType.SOURCES : OrderRootType.CLASSES); } libraryModel.commit(); }