This example project demonstrates the "in-workspace" execution support in Pants which allows running processes directly in a project's repository instead of the usual execution sandbox. The workspace execution support is accessible via the new experimental_workspace_environment
target type.
This example project integrates Pants with Bazel to build a small Java program. (Pants has Java support so this example is very much contrived, but the point is demonstrate integration with a third party build tool, not to focus too much on details of this particular example.)
Some items to be aware of:
-
Bazel sources. The Bazel workspace is under the
bazel-jvm
directory. -
Pants configuration. Pants has been configured to only look in
BUILD.pants
for targets so that Pants does not try to read anyBUILD.bazel
files.
-
Ensure you have Bazel and Docker both installed somewhere on the
PATH
. -
Run
pants run //:project_image
. This will produce a Docker image with the jar file produced by Bazel and run the resulting image. You should see the output:Hello!
For futher context, see the original "In-Workspace Process Execution" design document.