diff options
author | tomlu <tomlu@google.com> | 2018-02-28 19:15:42 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-02-28 19:18:35 -0800 |
commit | 5905e410cf9ba262643951c9e71de048612f4a74 (patch) | |
tree | ca2bc639bb5d11717853bf4f2aa24dff4328aef1 /src/java_tools/buildjar | |
parent | 38a36ccd369e66a8a9bca8e6753d342a1cec05a1 (diff) |
Change the strict deps plugin to read jar owner from manifest.
The plugin tries to read the following attributes:
Target-Label: <label>
Injecting-Rule-Kind: <rule kind>
These are used instead of the jar owners passed to JavaBuilder from blaze. Any owners currently passed from blaze are now ignored.
This CL also half-reverts the command line syntax for JavaBuilder and Turbine. It is now:
--classpath <jar1> <jar2> ...
--direct_dependencies <jar1> ...
RELNOTES: None
PiperOrigin-RevId: 187419469
Diffstat (limited to 'src/java_tools/buildjar')
7 files changed, 74 insertions, 153 deletions
diff --git a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/JavaLibraryBuildRequest.java b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/JavaLibraryBuildRequest.java index 101d8b6c0b..a567af749f 100644 --- a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/JavaLibraryBuildRequest.java +++ b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/JavaLibraryBuildRequest.java @@ -16,7 +16,6 @@ package com.google.devtools.build.buildjar; import static com.google.common.base.MoreObjects.firstNonNull; import static com.google.common.collect.ImmutableList.toImmutableList; -import static com.google.common.collect.ImmutableMap.toImmutableMap; import static com.google.common.collect.ImmutableSet.toImmutableSet; import com.google.common.base.Joiner; @@ -111,12 +110,6 @@ public final class JavaLibraryBuildRequest { throws InvalidCommandLineException, IOException { depsBuilder.setDirectJars( optionsParser.directJars().stream().map(Paths::get).collect(toImmutableSet())); - depsBuilder.setJarsToTargets( - optionsParser - .jarsToTargets() - .entrySet() - .stream() - .collect(toImmutableMap(e -> Paths.get(e.getKey()), e -> e.getValue()))); if (optionsParser.getStrictJavaDeps() != null) { depsBuilder.setStrictJavaDeps(optionsParser.getStrictJavaDeps()); } diff --git a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/OptionsParser.java b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/OptionsParser.java index 8eb700d829..5c1856ba54 100644 --- a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/OptionsParser.java +++ b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/OptionsParser.java @@ -16,7 +16,6 @@ package com.google.devtools.build.buildjar; import static java.nio.charset.StandardCharsets.UTF_8; -import com.google.common.base.Preconditions; import com.google.common.base.Splitter; import com.google.common.collect.Iterables; import java.io.File; @@ -27,7 +26,6 @@ import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collection; import java.util.Deque; -import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; @@ -42,10 +40,8 @@ import javax.annotation.Nullable; * command-line flags and options files and provides them via getters. */ public final class OptionsParser { - private static final Splitter SPACE_SPLITTER = Splitter.on(' '); private final List<String> javacOpts = new ArrayList<>(); - private final Map<String, JarOwner> jarsToTargets = new HashMap<>(); private final Set<String> directJars = new HashSet<>(); private String strictJavaDeps; @@ -111,10 +107,6 @@ public final class OptionsParser { readJavacopts(javacOpts, argQueue); sourcePathFromJavacOpts(); break; - case "--dependencies": - collectDependencies(classPath, jarsToTargets, argQueue, arg, "--"); - foundNewDependencyArgument = true; - break; case "--direct_dependencies": collectFlagArguments(directJars, argQueue, "--"); foundNewDependencyArgument = true; @@ -123,18 +115,16 @@ public final class OptionsParser { { // TODO(b/72379900): Remove this String jar = getArgument(argQueue, arg); - JarOwner owner = parseJarOwnerLegacy(getArgument(argQueue, arg)); + getArgument(argQueue, arg); directJars.add(jar); - jarsToTargets.put(jar, owner); foundLegacyDependencyArgument = true; break; } case "--indirect_dependency": { // TODO(b/72379900): Remove this - String jar = getArgument(argQueue, arg); - JarOwner owner = parseJarOwnerLegacy(getArgument(argQueue, arg)); - jarsToTargets.put(jar, owner); + getArgument(argQueue, arg); + getArgument(argQueue, arg); foundLegacyDependencyArgument = true; break; } @@ -172,9 +162,7 @@ public final class OptionsParser { collectFlagArguments(sourceJars, argQueue, "-"); break; case "--classpath": - // TODO(b/72379900): Remove this collectFlagArguments(classPath, argQueue, "-"); - foundLegacyDependencyArgument = true; break; case "--sourcepath": // TODO(#970): Consider whether we want to use --sourcepath for resolving of #970. @@ -230,8 +218,8 @@ public final class OptionsParser { throw new InvalidCommandLineException( "Found both new-style and old-style dependency arguments: " + "Cannot use arguments from both " - + "(--dependencies, --direct_dependencies) and " - + "(--direct_dependency, --indirect_dependency, --classpath) " + + "(--direct_dependencies) and " + + "(--direct_dependency, --indirect_dependency) " + "at the same time."); } } @@ -248,58 +236,6 @@ public final class OptionsParser { } } - private static void collectDependencies( - Collection<String> classPath, - Map<String, JarOwner> jarsToTargets, - Deque<String> args, - String arg, - String terminatorPrefix) - throws InvalidCommandLineException { - while (true) { - String nextArg = args.pollFirst(); - if (nextArg == null) { - break; - } - if (nextArg.startsWith(terminatorPrefix)) { - args.addFirst(nextArg); - break; - } - String jar = nextArg; - JarOwner jarOwner; - try { - jarOwner = parseJarOwner(args.remove()); - } catch (NoSuchElementException e) { - throw new InvalidCommandLineException(arg + ": missing argument"); - } - classPath.add(jar); - jarsToTargets.put(jar, jarOwner); - } - } - - private static JarOwner parseJarOwner(String line) { - int separatorIndex = line.indexOf(';'); - final JarOwner owner; - if (separatorIndex == -1) { - owner = JarOwner.create(line); - } else { - owner = - JarOwner.create(line.substring(0, separatorIndex), line.substring(separatorIndex + 1)); - } - return owner; - } - - private JarOwner parseJarOwnerLegacy(String line) { - List<String> ownerStringParts = SPACE_SPLITTER.splitToList(line); - JarOwner owner; - Preconditions.checkState(ownerStringParts.size() == 1 || ownerStringParts.size() == 2); - if (ownerStringParts.size() == 1) { - owner = JarOwner.create(ownerStringParts.get(0)); - } else { - owner = JarOwner.create(ownerStringParts.get(0), ownerStringParts.get(1)); - } - return owner; - } - /** * Pre-processes an argument list, expanding options @filename to read in the content of the file * and add it to the list of arguments. @@ -423,10 +359,6 @@ public final class OptionsParser { return directJars; } - public Map<String, JarOwner> jarsToTargets() { - return jarsToTargets; - } - public String getStrictJavaDeps() { return strictJavaDeps; } diff --git a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/dependency/DependencyModule.java b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/dependency/DependencyModule.java index 80842ffaca..d2d9e8f8ca 100644 --- a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/dependency/DependencyModule.java +++ b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/dependency/DependencyModule.java @@ -18,7 +18,6 @@ import static com.google.common.collect.ImmutableList.toImmutableList; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.devtools.build.buildjar.JarOwner; import com.google.devtools.build.buildjar.javac.plugins.BlazeJavaCompilerPlugin; @@ -75,7 +74,6 @@ public final class DependencyModule { private final StrictJavaDeps strictJavaDeps; private final FixTool fixDepsTool; private final ImmutableSet<Path> directJars; - private final ImmutableMap<Path, JarOwner> jarsToTargets; private final boolean strictClasspathMode; private final Set<Path> depsArtifacts; private final String targetLabel; @@ -93,7 +91,6 @@ public final class DependencyModule { StrictJavaDeps strictJavaDeps, FixTool fixDepsTool, ImmutableSet<Path> directJars, - ImmutableMap<Path, JarOwner> jarsToTargets, boolean strictClasspathMode, Set<Path> depsArtifacts, ImmutableSet<Path> platformJars, @@ -104,7 +101,6 @@ public final class DependencyModule { this.strictJavaDeps = strictJavaDeps; this.fixDepsTool = fixDepsTool; this.directJars = directJars; - this.jarsToTargets = jarsToTargets; this.strictClasspathMode = strictClasspathMode; this.depsArtifacts = depsArtifacts; this.targetLabel = targetLabel; @@ -179,11 +175,6 @@ public final class DependencyModule { return directJars; } - /** Returns the mapping from jar paths to {@link JarOwner}s. */ - public Map<Path, JarOwner> jarsToTargets() { - return jarsToTargets; - } - /** Returns the strict dependency checking (strictJavaDeps) setting. */ public StrictJavaDeps getStrictJavaDeps() { return strictJavaDeps; @@ -338,7 +329,6 @@ public final class DependencyModule { private StrictJavaDeps strictJavaDeps = StrictJavaDeps.OFF; private FixTool fixDepsTool = null; private ImmutableSet<Path> directJars = ImmutableSet.of(); - private ImmutableMap<Path, JarOwner> jarsToTargets = ImmutableMap.of(); private final Set<Path> depsArtifacts = new HashSet<>(); private ImmutableSet<Path> platformJars = ImmutableSet.of(); private String targetLabel; @@ -375,7 +365,6 @@ public final class DependencyModule { strictJavaDeps, fixDepsTool, directJars, - jarsToTargets, strictClasspathMode, depsArtifacts, platformJars, @@ -424,12 +413,6 @@ public final class DependencyModule { return this; } - /** Sets the mapping from jar paths to {@link JarOwners}s. */ - public Builder setJarsToTargets(ImmutableMap<Path, JarOwner> jarsToTargets) { - this.jarsToTargets = jarsToTargets; - return this; - } - /** * Sets the name of the file that will contain dependency information in the protocol buffer * format. diff --git a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/dependency/StrictJavaDepsPlugin.java b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/dependency/StrictJavaDepsPlugin.java index 62fe8ddb46..58ebbcfcbc 100644 --- a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/dependency/StrictJavaDepsPlugin.java +++ b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/plugins/dependency/StrictJavaDepsPlugin.java @@ -43,6 +43,7 @@ import com.sun.tools.javac.util.Name; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; +import java.io.UncheckedIOException; import java.nio.file.Path; import java.text.MessageFormat; import java.util.ArrayList; @@ -52,6 +53,9 @@ import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Set; +import java.util.jar.Attributes; +import java.util.jar.JarFile; +import java.util.jar.Manifest; import javax.lang.model.element.AnnotationValue; import javax.lang.model.util.SimpleAnnotationValueVisitor8; import javax.tools.JavaFileObject; @@ -64,6 +68,9 @@ import javax.tools.JavaFileObject; * that come from transitive dependencies (Blaze computes this information). */ public final class StrictJavaDepsPlugin extends BlazeJavaCompilerPlugin { + private static final Attributes.Name TARGET_LABEL = new Attributes.Name("Target-Label"); + private static final Attributes.Name INJECTING_RULE_KIND = + new Attributes.Name("Injecting-Rule-Kind"); @VisibleForTesting static String targetMapping = @@ -230,8 +237,6 @@ public final class StrictJavaDepsPlugin extends BlazeJavaCompilerPlugin { private final ImmutableSet<Path> directJars; - private final Map<Path, JarOwner> jarsToTargets; - /** Strict deps diagnostics. */ private final List<SjdDiagnostic> diagnostics; @@ -249,6 +254,8 @@ public final class StrictJavaDepsPlugin extends BlazeJavaCompilerPlugin { private final Set<JarOwner> seenTargets = new HashSet<>(); + private final Set<Path> seenStrictDepsViolatingJars = new HashSet<>(); + /** The set of jars on the compilation bootclasspath. */ private final Set<Path> platformJars; @@ -264,7 +271,6 @@ public final class StrictJavaDepsPlugin extends BlazeJavaCompilerPlugin { Set<JarOwner> missingTargets, Set<Path> platformJars) { this.directJars = dependencyModule.directJars(); - this.jarsToTargets = dependencyModule.jarsToTargets(); this.strictJavaDepsMode = dependencyModule.getStrictJavaDeps(); this.diagnostics = diagnostics; this.missingTargets = missingTargets; @@ -292,28 +298,32 @@ public final class StrictJavaDepsPlugin extends BlazeJavaCompilerPlugin { /** * Marks the provided dependency as a direct/explicit dependency. Additionally, if - * strict_java_deps is enabled, it emits a [strict] compiler warning/error (behavior to be soon - * replaced by the more complete Blaze implementation). + * strict_java_deps is enabled, it emits a [strict] compiler warning/error. */ private void collectExplicitDependency(Path jarPath, JCTree node, Symbol sym) { if (strictJavaDepsMode.isEnabled() && !isStrictDepsExempt) { // Does it make sense to emit a warning/error for this pair of (type, owner)? // We want to emit only one error/warning per owner. - JarOwner owner = !directJars.contains(jarPath) ? jarsToTargets.get(jarPath) : null; - if (owner != null && seenTargets.add(owner)) { - // owner is of the form "//label/of:rule <Aspect name>" where <Aspect name> is optional. - String canonicalTargetName = canonicalizeTarget(remapTarget(owner.label())); - missingTargets.add(owner); - String toolInfo = - owner.aspect() == null - ? canonicalTargetName - : String.format("%s wrapped in %s", canonicalTargetName, owner.aspect()); - String used = - sym.getSimpleName().contentEquals("package-info") - ? "package " + sym.getEnclosingElement() - : "type " + sym; - String message = MessageFormat.format(TRANSITIVE_DEP_MESSAGE, used, toolInfo); - diagnostics.add(SjdDiagnostic.create(node.pos, message, source)); + if (!directJars.contains(jarPath) && seenStrictDepsViolatingJars.add(jarPath)) { + // IO cost here is fine because we only hit this path for an explicit dependency + // _not_ in the direct jars, i.e. an error + JarOwner owner = readJarOwnerFromManifest(jarPath); + if (owner != null && seenTargets.add(owner)) { + // owner is of the form "//label/of:rule <Aspect name>" where <Aspect name> is + // optional. + String canonicalTargetName = canonicalizeTarget(remapTarget(owner.label())); + missingTargets.add(owner); + String toolInfo = + owner.aspect() == null + ? canonicalTargetName + : String.format("%s wrapped in %s", canonicalTargetName, owner.aspect()); + String used = + sym.getSimpleName().contentEquals("package-info") + ? "package " + sym.getEnclosingElement() + : "type " + sym; + String message = MessageFormat.format(TRANSITIVE_DEP_MESSAGE, used, toolInfo); + diagnostics.add(SjdDiagnostic.create(node.pos, message, source)); + } } } @@ -332,6 +342,25 @@ public final class StrictJavaDepsPlugin extends BlazeJavaCompilerPlugin { } } + private static JarOwner readJarOwnerFromManifest(Path jarPath) { + try (JarFile jarFile = new JarFile(jarPath.toFile())) { + Manifest manifest = jarFile.getManifest(); + if (manifest == null) { + return null; + } + Attributes attributes = manifest.getMainAttributes(); + String label = (String) attributes.get(TARGET_LABEL); + if (label == null) { + return null; + } + String injectingRuleKind = (String) attributes.get(INJECTING_RULE_KIND); + return JarOwner.create(label, injectingRuleKind); + } catch (IOException e) { + // This jar file pretty much has to exist, we just used it in the compiler. Throw unchecked. + throw new UncheckedIOException(e); + } + } + @Override public void visitMethodDef(JCTree.JCMethodDecl method) { if ((method.mods.flags & Flags.GENERATEDCONSTR) != 0) { diff --git a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/testing/InMemoryJavaFileManager.java b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/testing/InMemoryJavaFileManager.java index 31de9832a9..1f278b78c8 100644 --- a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/testing/InMemoryJavaFileManager.java +++ b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/testing/InMemoryJavaFileManager.java @@ -39,8 +39,10 @@ import java.nio.file.attribute.BasicFileAttributes; import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.jar.Attributes; import java.util.jar.JarEntry; import java.util.jar.JarOutputStream; +import java.util.jar.Manifest; import javax.tools.Diagnostic; import javax.tools.DiagnosticCollector; import javax.tools.JavaFileObject; @@ -214,8 +216,19 @@ public class InMemoryJavaFileManager { } public static Path compiledClassesToJar(Path jar, Iterable<CompiledClass> classes) { + return compiledClassesToJar(jar, classes, null); + } + + public static Path compiledClassesToJar( + Path jar, Iterable<CompiledClass> classes, String targetLabel) { + Manifest manifest = new Manifest(); + Attributes attributes = manifest.getMainAttributes(); + attributes.put(Attributes.Name.MANIFEST_VERSION, "1.0"); + if (targetLabel != null) { + attributes.putValue("Target-Label", targetLabel); + } try (OutputStream os = Files.newOutputStream(jar); - final JarOutputStream jos = new JarOutputStream(os)) { + final JarOutputStream jos = new JarOutputStream(os, manifest)) { for (CompiledClass c : classes) { jos.putNextEntry(new JarEntry(c.name().replace('.', '/') + ".class")); jos.write(c.data()); diff --git a/src/java_tools/buildjar/java/com/google/devtools/build/java/turbine/javac/JavacTurbine.java b/src/java_tools/buildjar/java/com/google/devtools/build/java/turbine/javac/JavacTurbine.java index 242bee83e5..c9160fc705 100644 --- a/src/java_tools/buildjar/java/com/google/devtools/build/java/turbine/javac/JavacTurbine.java +++ b/src/java_tools/buildjar/java/com/google/devtools/build/java/turbine/javac/JavacTurbine.java @@ -21,7 +21,6 @@ import com.google.common.base.Joiner; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -import com.google.devtools.build.buildjar.JarOwner; import com.google.devtools.build.buildjar.javac.JavacOptions; import com.google.devtools.build.buildjar.javac.plugins.dependency.DependencyModule; import com.google.devtools.build.buildjar.javac.plugins.dependency.DependencyModule.StrictJavaDeps; @@ -271,17 +270,10 @@ public class JavacTurbine implements AutoCloseable { .setPlatformJars(platformJars) .setStrictJavaDeps(strictDepsMode.toString()); ImmutableSet.Builder<Path> directJars = ImmutableSet.builder(); - ImmutableMap.Builder<Path, JarOwner> jarsToTargets = ImmutableMap.builder(); - for (Map.Entry<String, String> entry : turbineOptions.directJarsToTargets().entrySet()) { - Path path = Paths.get(entry.getKey()); - directJars.add(path); - jarsToTargets.put(path, parseJarOwner(entry.getKey())); - } - for (Map.Entry<String, String> entry : turbineOptions.indirectJarsToTargets().entrySet()) { - jarsToTargets.put(Paths.get(entry.getKey()), parseJarOwner(entry.getValue())); + for (String path : turbineOptions.directJars()) { + directJars.add(Paths.get(path)); } dependencyModuleBuilder.setDirectJars(directJars.build()); - dependencyModuleBuilder.setJarsToTargets(jarsToTargets.build()); if (turbineOptions.outputDeps().isPresent()) { dependencyModuleBuilder.setOutputDepsProtoFile(Paths.get(turbineOptions.outputDeps().get())); } @@ -289,18 +281,6 @@ public class JavacTurbine implements AutoCloseable { return dependencyModuleBuilder.build(); } - private static JarOwner parseJarOwner(String line) { - int separatorIndex = line.indexOf(';'); - final JarOwner owner; - if (separatorIndex == -1) { - owner = JarOwner.create(line); - } else { - owner = - JarOwner.create(line.substring(0, separatorIndex), line.substring(separatorIndex + 1)); - } - return owner; - } - /** Write the class output from a successful compilation to the output jar. */ private static void emitClassJar( TurbineOptions turbineOptions, Map<String, byte[]> files, Map<String, byte[]> transitive) diff --git a/src/java_tools/buildjar/javatests/com/google/devtools/build/java/turbine/javac/JavacTurbineTest.java b/src/java_tools/buildjar/javatests/com/google/devtools/build/java/turbine/javac/JavacTurbineTest.java index d6159d96f5..faa0cc6032 100644 --- a/src/java_tools/buildjar/javatests/com/google/devtools/build/java/turbine/javac/JavacTurbineTest.java +++ b/src/java_tools/buildjar/javatests/com/google/devtools/build/java/turbine/javac/JavacTurbineTest.java @@ -341,9 +341,7 @@ public class JavacTurbineTest extends AbstractJavacTurbineCompilationTest { optionsBuilder.addClassPathEntries( ImmutableList.of(libA.toString(), libB.toString(), libC.toString())); optionsBuilder.addAllDepsArtifacts(ImmutableList.of(depsA.toString())); - optionsBuilder.addDirectJarToTarget(libA.toString(), "//lib:a"); - optionsBuilder.addDirectJarToTarget(libB.toString(), "//lib:b"); - optionsBuilder.addIndirectJarToTarget(libC.toString(), "//lib:c"); + optionsBuilder.addDirectJars(ImmutableList.of(libA.toString(), libB.toString())); optionsBuilder.setTargetLabel("//my:target"); addSourceLines( @@ -482,10 +480,7 @@ public class JavacTurbineTest extends AbstractJavacTurbineCompilationTest { optionsBuilder.addClassPathEntries( ImmutableList.of(libA.toString(), libB.toString(), libC.toString(), libD.toString())); optionsBuilder.addAllDepsArtifacts(ImmutableList.of(depsA.toString())); - optionsBuilder.addDirectJarToTarget(libA.toString(), "//lib:a"); - optionsBuilder.addIndirectJarToTarget(libB.toString(), "//lib:b"); - optionsBuilder.addIndirectJarToTarget(libC.toString(), "//lib:c"); - optionsBuilder.addIndirectJarToTarget(libD.toString(), "//lib:d"); + optionsBuilder.addDirectJars(ImmutableList.of(libA.toString())); optionsBuilder.setTargetLabel("//my:target"); addSourceLines( @@ -576,10 +571,7 @@ public class JavacTurbineTest extends AbstractJavacTurbineCompilationTest { optionsBuilder.addClassPathEntries( ImmutableList.of(libA.toString(), libB.toString(), libC.toString(), libD.toString())); optionsBuilder.addAllDepsArtifacts(ImmutableList.of(depsA.toString())); - optionsBuilder.addDirectJarToTarget(libA.toString(), "//lib:a"); - optionsBuilder.addIndirectJarToTarget(libB.toString(), "//lib:b"); - optionsBuilder.addIndirectJarToTarget(libC.toString(), "//lib:c"); - optionsBuilder.addIndirectJarToTarget(libD.toString(), "//lib:d"); + optionsBuilder.addDirectJars(ImmutableList.of(libA.toString())); optionsBuilder.setTargetLabel("//my:target"); addSourceLines( @@ -1070,7 +1062,7 @@ public class JavacTurbineTest extends AbstractJavacTurbineCompilationTest { "}"); optionsBuilder.addClassPathEntries(Collections.singleton(deps.toString())); - optionsBuilder.addDirectJarToTarget(deps.toString(), "//deps"); + optionsBuilder.addDirectJars(ImmutableList.of(deps.toString())); compile(); Map<String, byte[]> outputs = collectOutputs(); @@ -1092,7 +1084,6 @@ public class JavacTurbineTest extends AbstractJavacTurbineCompilationTest { addSourceLines( "Hello.java", "import " + Lib.class.getCanonicalName() + ";", "class Hello extends Lib {}"); - optionsBuilder.addIndirectJarToTarget(lib.toString(), "//lib"); optionsBuilder.addClassPathEntries(ImmutableList.of(lib.toString())); optionsBuilder.addSources(ImmutableList.copyOf(Iterables.transform(sources, TO_STRING))); |