- We assume you write code and have used build systems - just not pants.
- Quick review of what build systems do, and what they don’t do.
- High-level overview of how pants works.
- Learn how to use and configure pants.
- Demo of using pants.
Today we’re learning the essentials. Practical knowledge that will help you get stuff done.
./pants goal test
examples/src/java/com/pants/examples/hello/main
examples/tests/java/com/pants/examples/hello/greet
Pants is exclusively controlled via its command-line interface. Learn to use it well.
./pants goal goalname [flags] [goalname ...] [flags] target [target ...]
./pants goal goals
./pants goal mygoal -h
An address is filesystem path to a BUILD file combined with a target name
path/to/mybird:mybird path/to/mybird (target with same name as dir) :mybird (in the same build file)
Command Line-only conveniences:
path/to/mybird/:mybird path/to/mybird/ path/to/mybird: (wildcard) path/to/mybird:: (recursive wildcard) path/to/mybird/BUILD:
Here’s a simple library target. You might find this in src/java/com/twitter/mybird/BUILD.
java_library(name='mybird',
dependencies=[
'3rdparty/jvm:guava',
'src/java/com/mycom/otherbird/common',
],
sources=globs('*.java'),
)
When developing on the JVM, the following target types are most frequently used:
You probably use code from outside the repo.
# 3rdparty/jvm/com/twitter/mybird:mybird jar_library(name='mybird', jars=[ jar(org='com.twitter.mybird', name='mybird', rev='1.0.0') ] )
What should happen here? Avoid this by all internal sources using the same 3rdparty library version.
java_thrift_library(name='mybird-scala', sources=globs('*.thrift'), dependencies=['src/thrift/included:includedbird-scala',], compiler='scrooge', language='scala', rpc_style='finagle', )
Need to generate a few languages?
Use a few *_thrift_library targets.
(If your org has a standard set of languages to generate, might have a plugin
with a BUILD helper function for this.)
Want to upload something runnable to a server? Generate a bundle:
# in mybird/BUILD jvm_binary(name='mybird-bin', dependencies=['src/java/com/twitter/mybird'], ... ) jvm_app(name='mybird-app', binary=':mybird-bin', bundles=[bundle(relative_to='common').add(rglobs('common/*')), ])
./pants goal bundle mybird:mybird-app --bundle-archive=zip
/
#