diff options
author | 2016-05-20 13:19:40 +0000 | |
---|---|---|
committer | 2016-05-20 14:42:25 +0000 | |
commit | cc048cd480cab7e2d080a79264bc72afdeed3f39 (patch) | |
tree | aae50da42f41ac2ca9a58a70ffaf5d5f0f995b40 /src/main/java/com/google/devtools/build/lib | |
parent | 2703dd304d2c047589c6323e8df8098c9f4534e3 (diff) |
Rollback of commit 8375185ee11d573562f98de14bed79a77fcfd728.
--
MOS_MIGRATED_REVID=122825908
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/java/JavaUtil.java | 42 |
1 files changed, 3 insertions, 39 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 60647c2f98..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,11 +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". - * If the found item was at the first segment, check for a nested "src" directory, followed by - * either (main|test)/java or (com|org|net), 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. @@ -74,40 +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) { - // Check for a nested "src" directory. - // Also, to support an existing case, "javatests" within "src". - for (int i = 1, max = path.segmentCount() - 2; i <= max; i++) { - String segment = path.getSegment(i); - if ("src".equals(segment) || (isSrc && "javatests".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. - checkMavenIndex = i; - } - break; - } - } - } - // Check for (main|test)/java after /src/. - if (checkMavenIndex >= 0 && checkMavenIndex + 2 < path.segmentCount()) { - if ("java".equals(path.getSegment(checkMavenIndex + 2))) { - String next = path.getSegment(checkMavenIndex + 1); - if ("main".equals(next) || "test".equals(next)) { - rootIndex = checkMavenIndex + 2; - } - } - } - return rootIndex; + return path.getFirstSegment(ImmutableSet.of("java", "javatests")); } /** |