Skip to main content

Build with Flox

Not only can you develop your software with Flox, but you can build it as well. See the builds concept page for more details.

Manifest builds

This example will use Gradle and the shadowJar plugin, though a number of build systems exist in the Java ecosystem. The core of building a Java artifact with Flox looks like this:
  • Bundle the application into a JAR
  • Place the JAR into $out/lib/
  • Create a script that calls java -jar <path to jar>, where <path to jar> is the path to the jar in $out/lib at runtime, where $out is not set.
Since $out is not set at runtime, the script that calls java -jar <path to jar> needs to find the location of the JAR at runtime. Note that pwd will return the location from which the built artifact is run, not the location of the artifact itself, which is why the script goes through the process of setting SCRIPT_DIR and JAR_PATH.