void (JpsModule rootModel, String junitName, ExpandMacroToPathMap macroMap) { final @NonNls String ideaHome = macroMap.substitute("$APPLICATION_HOME_DIR$", SystemInfo.isFileSystemCaseSensitive); final FilenameFilter junitFilter = (dir, name) -> name.startsWith("junit"); File[] junitJars = new File(ideaHome, "lib").listFiles(junitFilter); if (junitJars == null || junitJars.length == 0) { junitJars = new File(new File(ideaHome, "community"), "lib").listFiles(junitFilter); } if (junitJars != null && junitJars.length > 0) { final boolean isJUnit4 = junitName.contains("4"); File junitJar = null; for (File jar : junitJars) { final boolean isCurrentJarV4 = jar.getName().contains("4"); if (isCurrentJarV4 && isJUnit4 || !isCurrentJarV4 && !isJUnit4) { junitJar = jar; break; } } if (junitJar != null) { final JpsLibrary jpsLibrary = rootModel.addModuleLibrary(junitName, JpsJavaLibraryType.INSTANCE); jpsLibrary.addRoot(pathToUrl(junitJar.getPath()), JpsOrderRootType.COMPILED); final JpsDependenciesList dependenciesList = rootModel.getDependenciesList(); dependenciesList.addLibraryDependency(jpsLibrary); } } }