Docs›Guides
Run a script during the build
Any build can run a script of yours before or after one of its phases, without writing a plugin.
1. Turn it on
Add BuildExtensionCommands to the project's build-dependencies:
plinto.conf
build-dependencies: {
JavaBuild = 1.0
Java = 25
BuildExtensionCommands = 1.0
}
2. Add a script
Name it after the phase and when it runs: scripts/before-<phase>.sh or scripts/after-<phase>.sh.
| Phase | When |
|---|---|
prepare |
before anything is compiled |
compile |
compiling the code |
test |
running the tests (its scripts are skipped with the tests) |
package |
making the jar, wheel or archive |
release |
releasing, in plinto release only |
scripts/before-compile.sh
#!/bin/sh
echo "building $PLINTO_PROJECT $PLINTO_VERSION"
A script runs with its #! line, else with sh. Another name in scripts/ that looks like a hook fails the build, with the names it takes.
What a script gets
| Variable | What it holds |
|---|---|
PLINTO_PROJECT, PLINTO_VERSION |
the project's name and version |
PLINTO_PROJECT_DIR, PLINTO_BUILD_DIR |
the project's folder and its build/ |
PLINTO_HOOK |
which script this is, such as before-compile |
PLINTO_RELEASE, PLINTO_SKIP_TESTS |
whether it is a release, and whether tests are skipped |
PLINTO_OUTPUTS |
what the phases so far made, one file a line |