diff options
-rw-r--r-- | src/java_tools/buildjar/java/com/google/devtools/build/buildjar/ReducedClasspathJavaLibraryBuilder.java | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/ReducedClasspathJavaLibraryBuilder.java b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/ReducedClasspathJavaLibraryBuilder.java index 81eaf60fdd..9f12705641 100644 --- a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/ReducedClasspathJavaLibraryBuilder.java +++ b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/ReducedClasspathJavaLibraryBuilder.java @@ -51,6 +51,13 @@ public class ReducedClasspathJavaLibraryBuilder extends SimpleJavaLibraryBuilder compressedClasspath = build.getDependencyModule().computeStrictClasspath(build.getClassPath()); } + if (compressedClasspath.isEmpty()) { + // If the empty classpath is specified and javac is invoked programatically, + // javac falls back to using the host classpath. We don't want JavaBuilder + // to leak onto the compilation classpath, so we add the (hopefully empty) + // class output directory to prevent that from happening. + compressedClasspath = build.getClassDir(); + } String[] javacArguments = makeJavacArguments(build, compressedClasspath); // Compile! |