@Test(description = "Test copy resources functionality") public void testCopyResources() throws IOException { String userDir = System.getProperty("user.dir"); String outputFolderPath = userDir + File.separator + "target" + File.separator + "api-docs3"; try { File outputPathFile = new File(outputFolderPath); Files.createDirectories(Paths.get(outputPathFile.getPath())); BallerinaDocUtils.copyResources("test-theme", outputFolderPath); File file1 = new File(outputFolderPath + File.separator + "test-theme" + File.separator + "bar" + File.separator + "file1.css"); Assert.assertTrue(file1.exists()); File file2 = new File(outputFolderPath + File.separator + "test-theme" + File.separator + "bar" + File.separator + "xyz" + File.separator + "file2.css"); Assert.assertTrue(file2.exists()); File file3 = new File(outputFolderPath + File.separator + "test-theme" + File.separator + "foo" + File.separator + "file3.css"); Assert.assertTrue(file3.exists()); File file4 = new File(outputFolderPath + File.separator + "test-theme" + File.separator + "foo" + File.separator + "xyz" + File.separator + "file4.css"); Assert.assertTrue(file4.exists()); } finally { BallerinaDocGenTestUtils.deleteDirectory(outputFolderPath); } }
public static void copyResources(String resource, String targetPath) throws IOException { URI uri = null; try { uri = BallerinaDocUtils.class.getClassLoader().getResource(resource).toURI(); } catch (URISyntaxException e) { throw new IOException("Failed to load resources: " + e.getMessage(), e); } Path source; try { source = Paths.get(uri); } catch (FileSystemNotFoundException e) { Map<String, String> env = new HashMap<>(); env.put("create", "true"); FileSystems.newFileSystem(uri, env); source = Paths.get(uri); } Path target = Paths.get(targetPath, resource); Files.walkFileTree(source, new RecursiveFileVisitor(source, target)); }
BallerinaDocUtils { public static void copyResources(String resource, String targetPath) throws IOException { URI uri = null; try { uri = BallerinaDocUtils.class.getClassLoader().getResource(resource).toURI(); } catch (URISyntaxException e) { throw new IOException("Failed to load resources: " + e.getMessage(), e); } Path source; try { source = Paths.get(uri); } catch (FileSystemNotFoundException e) { Map<String, String> env = new HashMap<>(); env.put("create", "true"); FileSystems.newFileSystem(uri, env); source = Paths.get(uri); } Path target = Paths.get(targetPath, resource); Files.walkFileTree(source, new RecursiveFileVisitor(source, target)); } }
BallerinaDocUtils { public static void copyResources(String resource, String targetPath) throws IOException { URI uri = null; try { uri = BallerinaDocUtils.class.getClassLoader().getResource(resource).toURI(); } catch (URISyntaxException e) { throw new IOException("Failed to load resources: " + e.getMessage(), e); } Path source; try { source = Paths.get(uri); } catch (FileSystemNotFoundException e) { Map<String, String> env = new HashMap<>(); env.put("create", "true"); FileSystems.newFileSystem(uri, env); source = Paths.get(uri); } Path target = Paths.get(targetPath, resource); Files.walkFileTree(source, new RecursiveFileVisitor(source, target)); }  }
BallerinaDocUtils { public static void copyResources(String resource, String targetPath) throws IOException { URI uri = null; try { uri = BallerinaDocUtils.class.getClassLoader().getResource(resource).toURI(); } catch (URISyntaxException e) { throw new IOException("Failed to load resources: " + e.getMessage(), e); } Path source; try { source = Paths.get(uri); } catch (FileSystemNotFoundException e) { Map<String, String> env = new HashMap<>(); env.put("create", "true"); FileSystems.newFileSystem(uri, env); source = Paths.get(uri); } Path target = Paths.get(targetPath, resource); Files.walkFileTree(source, new RecursiveFileVisitor(source, target)); }  static String mdToHtml(String mdContent); static List<String> loadPrimitivesDescriptions(boolean filterDescription); static void packageToZipFile(String sourceDirPath, String zipFilePath); static void copyResources(String resource, String targetPath); static boolean isDebugEnabled(); static String getPrimitiveDescription(List<String> descriptions, String type); }
BallerinaDocUtils { public static void copyResources(String resource, String targetPath) throws IOException { URI uri = null; try { uri = BallerinaDocUtils.class.getClassLoader().getResource(resource).toURI(); } catch (URISyntaxException e) { throw new IOException("Failed to load resources: " + e.getMessage(), e); } Path source; try { source = Paths.get(uri); } catch (FileSystemNotFoundException e) { Map<String, String> env = new HashMap<>(); env.put("create", "true"); FileSystems.newFileSystem(uri, env); source = Paths.get(uri); } Path target = Paths.get(targetPath, resource); Files.walkFileTree(source, new RecursiveFileVisitor(source, target)); }  static String mdToHtml(String mdContent); static List<String> loadPrimitivesDescriptions(boolean filterDescription); static void packageToZipFile(String sourceDirPath, String zipFilePath); static void copyResources(String resource, String targetPath); static boolean isDebugEnabled(); static String getPrimitiveDescription(List<String> descriptions, String type);  }