void (LibraryEx from, Map<String, String> rootMapping, LibraryEx.ModifiableModelEx target) { target.setProperties(from.getProperties()); for (OrderRootType type : OrderRootType.getAllTypes()) { final String[] urls = from.getUrls(type); for (String url : urls) { final String protocol = VirtualFileManager.extractProtocol(url); if (protocol == null) continue; final String fullPath = VirtualFileManager.extractPath(url); final int sep = fullPath.indexOf(JarFileSystem.JAR_SEPARATOR); String localPath; String pathInJar; if (sep != -1) { localPath = fullPath.substring(0, sep); pathInJar = fullPath.substring(sep); } else { localPath = fullPath; pathInJar = ""; } final String targetPath = rootMapping.get(localPath); String targetUrl = targetPath != null ? VirtualFileManager.constructUrl(protocol, targetPath + pathInJar) : url; if (from.isJarDirectory(url, type)) { target.addJarDirectory(targetUrl, false, type); } else { target.addRoot(targetUrl, type); } } } }