ClassUtil { public static List<String> findMainClasses(File rootDir) throws IOException { List<String> ret = new ArrayList<>(); if (!rootDir.exists()) { return ret; } if (!rootDir.isDirectory()) { throw new IllegalArgumentException(String.format("Path %s is not a directory",rootDir.getPath())); } findClasses(ret, rootDir, rootDir.getAbsolutePath() + "/"); return ret; }  static Set<String> getResources(String resource); static Set<String> getResources(String resource, List<ClassLoader> additionalClassLoaders); static Class<T> classForName(String className, List<ClassLoader> additionalClassLoaders); static List<String> findMainClasses(File rootDir); static URLClassLoader createProjectClassLoader(List<String> elements, Logger log);  }
@Test public void findOne() throws IOException { File root = getRelativePackagePath("mainclass/one"); List<String> ret = ClassUtil.findMainClasses(root); assertEquals(1,ret.size()); assertEquals("sub.OneMain", ret.get(0)); }
@Test public void findTwo() throws IOException { File root = getRelativePackagePath("mainclass/two"); Set<String> ret = new HashSet<>(ClassUtil.findMainClasses(root)); assertEquals(2,ret.size()); assertTrue(ret.contains("OneMain")); assertTrue(ret.contains("another.sub.a.bit.deeper.TwoMain")); }
@Test public void findNone() throws IOException { File root = getRelativePackagePath("mainclass/zero"); List<String> ret = ClassUtil.findMainClasses(root); assertEquals(0,ret.size()); }