Search in sources :

Example 6 with JavaLibraryBuilder

use of com.facebook.buck.jvm.java.JavaLibraryBuilder in project buck by facebook.

the class ActionGraphCacheTest method createTargetNode.

private TargetNode<?, ?> createTargetNode(String name, TargetNode<?, ?>... deps) {
    BuildTarget buildTarget = BuildTargetFactory.newInstance("//foo:" + name);
    JavaLibraryBuilder targetNodeBuilder = JavaLibraryBuilder.createBuilder(buildTarget);
    for (TargetNode<?, ?> dep : deps) {
        targetNodeBuilder.addDep(dep.getBuildTarget());
    }
    return targetNodeBuilder.build();
}
Also used : BuildTarget(com.facebook.buck.model.BuildTarget) JavaLibraryBuilder(com.facebook.buck.jvm.java.JavaLibraryBuilder)

Example 7 with JavaLibraryBuilder

use of com.facebook.buck.jvm.java.JavaLibraryBuilder in project buck by facebook.

the class BuildRuleResolverTest method testRequireExistingBuildRule.

@Test
public void testRequireExistingBuildRule() throws Exception {
    BuildTarget target = BuildTargetFactory.newInstance("//foo:bar");
    JavaLibraryBuilder builder = JavaLibraryBuilder.createBuilder(target);
    TargetNode<?, ?> library = builder.build();
    TargetGraph targetGraph = TargetGraphFactory.newInstance(library);
    BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
    BuildRule existing = builder.build(resolver);
    assertThat(resolver.getRuleOptional(target).isPresent(), is(true));
    BuildRule rule = resolver.requireRule(target);
    assertThat(rule, is(notNullValue()));
    assertThat(rule.getBuildTarget(), is(equalTo(target)));
    assertThat(rule, is(equalTo(existing)));
}
Also used : BuildTarget(com.facebook.buck.model.BuildTarget) JavaLibraryBuilder(com.facebook.buck.jvm.java.JavaLibraryBuilder) Test(org.junit.Test)

Example 8 with JavaLibraryBuilder

use of com.facebook.buck.jvm.java.JavaLibraryBuilder in project buck by facebook.

the class VersionedTargetGraphTest method createTargetNode.

private TargetNode<?, ?> createTargetNode(String name, TargetNode<?, ?>... deps) {
    BuildTarget buildTarget = BuildTargetFactory.newInstance("//foo:" + name);
    JavaLibraryBuilder targetNodeBuilder = JavaLibraryBuilder.createBuilder(buildTarget);
    // Use the selected versions field to embed the original build target name.  We'll use this to
    // verify the correct node was recovered from the target graph.
    targetNodeBuilder.setSelectedVersions(ImmutableMap.of(buildTarget, Version.of("1.0")));
    for (TargetNode<?, ?> dep : deps) {
        targetNodeBuilder.addDep(dep.getBuildTarget());
    }
    return targetNodeBuilder.build();
}
Also used : BuildTarget(com.facebook.buck.model.BuildTarget) JavaLibraryBuilder(com.facebook.buck.jvm.java.JavaLibraryBuilder)

Aggregations

JavaLibraryBuilder (com.facebook.buck.jvm.java.JavaLibraryBuilder)8 BuildTarget (com.facebook.buck.model.BuildTarget)6 Test (org.junit.Test)4 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)2 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)2 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)2 Path (java.nio.file.Path)2 ArchiveMemberPath (com.facebook.buck.io.ArchiveMemberPath)1 DefaultRuleKeyFactory (com.facebook.buck.rules.keys.DefaultRuleKeyFactory)1 FakeFileHashCache (com.facebook.buck.testutil.FakeFileHashCache)1 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)1 DefaultFileHashCache (com.facebook.buck.util.cache.DefaultFileHashCache)1 FileHashCache (com.facebook.buck.util.cache.FileHashCache)1 NullFileHashCache (com.facebook.buck.util.cache.NullFileHashCache)1 StackedFileHashCache (com.facebook.buck.util.cache.StackedFileHashCache)1 File (java.io.File)1 Before (org.junit.Before)1