@Test public void tokenizerTest() { String cpString = "file:/home/sesame/.m2/repository/repositories/kie/global/org/kie/kie-api/7.9.0-SNAPSHOT/kie-api-7.9.0-SNAPSHOT.jar:" + "file:/home/sesame/.m2/repository/repositories/kie/global/org/kie/soup/kie-soup-maven-support/7.9.0-SNAPSHOT/" + "kie-soup-maven-support-7.9.0-SNAPSHOT.jar:file:/home/sesame/.m2/" + "repository/repositories/kie/global/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar"; Set<String> deps = new HashSet<>(); deps.add(cpString); List<String> items = CompilerClassloaderUtils.readItemsFromClasspathString(deps); assertThat(items).hasSize(3); assertThat(items.contains("file:/home/sesame/.m2/repository/repositories/kie/global/org/kie/kie-api/7.9.0-SNAPSHOT/kie-api-7.9.0-SNAPSHOT.jar")).isTrue(); assertThat(items.contains("file:/home/sesame/.m2/repository/repositories/kie/global/org/kie/soup/kie-soup-maven-support/7.9.0-SNAPSHOT/kie-soup-maven-support-7.9.0-SNAPSHOT.jar")).isTrue(); assertThat(items.contains("file:/home/sesame/.m2/repository/repositories/kie/global/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar")).isTrue(); }
public static List<String> readItemsFromClasspathString(Set<String> depsModules) { Set<String> items = new HashSet<>(); Iterator<String> iter = depsModules.iterator(); while (iter.hasNext()) { StringTokenizer token = new StringTokenizer(iter.next()); while (token.hasMoreElements()) { String item = token.nextToken(":"); if (item.endsWith(CommonConstants.JAVA_ARCHIVE_RESOURCE_EXT)) { StringBuilder sb = new StringBuilder(CommonConstants.FILE).append(item); items.add(sb.toString()); } } } return new ArrayList<>(items); }
CompilerClassloaderUtils { public static List<String> readItemsFromClasspathString(Set<String> depsModules) { Set<String> items = new HashSet<>(); Iterator<String> iter = depsModules.iterator(); while (iter.hasNext()) { StringTokenizer token = new StringTokenizer(iter.next()); while (token.hasMoreElements()) { String item = token.nextToken(":"); if (item.endsWith(CommonConstants.JAVA_ARCHIVE_RESOURCE_EXT)) { StringBuilder sb = new StringBuilder(CommonConstants.FILE).append(item); items.add(sb.toString()); } } } return new ArrayList<>(items); } }
CompilerClassloaderUtils { public static List<String> readItemsFromClasspathString(Set<String> depsModules) { Set<String> items = new HashSet<>(); Iterator<String> iter = depsModules.iterator(); while (iter.hasNext()) { StringTokenizer token = new StringTokenizer(iter.next()); while (token.hasMoreElements()) { String item = token.nextToken(":"); if (item.endsWith(CommonConstants.JAVA_ARCHIVE_RESOURCE_EXT)) { StringBuilder sb = new StringBuilder(CommonConstants.FILE).append(item); items.add(sb.toString()); } } } return new ArrayList<>(items); } private  CompilerClassloaderUtils(); }
CompilerClassloaderUtils { public static List<String> readItemsFromClasspathString(Set<String> depsModules) { Set<String> items = new HashSet<>(); Iterator<String> iter = depsModules.iterator(); while (iter.hasNext()) { StringTokenizer token = new StringTokenizer(iter.next()); while (token.hasMoreElements()) { String item = token.nextToken(":"); if (item.endsWith(CommonConstants.JAVA_ARCHIVE_RESOURCE_EXT)) { StringBuilder sb = new StringBuilder(CommonConstants.FILE).append(item); items.add(sb.toString()); } } } return new ArrayList<>(items); } private  CompilerClassloaderUtils(); static Optional<ClassLoader> getClassloaderFromAllDependencies(String prjPath,
                                                                          String localRepo,
                                                                          String settingsXmlPath); static Map<String, byte[]> getMapClasses(String path,
                                                    Map<String, byte[]> store); static Predicate<File> filterClasses(); static Optional<ClassLoader> loadDependenciesClassloaderFromProject(String prjPath,
                                                                               String localRepo); static Optional<ClassLoader> loadDependenciesClassloaderFromProject(List<String> poms,
                                                                               String localRepo); static Optional<ClassLoader> getClassloaderFromProjectTargets(List<String> pomsPaths); static List<URL> buildUrlsFromArtifacts(String localRepo,
                                                   List<Artifact> artifacts); static List<URL> getDependenciesURL(List<String> poms,
                                               String localRepo); static List<URL> getTargetModulesURL(List<String> pomsPaths); static Optional<ClassLoader> createClassloaderFromStringDeps(List<String> depsProject); static List<URL> readAllDepsAsUrls(List<String> prjDeps); static List<URI> readAllDepsAsUris(List<String> prjDeps); static List<String> readItemsFromClasspathString(Set<String> depsModules); static List<String> getStringFromTargets(Path prjPath); static List<String> getStringFromTargetWithStream(Path pathIn,
                                                             String... extensions); static List<URI> processScannedFilesAsURIs(List<String> classPathFiles); static List<URL> processScannedFilesAsURLs(List<String> classPathFiles); static Set<String> filterPathClasses(Collection<String> paths,
                                                String mavenRepoPath); static List<String> filterClassesByPackage(Collection<String> items,
                                                      String packageName); static Class<?> getClass(String pkgName,
                                    String className,
                                    ClassLoader classloader); }
