buck2 icon indicating copy to clipboard operation
buck2 copied to clipboard

How to build Java libraries/binaries?

Open 0xAda opened this issue 2 years ago • 8 comments

I've been experimenting with buck2 but I've been struggling to find any information on building Java. A simple java_library rule fails to build

java_library(
    name = 'main',
    srcs = ['Main.java'],
)
Error running analysis for `root//:main (prelude//platforms:default#524f8da68ea2a374)`

Caused by:
    0: Error looking up configured node root//:main (prelude//platforms:default#524f8da68ea2a374)
    1: Error getting configuration node of `prelude//runtime/constraints:android-host-test` within the `prelude//platforms:default#524f8da68ea2a374` configuration
    2: Error running analysis for `prelude//runtime/constraints:android-host-test (<unbound>)`
    3: Error looking up configured node prelude//runtime/constraints:android-host-test (<unbound>)
    4: looking up unconfigured target node `prelude//runtime/constraints:android-host-test`
    5: Error loading targets in package `prelude//runtime/constraints` for target `prelude//runtime/constraints:android-host-test`
    6: Error gathering package listing for `prelude//runtime/constraints`
    7: The package is invalid
    8: This error was caused by the end user
    9: Error listing dir `prelude//runtime/constraints`
   10: Error listing directory
   11: read_dir(/tmp/buck2test/prelude/runtime/constraints)
   12: No such file or directory (os error 2)
Build ID: fedd29e4-2e88-42b8-aa74-d133c81e21db
Jobs completed: 46. Time elapsed: 0.1s.
BUILD FAILED

I'm not 100% sure what this error is caused by, I assume I need to configure a java toolchain, but I can't find anything to reference on how to do this. Is there documentation on this or projects to reference?

0xAda avatar Aug 19 '23 21:08 0xAda

We currently have Java working internally, but haven't yet got an example open source instance working. It might be only a few lines away, it might already work (but probably not given your notes) or it might be a huge amount of work. CC @IanChilds who might have a better idea how far away it is.

ndmitchell avatar Aug 21 '23 10:08 ndmitchell

@0xAda, @ndmitchell Any updates on this (Java builds)?

oscarvarto avatar Nov 10 '23 05:11 oscarvarto

@ndmitchell Any updates on java/jvm builds? Or any examples for Java?

heimashi avatar Nov 22 '23 12:11 heimashi

Still not I'm afraid. CC @IanChilds who might have a better idea. It's still being worked on.

ndmitchell avatar Nov 22 '23 22:11 ndmitchell

Same question here as OP, @0xAda, as well as PHP, and many other languages. I'm having trouble finding clarification on the polyglot angle.

qualeo avatar Dec 09 '23 19:12 qualeo

Internally we support a lot of languages - you can see their code in the prelude directory - https://github.com/facebook/buck2/tree/main/prelude. We have made a number of them work externally - you can see the test cases in https://github.com/facebook/buck2/tree/main/examples/with_prelude (C++, Haskell, Python, Rust, OCaml). We are actively working on making a number of internally-only ones work open-source, such as Java, Android, Apple.

We have no rules for languages such as PHP. We wouldn't be averse to adding them one day, as a user contribution.

ndmitchell avatar Dec 17 '23 20:12 ndmitchell