facebook / buck2

Build system, successor to Buck

Home Page:https://buck2.build/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Java rules don't appear to be usable in OSS edition of buck2

zjturner opened this issue · comments

I tried to use java_binary(). I was pretty quickly hit with an error about one of my provider fields (JavaToolchainInfo.fat_jar) being unset, so I looked into what it might be expecting, and found this.

args = [
java_toolchain.fat_jar[RunInfo],
"--jar_builder_tool",
cmd_args(java_toolchain.jar_builder, delimiter = " "),
"--output",
output.as_output(),
"--jars_file",
ctx.actions.write("jars_file", jars),
]

Whatever tool this is doesn't appear to be a standard JRE tool, and I suspect it's a Meta internal tool. Which means all of the Java rules don't work outside of Meta. Is my hunch correct about this, or is there a way to get this tool?

Yeah, that's correct. Java rules are not yet properly supported unfortunately

That’s too bad. Can you shed some light on why? What kind of use cases does meta have for which the jre alone isn’t sufficient to build everything you need to build?

Disclaimer: I don't work at meta, I don't actually know what goes on upstream.

My understanding is that the prelude shipping here is a subset of the actual prelude meta uses, with stuff that relies on their infra ripped out. If Java rules aren't working, I imagine the parts that are needed to make it work are meta-specific, and therefore, haven't ended up here.

It does mean that folks can make them work, and then send PRs to fix it, but it's not going to be a drop-in experience like with other languages.

Yea, I understand that. In this case, the first error I ran into is that there is a tool missing. The tool has command line arguments like --jar_builder and presumably takes some inputs and produces a jar, if the name and command line options are any indication. So it would just be interesting to know, for example, what aspects of building a jar does the jre fall short in? If someone were to come along and want to make the java rules open-source friendly while also being compatible with meta internal stuff, is it impossible? What would need to be done? Is there any path forward to having a usable set of OSS java rules short of waiting for someone at Meta to do the work?