Merge "idegen: traversing all vendor-specific excludes"

This commit is contained in:
Treehugger Robot
2022-01-17 12:55:14 +00:00
committed by Gerrit Code Review
3 changed files with 27 additions and 10 deletions

View File

@@ -61,9 +61,9 @@ Excluding source roots and jars
use Java's regular expression parser (see java.util.regex.Parser). use Java's regular expression parser (see java.util.regex.Parser).
You can create your own additional exclusion list by creating an You can create your own additional exclusion list by creating an
"excluded-paths" file in the project's root directory. For example, you "excluded-paths" file in the project's root directory or your vendor
might exclude all apps except the Browser in your IDE configuration with directory. For example, you might exclude all apps except the Browser in your
this regular expression: "^packages/apps/(?!Browser)". IDE configuration with this regular expression: "^packages/apps/(?!Browser)".
Controlling source root ordering (Eclipse) Controlling source root ordering (Eclipse)

View File

@@ -6,7 +6,8 @@
# document the reason for each exclusion. # document the reason for each exclusion.
# #
# Developers can also create an 'excluded-paths' file in the project's root # 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 # 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 # can't have two classes with the same name at once. In the future, we'll

View File

@@ -48,6 +48,9 @@ public class Configuration {
/** File name used for excluded path files. */ /** File name used for excluded path files. */
private static final String EXCLUDED_PATHS = "excluded-paths"; 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 * Constructs a Configuration by traversing the directory tree, looking
* for .java and .jar files and identifying source roots. * for .java and .jar files and identifying source roots.
@@ -91,12 +94,8 @@ public class Configuration {
File globalExcludes = new File(toolDirectory, EXCLUDED_PATHS); File globalExcludes = new File(toolDirectory, EXCLUDED_PATHS);
parseFile(globalExcludes, patterns); parseFile(globalExcludes, patterns);
// Look for Google-specific excludes. // Traverse all vendor-specific directories
// TODO: Traverse all vendor-specific directories. readVendorExcludes(patterns);
File googleExcludes = new File("./vendor/google/" + EXCLUDED_PATHS);
if (googleExcludes.exists()) {
parseFile(googleExcludes, patterns);
}
// Look for user-specific excluded-paths file in current directory. // Look for user-specific excluded-paths file in current directory.
File localExcludes = new File(EXCLUDED_PATHS); File localExcludes = new File(EXCLUDED_PATHS);
@@ -107,6 +106,23 @@ public class Configuration {
return new Excludes(patterns); return new Excludes(patterns);
} }
/**
* 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 * Recursively finds .java source roots, .jar files, and excluded
* directories. * directories.