Buck: java_binary()


A java_binary() rule is used to create a JAR file of the compiled .class files and resources of the java_library() rules on which it depends.


  • name (required) #

    The name of the rule, as well as the name of the generated JAR file.

  • deps (defaults to []) #

    Rules (normally of type java_library) that should be compiled and whose .class files and resources should be included in the generated JAR file.

  • main_class (defaults to None) #

    If provided, this will be the value specified as the Main-Class attribute of the META-INF/MANIFEST.MF file in the generated JAR file. Also, when this rule is used as an executable in a genrule(), main_class will indicate the class whose main() method will be invoked to process the command-line arguments. This is consistent with the expected usage of java -jar<name.jar> <args>.

  • manifest_file (defaults to None) #

    If provided, this manifest will be used when generating the JAR file. If combined with main_class, the specified manifest file will be used but the main_class will override the main class in the manifest.

  • meta_inf_directory (defaults to None) #

    Note: This has beta support currently. If provided, the contents in this directory will end up in the META-INF directory inside the generated JAR file.

  • blacklist (defaults to []) #

    A list of patterns that identify Java packages/symbols to exclude from the final generated JAR file. Example:

      name = 'example',
      blacklist = [
        # Excludes com.example.A and com.example.Alligator,
        # as well as their inner classes.
        # Excludes all .class files from org.slf4j.*.
      deps = [

  • visibility (defaults to []) #

    List of build target patterns that identify the build rules that can include this rule in its deps.

  • licenses (defaults to []) #

    Set of license files for this library. To get the list of license files for a given build rule and all of its dependencies, you can use buck query.

  • labels (defaults to []) #

    Set of arbitrary strings which allow you to annotate a build rule with tags that can be searched for over an entire dependency tree using buck query attrfilter.