Change Doclava to support multimodule samples

Doclava only recognizes samples as browseable projects if they contain both
an _index.jd file and a src/ directory on their root directories. This CL
relaxes this rule by allowing the src/ to be inside a top level director as
well, so samples with multiple modules, like Wear apps, can be browsed.

Bug: 17042843

Change-Id: I2bcebb1dc3b2d317b43ff4af379c761067535bd9
diff --git a/src/com/google/doclava/Doclava.java b/src/com/google/doclava/Doclava.java
index 88222e7..b09fcf4 100644
--- a/src/com/google/doclava/Doclava.java
+++ b/src/com/google/doclava/Doclava.java
@@ -1783,16 +1783,30 @@
 
   /**
   * Test whether a given directory is the root directory for a sample code project.
-  * Root directories must include both a src/ directory and a valid _index.jd file.
+  * Root directories must contain a valid _index.jd file and a src/ directory
+  * or a module directory that contains a src/ directory.
   */
   public static boolean isValidSampleProjectRoot(File dir) {
-    File srcDir = new File(dir.getAbsolutePath(), "src");
-    File indexJd = new File(dir.getAbsolutePath(), "_index.jd");
-    if (srcDir.exists() && indexJd.exists()) {
+    File indexJd = new File(dir, "_index.jd");
+    if (!indexJd.exists()) {
+      return false;
+    }
+    File srcDir = new File(dir, "src");
+    if (srcDir.exists()) {
       return true;
     } else {
+      // Look for a src/ directory one level below the root directory, so
+      // modules are supported.
+      for (File childDir : dir.listFiles()) {
+        if (childDir.isDirectory()) {
+          srcDir = new File(childDir, "src");
+          if (srcDir.exists()) {
+            return true;
+          }
+        }
+      }
       return false;
     }
   }
-  
-}
\ No newline at end of file
+
+}