From be7486c4c5d7a30bc8e0380a33544b0f57174b73 Mon Sep 17 00:00:00 2001 From: Jake Wang Date: Mon, 9 Dec 2024 22:14:03 +0800 Subject: [PATCH] Check existence of default client/public folder before adding to tracking list --- .../java/org/docstr/gwt/GwtCompileConfig.java | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/plugin/src/main/java/org/docstr/gwt/GwtCompileConfig.java b/plugin/src/main/java/org/docstr/gwt/GwtCompileConfig.java index 2c10d5d..ca636ad 100644 --- a/plugin/src/main/java/org/docstr/gwt/GwtCompileConfig.java +++ b/plugin/src/main/java/org/docstr/gwt/GwtCompileConfig.java @@ -85,6 +85,12 @@ static File findModuleFile(String moduleName, Set sourceFiles) { * 2. Add the package directory for each entry-point to the source paths. * 3. Extract the source paths from the GWT module XML file. * 4. Extract the public paths from the GWT module XML file. + *

+ * As mentioned in https://www.gwtproject.org/doc/latest/DevGuideOrganizingProjects.html + * if no source or public element is defined in a module XML file, the + * client and public subpackage is implicitly added to the source/public + * path as if or had been + * found in the XML. */ TreeSet extractSourcePaths(File moduleFile) { TreeSet sourcePaths = new TreeSet<>(); @@ -122,13 +128,15 @@ TreeSet extractSourcePaths(File moduleFile) { // Extract the source paths from the GWT module XML file NodeList sourceNodes = doc.getElementsByTagName("source"); - if(sourceNodes.getLength() == 0) { - File sourceDir = new File(moduleParent, "client"); - sourcePaths.add(sourceDir); + if (sourceNodes.getLength() == 0) { + File defaultClientDir = new File(moduleParent, "client"); + if (defaultClientDir.exists()) { + sourcePaths.add(defaultClientDir); + } } else { - for(int i = 0; i < sourceNodes.getLength(); i++) { + for (int i = 0; i < sourceNodes.getLength(); i++) { String path = sourceNodes.item(i).getAttributes().getNamedItem("path") - .getNodeValue(); + .getNodeValue(); File sourceDir = new File(moduleParent, path); sourcePaths.add(sourceDir); } @@ -136,13 +144,15 @@ TreeSet extractSourcePaths(File moduleFile) { // Extract the public paths from the GWT module XML file NodeList publicNodes = doc.getElementsByTagName("public"); - if(publicNodes.getLength() == 0) { - File sourceDir = new File(moduleParent, "public"); - sourcePaths.add(sourceDir); + if (publicNodes.getLength() == 0) { + File defaultPublickDir = new File(moduleParent, "public"); + if (defaultPublickDir.exists()) { + sourcePaths.add(defaultPublickDir); + } } else { - for(int i = 0; i < publicNodes.getLength(); i++) { + for (int i = 0; i < publicNodes.getLength(); i++) { String path = publicNodes.item(i).getAttributes().getNamedItem("path") - .getNodeValue(); + .getNodeValue(); File publicDir = new File(moduleParent, path); sourcePaths.add(publicDir); }