Building an app

Before we get into how to write an HFactory app, we’ll start by describing the dependencies required to do so. We’ll use SBT ( but you could use Maven as well.

First, we have to specify the repositories we’ll get the HFactory packages from. To use HFactory Tools Nexus repository, add the following lines in your project’s build.sbt:

      resolvers in ThisBuild ++= Seq(
        "Ubeeko nexus public" at "",
        "Ubeeko nexus releases" at "",
        "Ubeeko nexus snapshots" at ""

Building an HFactory app requires the following HFactory packages:

  • com.ubeeko.hfactory-app: provides the base class your app must subclass.
  • com.ubeeko.hfactory-core: provides the macros required to define entities.

Optionally, depending on what you need for your application, you may also depend on other HFactory packages, e.g. com.ubeeko.hfactory-jobs. Please refer to HFactory’s scaladoc for more information.

In SBT these dependencies would be declared as follows:

      libraryDependencies ++= Seq(
        "com.ubeeko" %% "hfactory-app"  % hfactoryVersion % "provided",
        "com.ubeeko" %% "hfactory-core" % hfactoryVersion % "provided",

      addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0-M5" cross CrossVersion.full)

where hfactoryVersion is the version of HFactory you want to use.

For this version to be shared among the subprojects of your SBT project, it is best defined (along with other libs’ versions) in project/versions.scala in the toplevel project directory as follows:

      object Versions {
        val hfactoryVersion = "1.4.7"
        // ...versions of other libs...

NOTE: The scalamacros compiler plugin is required for the hfactory-core macros.

Compiling the app is then simply a matter of running sbt compile. Building the app’s assembly requires SBT plugin sbt-assembly. It can be added to your project by creating file project/assembly.sbt with the following contents (adjust the version as needed):

      addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.13.0")

Since we don’t want to include the whole Scala distribution within the app’s assembly, you should add the following assembly settings in build.sbt:

      assemblyOption in assembly :=
        (assemblyOption in assembly).value.copy(includeScala = false)