List<Path> (AntDomClasspathElement typedef) { boolean cleanupNeeded = false; if (!ourIsBuildingClasspathForCustomTagLoading.get()) { ourIsBuildingClasspathForCustomTagLoading.set(Boolean.TRUE); cleanupNeeded = true; } try { List<Path> paths = new ArrayList<>(); // check classpath attribute List<File> cpFiles = typedef.getClasspath().getValue(); if (cpFiles != null) { addClasspathEntries(paths, cpFiles); } final HashSet<AntFilesProvider> processed = new HashSet<>(); final AntDomElement referencedPath = typedef.getClasspathRef().getValue(); if (referencedPath instanceof AntFilesProvider) { addClasspathEntries(paths, ((AntFilesProvider)referencedPath).getFiles(processed)); } // check nested elements for (Iterator<AntDomElement> it = typedef.getAntChildrenIterator(); it.hasNext();) { AntDomElement child = it.next(); if (child instanceof AntFilesProvider) { addClasspathEntries(paths, ((AntFilesProvider)child).getFiles(processed)); } } return paths; } finally { if (cleanupNeeded) { ourIsBuildingClasspathForCustomTagLoading.remove(); } } }