Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buck2 : Is java supported as a part of buck2 #610

Open
nagwww opened this issue Mar 20, 2024 · 2 comments
Open

buck2 : Is java supported as a part of buck2 #610

nagwww opened this issue Mar 20, 2024 · 2 comments

Comments

@nagwww
Copy link

nagwww commented Mar 20, 2024

Hi,
We want to utilize Buck2 to construct our Java apps. we are having trouble coming up with a "Hello world" for Java.

Could you kindly assist us in the appropriate route for bootstrapping a Java application in Buck2?

Thanks, Nag

@nagwww nagwww changed the title buc2 : Is java supported as a part of buck2 buck2 : Is java supported as a part of buck2 Mar 20, 2024
@nagwww
Copy link
Author

nagwww commented Mar 29, 2024

This is the config I tried for creating a hello world application in Java

 java_binary(
    name = "main",
    main_class = "Main",
    deps = [":print"],
)

java_library(
    name = "print",
    srcs = ["Main.java"],
) 

Using the latest version of buck2 ( Downloaded from https://github.com/facebook/buck2/releases/tag/latest ) This was updated like 14 hours back.

$ ./buck2-x86_64-apple-darwin build //:main

Getting the following error

buck2-x86_64-apple-darwin build //:main
File changed: prelude//toolchains/demo.bzl
Build ID: e40e9b95-b558-4faf-a75d-00db9f8cc0ab
Jobs completed: 4. Time elapsed: 0.1s.
BUILD FAILED
Error running analysis for `root//:main (prelude//platforms:default#f6691640831d48dd)`

Caused by:
    0: Error looking up configured node root//:main (prelude//platforms:default#f6691640831d48dd)
    1: Error looking up configured node toolchains//:java (prelude//platforms:default#f6691640831d48dd) (prelude//platforms:default#f6691640831d48dd)
    2: looking up unconfigured target node `toolchains//:java`
    3: Unknown target `java` from package `toolchains//`.
       Did you mean one of the 9 targets in toolchains//:BUCK?
       Maybe you meant one of these similar targets?
         toolchains//:cxx
         toolchains//:go
         toolchains//:ocaml
         toolchains//:rust

I was trying to look at the examples provided for cxx and implement the same for java. cxx works great for the example provided here https://github.com/facebook/buck2/blob/main/examples/hello_world/BUCK

It looks like it has rules in prelude folder, but no toolchain wrapper for java.

Was really hoping to get some guidance / pointer to create a wrapper for java. Hoping to send out a PR to buck2 so this would help out the buck2 community.

Thanks and looking forward to get some guidance on creating a toolchain/wrapper for java.

Kind regards,
Nag

@ndmitchell
Copy link
Contributor

CC @IanChilds @cjhopman who work on our Java version internally. My latest understanding is that we don't have things working externally with Java, as the toolchain requires pieces of Buck1 that, while open sourced, are basically impossible to use open source since they require careful compilation.

I wonder if we can possibly provide a binary of the Java pieces on the toolchain in the meantime to get people to experiment with open source?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants