diff --git a/tools/idegen/README b/tools/idegen/README index d9444408e..821559b19 100644 --- a/tools/idegen/README +++ b/tools/idegen/README @@ -61,9 +61,9 @@ Excluding source roots and jars 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 9122c3020..a5dd3040e 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 e92b58eb2..679269f75 100644 --- a/tools/idegen/src/Configuration.java +++ b/tools/idegen/src/Configuration.java @@ -48,6 +48,9 @@ public class Configuration { /** 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 @@ public class Configuration { 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); @@ -107,6 +106,23 @@ public class Configuration { return new Excludes(patterns); } + /** + * Reads vendor excluded path files. + * @see #readExcludes() + */ + private static void readVendorExcludes(List 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.