@Test public void getOutputDoesNotAccessWrappedJavaLibrary() throws IOException { BuildRuleResolver ruleResolver = new BuildRuleResolver(); SourcePathResolver pathResolver = new SourcePathResolver(ruleResolver); JavaLibrary javaLibrary = (JavaLibrary) JavaLibraryBuilder.createBuilder(BuildTargetFactory.newInstance("//:lib")) .build(ruleResolver); BuildRuleParams params = new FakeBuildRuleParamsBuilder(BuildTargetFactory.newInstance("//:target")).build(); DexProducedFromJavaLibrary dexProducedFromJavaLibrary = new DexProducedFromJavaLibrary(params, pathResolver, javaLibrary); ObjectMapper mapper = new ObjectMapper(); FakeOnDiskBuildInfo onDiskBuildInfo = new FakeOnDiskBuildInfo() .putMetadata(DexProducedFromJavaLibrary.LINEAR_ALLOC_KEY_ON_DISK_METADATA, "0") .putMetadata( DexProducedFromJavaLibrary.CLASSNAMES_TO_HASHES, mapper.writeValueAsString(ImmutableMap.<String, String>of())); initialize(dexProducedFromJavaLibrary, onDiskBuildInfo); assertFalse(dexProducedFromJavaLibrary.hasOutput()); }
@Test public void testClasspathTransitiveDepsBecomeFirstOrderDeps() { BuildRuleResolver ruleResolver = new BuildRuleResolver(); BuildRule transitiveDep = JavaLibraryBuilder.createBuilder(BuildTargetFactory.newInstance("//exciting:dep")) .addSrc(Paths.get("Dep.java")) .build(ruleResolver); BuildRule dep = JavaLibraryBuilder.createBuilder(BuildTargetFactory.newInstance("//exciting:target")) .addSrc(Paths.get("Other.java")) .addDep(transitiveDep.getBuildTarget()) .build(ruleResolver); Genrule genrule = (Genrule) GenruleBuilder.newGenruleBuilder(BuildTargetFactory.newInstance("//:rule")) .setOut("out") .setCmd("$(classpath //exciting:target)") .build(ruleResolver); assertThat(genrule.getDeps(), Matchers.containsInAnyOrder(dep, transitiveDep)); }