diff options
-rw-r--r-- | java/com/google/turbine/deps/Dependencies.java | 7 | ||||
-rw-r--r-- | javatests/com/google/turbine/deps/DependenciesTest.java | 3 |
2 files changed, 9 insertions, 1 deletions
diff --git a/java/com/google/turbine/deps/Dependencies.java b/java/com/google/turbine/deps/Dependencies.java index 4235bc2..92193e8 100644 --- a/java/com/google/turbine/deps/Dependencies.java +++ b/java/com/google/turbine/deps/Dependencies.java @@ -184,11 +184,18 @@ public class Dependencies { /** * Filters a transitive classpath to contain only the entries for direct dependencies, and the * types needed to compile those direct deps as reported by jdeps. + * + * <p>If no direct dependency information is available the full transitive classpath is returned. */ public static Collection<String> reduceClasspath( ImmutableList<String> transitiveClasspath, ImmutableSet<String> directJars, ImmutableList<String> depsArtifacts) { + if (directJars.isEmpty()) { + // the compilation doesn't support strict deps (e.g. proto libraries) + // TODO(cushon): make this a usage error + return transitiveClasspath; + } Set<String> reduced = new HashSet<>(directJars); for (String path : depsArtifacts) { DepsProto.Dependencies.Builder deps = DepsProto.Dependencies.newBuilder(); diff --git a/javatests/com/google/turbine/deps/DependenciesTest.java b/javatests/com/google/turbine/deps/DependenciesTest.java index 213a28b..65480e4 100644 --- a/javatests/com/google/turbine/deps/DependenciesTest.java +++ b/javatests/com/google/turbine/deps/DependenciesTest.java @@ -256,7 +256,8 @@ public class DependenciesTest { "j.jar"); ImmutableSet<String> directJars = ImmutableSet.of(); ImmutableList<String> depsArtifacts = ImmutableList.of(); - assertThat(Dependencies.reduceClasspath(classpath, directJars, depsArtifacts)).isEmpty(); + assertThat(Dependencies.reduceClasspath(classpath, directJars, depsArtifacts)) + .containsExactlyElementsIn(classpath); } @Test |