We now discuss the build commands. Each command can be executed from the command line, from the REPL, and from VSCode.
We can create a new project, inside a directory, with the
This will create the default Flix project structure:
│ └── Main.flix
2 directories, 6 files
The most relevant files are
flix.toml manifest file is discussed in the next section.
initcommand is safe to use; it will only create files that do not already exist.
We can check a project for compiler errors with the
check command. During
check command is preferable to the
build command because it
skips code generation (and hence is significantly faster).
We can compile a project with the
build command. Running the
will compile the entire project and emit bytecode, i.e. compiled Java classes,
Flix has no
clean command. Deleting the
build directory serves the same
We can compile a project to a fat JAR-file with the
build-jar command. The
build-jar command emits a
artifact/project.jar file. If there is
function, we can run it:
$ java -jar artifact/project.jar
The JAR-file contains all class files from the
build directory. The built JAR
may depend on external JARs, if the project, or one of its dependencies, depends
Note: The project must be compiled with
We can bundle a project into a Flix package file (fpkg) with the
command. Running the
build-pkg command emits a
A Flix package file (fpkg) is essentially zip-file of the project source code. A
Flix package, together with its
flix.toml manifest, can be published on
We do not have to build a JAR-file to run a project, we can simply use the
command which will compile and run the main entry point.
We can use the
test command to run all test cases in a project. Flix will
collect all functions marked with
@Test, execute them, and print a summary of
Running 1 tests...
PASS test01 1,1ms
Passed: 1, Failed: 0. Skipped: 0. Elapsed: 3,9ms.