idegen: traversing all vendor-specific excludes
Allow vendors to have your own idegen "excluded-paths" files.
Change-Id: I842ce4f89bcb43a8bcfde827e4683d11c29f0624
diff --git a/tools/idegen/README b/tools/idegen/README
index d944440..821559b 100644
--- a/tools/idegen/README
+++ b/tools/idegen/README
@@ -61,9 +61,9 @@
use Java's regular expression parser (see java.util.regex.Parser).
You can create your own additional exclusion list by creating an
- "excluded-paths" file in the project's root directory. For example, you
- might exclude all apps except the Browser in your IDE configuration with
- this regular expression: "^packages/apps/(?!Browser)".
+ "excluded-paths" file in the project's root directory or your vendor
+ directory. For example, you might exclude all apps except the Browser in your
+ IDE configuration with this regular expression: "^packages/apps/(?!Browser)".
Controlling source root ordering (Eclipse)
diff --git a/tools/idegen/excluded-paths b/tools/idegen/excluded-paths
index 9122c30..a5dd304 100644
--- a/tools/idegen/excluded-paths
+++ b/tools/idegen/excluded-paths
@@ -6,7 +6,8 @@
# document the reason for each exclusion.
#
# Developers can also create an 'excluded-paths' file in the project's root
-# directory and add their own excludes to slim down their build.
+# directory or their vendor directory and add their own excludes to slim
+# down their build.
#
# Currently, we lump all the .java files together into one big module, so you
# can't have two classes with the same name at once. In the future, we'll
diff --git a/tools/idegen/src/Configuration.java b/tools/idegen/src/Configuration.java
index e92b58e..679269f 100644
--- a/tools/idegen/src/Configuration.java
+++ b/tools/idegen/src/Configuration.java
@@ -48,6 +48,9 @@
/** File name used for excluded path files. */
private static final String EXCLUDED_PATHS = "excluded-paths";
+ /** The vendor directory. */
+ private static final String VENDOR_PATH = "./vendor/";
+
/**
* Constructs a Configuration by traversing the directory tree, looking
* for .java and .jar files and identifying source roots.
@@ -91,12 +94,8 @@
File globalExcludes = new File(toolDirectory, EXCLUDED_PATHS);
parseFile(globalExcludes, patterns);
- // Look for Google-specific excludes.
- // TODO: Traverse all vendor-specific directories.
- File googleExcludes = new File("./vendor/google/" + EXCLUDED_PATHS);
- if (googleExcludes.exists()) {
- parseFile(googleExcludes, patterns);
- }
+ // Traverse all vendor-specific directories
+ readVendorExcludes(patterns);
// Look for user-specific excluded-paths file in current directory.
File localExcludes = new File(EXCLUDED_PATHS);
@@ -108,6 +107,23 @@
}
/**
+ * Reads vendor excluded path files.
+ * @see #readExcludes()
+ */
+ private static void readVendorExcludes(List<Pattern> out) throws IOException {
+ File vendorDir = new File(VENDOR_PATH);
+ File[] vendorList;
+ if (!vendorDir.exists() || (vendorList = vendorDir.listFiles()) == null) return;
+ for (File vendor : vendorList) {
+ File vendorExcludes = new File(vendor, EXCLUDED_PATHS);
+ if (vendorExcludes.exists()) {
+ Log.info("Read vendor excludes: " + vendorExcludes.getPath());
+ parseFile(vendorExcludes, out);
+ }
+ }
+ }
+
+ /**
* Recursively finds .java source roots, .jar files, and excluded
* directories.
*/