Search in sources :

Example 1 with PythonLibraryBuilder

use of com.facebook.buck.python.PythonLibraryBuilder in project buck by facebook.

the class MavenUberJarTest method onlyJavaDepsIncluded.

@Test
public void onlyJavaDepsIncluded() throws NoSuchBuildTargetException {
    BuildTarget pythonTarget = BuildTargetFactory.newInstance("//:python");
    BuildTarget javaTarget = BuildTargetFactory.newInstance("//:java");
    PythonLibraryBuilder pythonLibraryBuilder = PythonLibraryBuilder.createBuilder(pythonTarget);
    JavaLibraryBuilder javaLibraryBuilder = JavaLibraryBuilder.createBuilder(javaTarget).addResource(new DefaultBuildTargetSourcePath(pythonTarget));
    TargetGraph targetGraph = TargetGraphFactory.newInstance(pythonLibraryBuilder.build(), javaLibraryBuilder.build());
    BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
    PythonLibrary pythonLibrary = pythonLibraryBuilder.build(resolver, filesystem, targetGraph);
    JavaLibrary javaLibrary = javaLibraryBuilder.build(resolver, filesystem, targetGraph);
    MavenUberJar buildRule = MavenUberJar.create(javaLibrary, javaLibraryBuilder.createBuildRuleParams(resolver, filesystem), Optional.of("com.facebook.buck.jvm.java:java:jar:42"), Optional.empty());
    assertThat(buildRule.getDeps(), Matchers.not(Matchers.hasItem(pythonLibrary)));
}
Also used : PythonLibrary(com.facebook.buck.python.PythonLibrary) BuildTarget(com.facebook.buck.model.BuildTarget) PythonLibraryBuilder(com.facebook.buck.python.PythonLibraryBuilder) TargetGraph(com.facebook.buck.rules.TargetGraph) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) DefaultBuildTargetSourcePath(com.facebook.buck.rules.DefaultBuildTargetSourcePath) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) Test(org.junit.Test)

Example 2 with PythonLibraryBuilder

use of com.facebook.buck.python.PythonLibraryBuilder in project buck by facebook.

the class LuaBinaryDescriptionTest method pythonDeps.

@Test
public void pythonDeps() throws Exception {
    PythonLibraryBuilder pythonLibraryBuilder = new PythonLibraryBuilder(BuildTargetFactory.newInstance("//:dep")).setSrcs(SourceList.ofUnnamedSources(ImmutableSortedSet.of(new FakeSourcePath("foo.py"))));
    LuaBinaryBuilder luaBinaryBuilder = new LuaBinaryBuilder(BuildTargetFactory.newInstance("//:rule")).setMainModule("hello.world").setDeps(ImmutableSortedSet.of(pythonLibraryBuilder.getTarget()));
    TargetGraph targetGraph = TargetGraphFactory.newInstance(pythonLibraryBuilder.build(), luaBinaryBuilder.build());
    ProjectFilesystem filesystem = new FakeProjectFilesystem();
    BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
    pythonLibraryBuilder.build(resolver, filesystem, targetGraph);
    LuaBinary luaBinary = luaBinaryBuilder.build(resolver, filesystem, targetGraph);
    assertThat(luaBinary.getComponents().getPythonModules().keySet(), Matchers.hasItem("foo.py"));
}
Also used : FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) PythonLibraryBuilder(com.facebook.buck.python.PythonLibraryBuilder) TargetGraph(com.facebook.buck.rules.TargetGraph) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) Test(org.junit.Test)

Example 3 with PythonLibraryBuilder

use of com.facebook.buck.python.PythonLibraryBuilder in project buck by facebook.

the class LuaBinaryDescriptionTest method pythonInitIsRuntimeDepForInPlaceBinary.

@Test
public void pythonInitIsRuntimeDepForInPlaceBinary() throws Exception {
    PythonLibraryBuilder pythonLibraryBuilder = new PythonLibraryBuilder(BuildTargetFactory.newInstance("//:dep")).setSrcs(SourceList.ofUnnamedSources(ImmutableSortedSet.of(new FakeSourcePath("foo.py"))));
    LuaBinaryBuilder luaBinaryBuilder = new LuaBinaryBuilder(BuildTargetFactory.newInstance("//:rule")).setMainModule("hello.world").setPackageStyle(LuaConfig.PackageStyle.INPLACE).setDeps(ImmutableSortedSet.of(pythonLibraryBuilder.getTarget()));
    TargetGraph targetGraph = TargetGraphFactory.newInstance(pythonLibraryBuilder.build(), luaBinaryBuilder.build());
    ProjectFilesystem filesystem = new FakeProjectFilesystem();
    BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
    pythonLibraryBuilder.build(resolver, filesystem, targetGraph);
    LuaBinary luaBinary = luaBinaryBuilder.build(resolver, filesystem, targetGraph);
    assertThat(luaBinary.getRuntimeDeps().collect(MoreCollectors.toImmutableSet()), Matchers.hasItem(PythonBinaryDescription.getEmptyInitTarget(luaBinary.getBuildTarget())));
}
Also used : FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) PythonLibraryBuilder(com.facebook.buck.python.PythonLibraryBuilder) TargetGraph(com.facebook.buck.rules.TargetGraph) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) Test(org.junit.Test)

Aggregations

PythonLibraryBuilder (com.facebook.buck.python.PythonLibraryBuilder)3 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)3 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)3 TargetGraph (com.facebook.buck.rules.TargetGraph)3 Test (org.junit.Test)3 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)2 FakeSourcePath (com.facebook.buck.rules.FakeSourcePath)2 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)2 BuildTarget (com.facebook.buck.model.BuildTarget)1 PythonLibrary (com.facebook.buck.python.PythonLibrary)1 DefaultBuildTargetSourcePath (com.facebook.buck.rules.DefaultBuildTargetSourcePath)1