sbt-eezo: the tasks and settings it adds, the source it generates, and the sbt versions it
runs on.
// project/plugins.sbt
addSbtPlugin("io.eezo" % "sbt-eezo" % eezoVersion)
// build.sbt
enablePlugins(EezoPlugin)The plugin does nothing until a project enables it. An application with no routes, a job on
eezo-db alone, doesn't need it.
| task | what it does |
|---|---|
eezoGenerateRoutes |
writes Routes.scala; runs on every compile as a source generator, cached on the sources' hashes |
eezoGenerateConfig |
writes ConfigFile.scala when eezoConfigClass names a class, and deletes it when it names none; runs on every compile as a source generator |
eezoDev [--once|--plain|--json] |
a command, not a task: the dev console. Watches the sources, compiles on every save, forks Main dev with its output piped into a pane, and draws the log, the errors, the routes, the drift and the config on the terminal; the schema commands on keys, and e for a value boot refused. --plain is the same loop printed as lines, no screen and no keys, which eezo dev --no-tui passes, and --json the same loop as one JSON object per line (the event stream below), which eezo dev --json passes; a pipe or an agent reads either and Ctrl-C stops it. Without a terminal and without a flag only --once runs: it builds, starts, prints the events as lines, waits for the application to serve, stops, and fails when it did not |
eezoRestart |
prints eezo dev: building, compiles, kills the running application, forks a fresh JVM running Main dev with its output inherited, prints eezo dev: started <Main>; ~eezoRestart is the loop without the console |
eezoStop |
stops the forked application, if any |
eezoRoutes |
run routes |
eezoStatus |
run db status |
eezoSync <args> |
run db sync <args>; --apply and --force pass through |
eezoMigrate <args> |
run db migrate <args> |
eezoFreeze <args> |
run db freeze <args> |
eezoStage |
stages target/eezo/stage/, returns the directory |
eezoTailwind |
builds assets/tailwind.css from the tailwind.css at the project root with the Tailwind CLI; a resource generator, so it runs whenever the classpath is asked for, cached on the sources' hashes; does nothing without the file |
The five forwards go through Compile / run, so they inherit everything the build decided
about running: fork, the working directory, javaOptions, javaHome. eezoRestart reads the
same keys for the JVM it forks. The forked application's output is inherited into sbt's
console.
| key | default | notes |
|---|---|---|
eezoJavaVersion |
"25" |
the JRE tag eezoStage writes into the Dockerfile |
eezoConfigClass |
None |
the case class src/main/resources/application.conf is read into, fully qualified; Some makes the build check the file against it |
Compile / run / connectInput |
true |
set by the plugin so freeze can prompt |
Compile / eezoGenerateRoutes / watchTriggers |
src/main/scala/**/*.scala |
what the watch reacts to |
eezoTailwindVersion |
"4.3.3" |
the Tailwind release eezoTailwind fetches |
eezoTailwindInput |
baseDirectory.value / "tailwind.css" |
the stylesheet eezoTailwind compiles; absent means no Tailwind |
eezoTailwindCli |
None |
a Tailwind CLI already on the machine, instead of the fetched one |
watchTriggers |
+= tailwind.css, ++= src/main/resources/**/*.conf, *.json, *.properties |
project level, so ~eezoRestart and ~test rerun on an edit to the stylesheet or to a config file alone; the console's watch covers eezoTailwindInput and the resource directories on its own |
run / fork := true is the scaffold's, not the plugin's, and it's needed: the application
runs on the JDK floor, and sbt's own JVM may not be on it.
eezoDev asks for the full classpath, which compiles the project first. A failed compile
leaves the running application untouched, so it keeps serving, and its diagnostics fill the
errors pane. On success the previous process is destroyed, forcibly after ten seconds, then the
next is forked, with EEZO_DEV_MARKERS set so the application prints its route table, its
drift and its Config's read as one JSON line each (eezo dev: routes, eezo dev: drift,
eezo dev: config), which the console reads. The config line is printed under dev only, on a
good read and on a refusal, when the build names a Config class: variables, one object per
variable application.conf names with variable, path, redacted, need and set (a
boolean, never the value), and offenders, one object per reason boot refused, with kind
(missing, malformed, reserved, literal, absent or unparsable), path, the
variables the file names for the path, among them the ones feeding the value boot read
(of two fed in turn only the later one set, of a concatenation every set part; none for a
missing value), reason for a malformed value, variable for a reserved one, and boot's own
line.
One secret per sbt session is passed as EEZO_SECRET unless the environment already sets one.
The values the config pane took are passed to every fork after it took them, over a variable of
the same name in sbt's environment; never a variable under EEZO_, and never to a schema
command.
A reload of the build strands the running child until sbt exits, and makes a fresh secret.
The console runs sbt's tasks under a session with console logging and the progress bars off,
since the screen is its own; a failed compile's log is still in last compile. It reads the
terminal through sbt's own terminal layer, the one the sbt shell uses, so eezoDev typed at the
shell works the same as from the launcher, and q hands the terminal back. It refuses to run
behind sbt's thin client, which an sbt 2 project gets from the sbt script by default, because
the client returns at the first failed task and would leave the loop running in a server nobody
sees: sbt --server eezoDev there, or eezo dev, which passes the flag.
dev is the http layer's command, so eezoDev on a DbApp prints the unknown command line on
every save. A job's rerun-on-save loop is sbt's own ~run.
eezoDev --json prints one JSON object per line, each with an event field. The build events
share a build number, counted from one per eezoDev, so a reader that saw compiling after
its save knows which built or failed answers it.
event |
fields |
|---|---|
compiling |
build, trigger (the file that changed, or null for a restart) |
built |
build, millis, warnings (diagnostics) |
failed |
build, millis, diagnostics |
broken |
build, message: the build could not run at all, no main class for one |
started |
mainClass |
serving |
url |
exited |
code |
stopped |
the application was stopped for a restart |
line |
stream (stdout or stderr), text: the application's own output, routine boot records removed |
routes |
the routes --json body: routes, overridden, shadowed, orphans; routes under /eezo have provenance eezo |
drift |
the db status --json body plus blocking, and unreachable with the reason when the database could not be asked |
config |
the config marker: variables (variable, path, redacted, need, set) and offenders (kind, path, variables, feeding, line); no value, and nothing of what the console was given |
command |
command, status (started or finished); when finished, code, ok, summary and the command's own JSON answer as result |
A diagnostic is path, line, column, severity (error, warning or info), message
and rendered, the compiler's own excerpt with the caret, or null.
eezoTailwind is a resource generator, so every task that asks for the classpath, eezoRestart,
test, package and eezoStage, builds the stylesheet first and finds it at
assets/tailwind.css in resourceManaged. The CLI is the standalone binary of the release named
by eezoTailwindVersion, fetched once per version into ~/.eezo/tools (or EEZO_HOME/tools),
verified against the release's sha256sums.txt, and run with the project directory as its
working directory. Its inputs are the stylesheet and every file under the unmanaged source and
resource directories, hashed; a stamp carrying the version and the CLI's path is hashed with them,
so a bumped version misses the cache. A CLI that exits with an error fails the task with its
diagnostics in the message. Style with Tailwind is the setup.
Compile / sourceManaged, at io/eezo/generated/Routes.scala, which is on the managed source
path so an editor can navigate into it. Routing conventions has its contents.
It's rewritten only when its content would change, so a save that doesn't touch a route
doesn't invalidate the compile that follows. Two facts about the build are folded into the
cache key, because no source file carries them:
- whether
eezo-dbis on the compile classpath, read off the resolution report so a transitiveeezo-dbcounts; it decides whetherstoreFormay nameJdbcStore; - whether
eezo-authis declared inlibraryDependenciesin a configuration the compiler sees (compile,provided,optional, or unscoped), which decides whether a route with noGuardedis a compile error.
Adding either dependency therefore regenerates the table on the next compile with no source change.
When eezoConfigClass names a class, a second file sits beside it,
io/eezo/generated/ConfigFile.scala. It holds one call, Config.checked[<class>](<path>), with
the absolute path of src/main/resources/application.conf, and a digest in its first line over
that file and every .conf, .json and .properties file under src/main/resources. The call
checks the file against the class at compile time. Boot finds the object by that fixed name and
reads the file into the class before the application starts, as
configuration describes. The digest is there because the incremental
compiler never looks inside a macro: an edit to the file, or to a file it includes from that
directory, changes the unit's text, so the unit is compiled and checked again. An include that
reaches outside src/main/resources, by absolute path, by a .. path or from the classpath, is
not in the digest: an edit to it alone is checked on the next clean compile, not the next
incremental one. With None the plugin writes no such file and deletes one left from before.
| axis | Scala | floor |
|---|---|---|
| sbt 1 | 2.12.21 | 1.5.8 |
| sbt 2 | 3.8.4 | 2.0.6 |
The Scala column is the Scala the plugin is built with on that axis. It is chosen by the sbt the axis targets and not by your application, because a plugin built with a newer Scala 3 than sbt's own cannot be loaded by it. That is why the sbt 2 row trails the Scala the framework is built with. The gate loads the plugin in sbt 2.0.6 to check the row.
One source file set, compiled on both axes. The source stays inside the subset both compilers accept, and building both is the only check that it does. The plugin's bytecode targets are Java 8 on sbt 1 and 17 on sbt 2, which are sbt's floors and have nothing to do with the JDK the application needs.
The dev loop is what the restart does to the browser. The CLI is the launcher that wraps these tasks.