java_binary()
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.Arguments
name
(required) #The short name for this build target. Also, 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 toNone
) #If provided, this will be the value specified as the
Main-Class
attribute of theMETA-INF/MANIFEST.MF
file in the generated JAR file. Also, when this rule is used as an executable in agenrule()
,main_class
will indicate the class whosemain()
method will be invoked to process the command-line arguments. This is consistent with the expected usage ofjava -jar<name.jar> <args>
.manifest_file
(defaults toNone
) #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 themain_class
will override the main class in the manifest.meta_inf_directory
(defaults toNone
) #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 files to exclude from the final generated JAR file. Example:
java_binary( name = 'example', blacklist = [ # Excludes com.example.A and com.example.Alligator, # as well as their inner classes and any non-class files that happen to match # the pattern 'com.example.A', # Excludes all files from org/slf4j/**/*. 'org.slf4j', ], deps = [ ':example1', ':third-party-stuff', ], )
tests
(defaults to[]
) #List of build targets that identify tests that exercise this target.
visibility
(defaults to[]
) #List of build target patterns that identify the build rules that can include this rule as a dependency, for example, by listing it in their
deps
orexported_deps
attributes. For more information, see visibility.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()
.