CompilerClassloaderUtils { public static List<String> readItemsFromClasspathString(Set<String> depsModules) { Set<String> items = new HashSet<>(); Iterator<String> iter = depsModules.iterator(); while (iter.hasNext()) { StringTokenizer token = new StringTokenizer(iter.next()); while (token.hasMoreElements()) { String item = token.nextToken(":"); if (item.endsWith(CommonConstants.JAVA_ARCHIVE_RESOURCE_EXT)) { StringBuilder sb = new StringBuilder(CommonConstants.FILE).append(item); items.add(sb.toString()); } } } return new ArrayList<>(items); } private  CompilerClassloaderUtils(); static Optional<ClassLoader> getClassloaderFromAllDependencies(String prjPath,
                                                                          String localRepo,
                                                                          String settingsXmlPath); static Map<String, byte[]> getMapClasses(String path,
                                                    Map<String, byte[]> store); static Predicate<File> filterClasses(); static Optional<ClassLoader> loadDependenciesClassloaderFromProject(String prjPath,
                                                                               String localRepo); static Optional<ClassLoader> loadDependenciesClassloaderFromProject(List<String> poms,
                                                                               String localRepo); static Optional<ClassLoader> getClassloaderFromProjectTargets(List<String> pomsPaths); static List<URL> buildUrlsFromArtifacts(String localRepo,
                                                   List<Artifact> artifacts); static List<URL> getDependenciesURL(List<String> poms,
                                               String localRepo); static List<URL> getTargetModulesURL(List<String> pomsPaths); static Optional<ClassLoader> createClassloaderFromStringDeps(List<String> depsProject); static List<URL> readAllDepsAsUrls(List<String> prjDeps); static List<URI> readAllDepsAsUris(List<String> prjDeps); static List<String> readItemsFromClasspathString(Set<String> depsModules); static List<String> getStringFromTargets(Path prjPath); static List<String> getStringFromTargetWithStream(Path pathIn,
                                                             String... extensions); static List<URI> processScannedFilesAsURIs(List<String> classPathFiles); static List<URL> processScannedFilesAsURLs(List<String> classPathFiles); static Set<String> filterPathClasses(Collection<String> paths,
                                                String mavenRepoPath); static List<String> filterClassesByPackage(Collection<String> items,
                                                      String packageName); static Class<?> getClass(String pkgName,
                                    String className,
                                    ClassLoader classloader);  }