Create a Bundled zip or Other Archive
You're working on a Scala or Java project and you want to bundle your project into a single ZIP file or other archive.
Note: If you're working on a Python project, you should compile a Python executable (a
.pex file) instead of a bundle. More information can be found in Run a Binary Target.
pants bundle command enables you to bundle a project into a single archive in the following file formats:
In order to use the
bundle goal, you need to target a
jvm_app definition. Here's an example target:
jvm_app( name='bundle', basename='my-project-deployable-bundle', binary=':my-binary-target', # should point to a jvm_binary target )
There are two ways to specify the desired file format:
1. Through the
BUILD file (recommended)
archive parameter to your
jvm_app target. Here's an example:
jvm_app( name='bundle', archive='zip', # etc )
2. Via the command line (which can override #1)
--bundle-jvm-archive option when invoking the Pants executable. Here's an example:
$ ./pants bundle src/java/com/myorg/myproject:bundle --bundle-jvm-archive=zip
Note: If you perform neither of the steps explained in #1 and #2, no bundle will be created.
When bundling is complete, you can find the resulting archive in the
dist directory of your Pants workspace. The name of the
.zip file is the concatenation of the path to the
BUILD file and the target name. In this example, the path for the bundle would be
my-project.sub-project is the period-delimited path to the
BUILD file and
my-project-deployable-bundle was the
basename assigned to the target).