Skip to content

Commit

Permalink
Brute force workaround for jdk 10 classpath entries being absolute
Browse files Browse the repository at this point in the history
  • Loading branch information
wcurrie committed Nov 8, 2018
1 parent 49f17d4 commit 452042c
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,26 @@ Dependencies buildDependenciesProto(ImmutableList<Path> classpath, boolean succe
.collect(toImmutableList()));

// Filter using the original classpath, to preserve ordering.
// On openjdk 10 entry is a relative Path whilst {explicit,implicit}DependenciesMap keys end up being absolute Paths
for (Path entry : classpath) {
if (explicitDependenciesMap.containsKey(entry)) {
deps.addDependency(explicitDependenciesMap.get(entry));
} else if (explicitDependenciesMap.containsKey(entry.toAbsolutePath())) {
deps.addDependency(withRelativePath(explicitDependenciesMap.get(entry.toAbsolutePath()), entry));
} else if (implicitDependenciesMap.containsKey(entry)) {
deps.addDependency(implicitDependenciesMap.get(entry));
} else if (implicitDependenciesMap.containsKey(entry.toAbsolutePath())) {
deps.addDependency(withRelativePath(implicitDependenciesMap.get(entry.toAbsolutePath()), entry));
}
}
return deps.build();
}

private static Dependency withRelativePath(Dependency dep, Path entry) {
// Eg absolute path has a prefix /private/var/tmp/_bazel_$USER/$HASH/execroot/$PROJECT/
return Dependency.newBuilder(dep).setPath(entry.toString()).build();
}

/** Returns the paths of direct dependencies. */
public ImmutableSet<Path> directJars() {
return directJars;
Expand Down

0 comments on commit 452042c

Please sign in to comment.