diff options
author | 2016-06-02 11:38:11 +0000 | |
---|---|---|
committer | 2016-06-02 15:41:50 +0000 | |
commit | 0b5d61fe0722b71a63b9756f8687d1ce2e380072 (patch) | |
tree | 456c888d1e0c5941cf508dc5834111d97569e709 /src/main/java/com/google/devtools/build/lib/rules | |
parent | 3e2a33ab7a2f7b311e6f7a20fc0a8b756e9511aa (diff) |
Rollback of commit 4ab4f05a8cbbaa4b7d938d1d305961fe95a5416c.
--
MOS_MIGRATED_REVID=123851529
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/java/JavaUtil.java | 46 |
1 files changed, 3 insertions, 43 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaUtil.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaUtil.java index e5677d813e..c4f95fe22c 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaUtil.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaUtil.java @@ -61,13 +61,8 @@ public final class JavaUtil { } /** - * Finds the index of the segment in a Java path fragment that precedes the source root. - * Starts from the first "java" or "javatests" or "src" segment. - * If the found item was "src", check if this is followed by "main" or "test" and then "java" - * or "resources" (maven layout). - * If the found item was "src", or "java"/"javatests" at the first segment, check for a nested - * root directory (src, java or javatests). A nested root must be followed by (com|net|org), - * or matching maven structure for nested "src", to be accepted, to avoid false positives. + * Find the index of the "java" or "javatests" segment in a Java path fragment + * that precedes the source root. * * @param path a Java source dir or file path * @return the index of the java segment or -1 iff no java segment was found. @@ -76,42 +71,7 @@ public final class JavaUtil { if (path.isAbsolute()) { throw new IllegalArgumentException("path must not be absolute: '" + path + "'"); } - int rootIndex = path.getFirstSegment(ImmutableSet.of("java", "javatests", "src")); - if (rootIndex < 0) { - return rootIndex; - } - final boolean isSrc = "src".equals(path.getSegment(rootIndex)); - int checkMavenIndex = isSrc ? rootIndex : -1; - if (rootIndex == 0 || isSrc) { - // Check for a nested "src" directory. - // Also, to support an existing case, "javatests" within "src". - for (int i = rootIndex + 1, max = path.segmentCount() - 2; i <= max; i++) { - String segment = path.getSegment(i); - if ("src".equals(segment) - || (isSrc && ("javatests".equals(segment) || "java".equals(segment)))) { - String next = path.getSegment(i + 1); - if ("com".equals(next) || "org".equals(next) || "net".equals(next)) { - // Check for common first element of java package, to avoid false positives. - rootIndex = i; - } else if ("src".equals(segment)) { - // Also accept maven style src/(main|test)/(java|resources). - checkMavenIndex = i; - } - break; - } - } - } - // Check for (main|test)/(java|resources) after /src/. - if (checkMavenIndex >= 0 && checkMavenIndex + 2 < path.segmentCount()) { - String next = path.getSegment(checkMavenIndex + 1); - if ("main".equals(next) || "test".equals(next)) { - next = path.getSegment(checkMavenIndex + 2); - if ("java".equals(next) || "resources".equals(next)) { - rootIndex = checkMavenIndex + 2; - } - } - } - return rootIndex; + return path.getFirstSegment(ImmutableSet.of("java", "javatests")); } /** |