/** * Returns the base set of resources needed to load the specified {@link Class} using the * specified {@link ClassLoader}. Also traces and includes the dependencies for the specified class. * * @param classLoader the {@link ClassLoader} to use to generate the set of resources * @param classz the {@link Class} to generate the set of resources for * @return the set of resources needed to load the specified {@link Class} using the specified {@link ClassLoader} * @throws IOException */ public static Set<String> getResourcesWithDependencies(ClassLoader classLoader, Class<?> classz) throws IOException { ClassPath classPath = getClassPath(classLoader, classz); // Add everything in the classpath as visible resources Set<String> result = Sets.newHashSet(Iterables.transform(classPath.getResources(), RESOURCE_INFO_TO_RESOURCE_NAME)); // Trace dependencies for all classes in the classpath findClassDependencies( classLoader, Iterables.transform(classPath.getAllClasses(), CLASS_INFO_TO_CLASS_NAME), result); return result; }
/** * Returns the base set of resources needed to load the specified {@link Class} using the * specified {@link ClassLoader}. Also traces and includes the dependencies for the specified class. * * @param classLoader the {@link ClassLoader} to use to generate the set of resources * @param classz the {@link Class} to generate the set of resources for * @return the set of resources needed to load the specified {@link Class} using the specified {@link ClassLoader} * @throws IOException */ public static Set<String> getResourcesWithDependencies(ClassLoader classLoader, Class<?> classz) throws IOException { ClassPath classPath = getClassPath(classLoader, classz); // Add everything in the classpath as visible resources Set<String> result = Sets.newHashSet(Iterables.transform(classPath.getResources(), RESOURCE_INFO_TO_RESOURCE_NAME)); // Trace dependencies for all classes in the classpath findClassDependencies( classLoader, Iterables.transform(classPath.getAllClasses(), CLASS_INFO_TO_CLASS_NAME), result); return result; }