# HG changeset patch # User Omair Majid # Date 1363731389 14400 # Node ID 136bdf5e62234cfdb376c73b85e1a115bf699c27 # Parent 361b7725dfce5eb91e4f86ee7574be43dcdff8cb Only generate plugin docs for supported API Reviewed-by: vanaltj Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2013-March/006078.html diff -r 361b7725dfce -r 136bdf5e6223 distribution/tools/MergePluginDocs.java --- a/distribution/tools/MergePluginDocs.java Tue Mar 19 17:54:56 2013 -0400 +++ b/distribution/tools/MergePluginDocs.java Tue Mar 19 18:16:29 2013 -0400 @@ -60,7 +60,15 @@ private static final String DOCS_FILE_NAME = CORE + ".xml"; private static final String DOCS_ELEMENT = CORE; + private static final List corePaths = new LinkedList<>(); + public static void main(String[] args) throws IOException, XMLStreamException { + corePaths.add(Paths.get("agent").toAbsolutePath().normalize()); + corePaths.add(Paths.get("launcher").toAbsolutePath().normalize()); + corePaths.add(Paths.get("client").toAbsolutePath().normalize()); + corePaths.add(Paths.get("common").toAbsolutePath().normalize()); + corePaths.add(Paths.get("storage", "core").toAbsolutePath().normalize()); + String startPath = "."; if (args.length > 0) { startPath = args[0]; @@ -76,11 +84,15 @@ Files.walkFileTree(Paths.get(startPath), new SimpleFileVisitor() { @Override + public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { + if (!shouldEnter(dir)) { + return FileVisitResult.SKIP_SUBTREE; + } + return FileVisitResult.CONTINUE; + } + + @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - if (!Files.isRegularFile(file)) { - throw new AssertionError("lrn2code, nub!"); - } - if (file.getFileName().toString().equals(DOCS_FILE_NAME)) { paths.add(file); } @@ -91,6 +103,17 @@ return paths; } + /** Only enter a directory if it is (or could lead to) a directory we want to check */ + private static boolean shouldEnter(Path toCheck) { + toCheck = toCheck.toAbsolutePath().normalize(); + for (Path path : corePaths) { + if (toCheck.startsWith(path) || path.startsWith(toCheck)) { + return true; + } + } + return false; + } + private static String mergePluginDocs(List paths) throws IOException, XMLStreamException { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); XMLEventFactory eventFactory = XMLEventFactory.newFactory();