make
-- Builds the project and runs unit tests.
make run NAME="$PWD/../samples/fib.lox"
-- Builds the project and runs a script.
- A recent version of the JDK (I have only tested it with
OpenJDK 14.0
on Mac OS). - The
gradle
build system.- Strictly speaking, you might be able to get the project running without using
gradle
, but then you'll have to manually manage the third-party dependencies with whatever other build system you decide to use.
- Strictly speaking, you might be able to get the project running without using
- (Optional) make to be able to run the same commands as in
clox
. OurMakefile
is really a thin wrapper that callsgradle
. In the unlikely case that you don't havemake
installed (and you don't care to install it), check out theMakefile
to see the commands you need to run for each task.
make
If you're doing incremental development (e.g., TDD
), you will eventually find it tedious to run this command after every change in the code. To make the command run automatically after a file in the project changes, you can run:
make watch
Also, if you're curious about all the tasks that are being run, you can run ./gradlew
directly using the --console=verbose
flag as follows:
./gradlew --console=verbose build
If you want to test single-line commands in Lox, you can run its REPL as follows:
make repl
When you're done with it, you can press Ctrl-D
or type quit
to exit.
Note that the REPL only supports single-line strings, so if you want to test something larger, your best bet is to put it in a script and run it as follows:
make run NAME="$PWD/../samples/fib.lox"
By default, the system.in
of the gradle
build is not wired up with the system.in
of the run
(JavaExec
) task. To fix this, app/build.gradle
contains this:
run {
standardInput = System.in
}
See more details here
As you might have noticed, gradle
stores gradle/wrapper/gradle-wrapper.jar
. This is indeed something that seems fishy, and there is an ongoing discussion about this here.