/** * * @return - a list of jar pairs that have overlapping class files - scans the whole classpath * * By default all duplicates are shown * */ public List<JarPair> findOverlappingJars() { return findOverlappingJars(findAllClasspathResources(), false); }
/** * * @return - a list of jar pairs that have overlapping class files - scans the whole classpath * */ public List<JarPair> findOverlappingJars(boolean excludeSameSizeDups) { return findOverlappingJars(findAllClasspathResources(), excludeSameSizeDups); }
/** * * @return - a list of jar pairs that have overlapping class files - scans the whole classpath * * By default all duplicates are shown * */ public List<JarPair> findOverlappingJars() { return findOverlappingJars(findAllClasspathResources(), false); }
/** * * @return - a list of jar pairs that have overlapping class files - scans the whole classpath * */ public List<JarPair> findOverlappingJars(boolean excludeSameSizeDups) { return findOverlappingJars(findAllClasspathResources(), excludeSameSizeDups); }
/** * * Finds a list of all classpath resources that contain duplicates. * * A duplicate classpath resource can be for example a configuration file such as log4.xml, that exists by accident * multiple times on the classpath. * * @param excludeSameSizeDups - excludes from the reports files for which all classpath versions have the same size * @return classpath resources that have multiple versions on the classpath */ public List<ClasspathResource> findAllResourcesWithDuplicates(boolean excludeSameSizeDups) { List<ClasspathResource> resourceFiles = findAllClasspathResources(); return ClasspathResources.findResourcesWithDuplicates(resourceFiles, excludeSameSizeDups); }
/** * * Finds a list of all classpath resources that contain duplicates. * * A duplicate classpath resource can be for example a configuration file such as log4.xml, that exists by accident * multiple times on the classpath. * * @param excludeSameSizeDups - excludes from the reports files for which all classpath versions have the same size * @return classpath resources that have multiple versions on the classpath */ public List<ClasspathResource> findAllResourcesWithDuplicates(boolean excludeSameSizeDups) { List<ClasspathResource> resourceFiles = findAllClasspathResources(); return ClasspathResources.findResourcesWithDuplicates(resourceFiles, excludeSameSizeDups); }
/** * * finds a resource on the classpath using a regular expression. * * @param search - search regular expression * @return - the list of classpath resources that match the regular expression */ public List<ClasspathResource> findByRegex(String search) { List<ClasspathResource> allResources = findAllClasspathResources(); List<ClasspathResource> matches = new ArrayList<>(); Pattern pattern = Pattern.compile(search); for (ClasspathResource resource : allResources) { if (resource != null && resource.getName() != null && pattern.matcher(resource.getName()).find()) { matches.add(resource); } } return matches; }
/** * * finds a resource on the classpath using a regular expression. * * @param search - search regular expression * @return - the list of classpath resources that match the regular expression */ public List<ClasspathResource> findByRegex(String search) { List<ClasspathResource> allResources = findAllClasspathResources(); List<ClasspathResource> matches = new ArrayList<>(); Pattern pattern = Pattern.compile(search); for (ClasspathResource resource : allResources) { if (resource != null && resource.getName() != null && pattern.matcher(resource.getName()).find()) { matches.add(resource); } } return matches; }
/** * * Search for a given class on the classpath, returns the list of all class versions. * * @param clazz - the class being searched. * @return - the classpath resource containing all the class versions, or null if not found */ public ClasspathResource findClass(Class clazz) { String classResourceName = clazz.getName().replace(".", "/") + ".class"; List<ClasspathResource> allResources = findAllClasspathResources(); ClasspathResource foundResource = null; for (ClasspathResource resource : allResources) { if (resource != null && resource.getName() != null && resource.getName().endsWith(classResourceName)) { foundResource = resource; break; } } return foundResource; }
/** * * Search for a given class on the classpath, returns the list of all class versions. * * @param clazz - the class being searched. * @return - the classpath resource containing all the class versions, or null if not found */ public ClasspathResource findClass(Class clazz) { String classResourceName = clazz.getName().replace(".", "/") + ".class"; List<ClasspathResource> allResources = findAllClasspathResources(); ClasspathResource foundResource = null; for (ClasspathResource resource : allResources) { if (resource != null && resource.getName() != null && resource.getName().endsWith(classResourceName)) { foundResource = resource; break; } } return foundResource; }