javabuck

How to add dependencies in BUCK


When I import libraries such as "org.json", I get an error. I know to add the dependencies in POM file if it's a maven project, but it's compiled using BUCK, so how do I add this dependency and it's version in BUCK?


Solution

  • This is covered in the the build rules section of buck docs - https://buck.build/concept/build_rule.html

    For java libraries we would care about java_library - https://buck.build/rule/java_library.html

    e.g

    If we wanted to add the uber cadence library(https://github.com/uber/cadence-java-client) to our project we would add "//3rdparty/jvm/com/uber/cadence:cadence-client-2.7.8.jar" to the deps section of our BUCK file and then run ./buckw project [project-name] to compile or use the buck ide plugin to run ./buckw project within the ide

    add to BUCK file

    java_library(
      ...
      deps = [
        ...
        "//third_party/cadence:cadence-client-2.7.8.jar",
      ],
    )