longevity

A Persistence Framework for Scala and NoSQL

View project on GitHub

project setup

scala version

We currently publish artifacts for Scala versions 2.11 and 2.12, so be sure your project is using a compatible Scala version. For example, your build.sbt file may have:

scalaVersion := "2.11.8"

or:

scalaVersion := "2.12.1"

using sonatype artifacts

Include the following two lines in your build.sbt to declare the dependency:

resolvers += Resolver.sonatypeRepo("releases")

libraryDependencies += "org.longevityframework" %% "longevity" % "0.22.0"

Include one of the following lines to bring in the library dependencies for the back end of your choice:

libraryDependencies += "org.longevityframework" %% "longevity-cassandra-deps" % "0.22.0"

libraryDependencies += "org.longevityframework" %% "longevity-mongodb-deps" % "0.22.0"

libraryDependencies += "org.longevityframework" %% "longevity-sqlite-deps" % "0.22.0"

enabling macro annotations

You will probably want to use the macro annotations provided in package longevity.model.annotations. To do so, you will need to add Macro Paradise to your build, like so:

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

supplying optional dependencies

There are a number of optional longevity features that require you to bring in other library dependencies yourself. If you want to use longevity.test.RepoCrudSpec or longevity.test.QuerySpec to build integration tests, you will need ScalaTest:

libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1"

If you want to stream query results to Akka Streams:

libraryDependencies += "com.typesafe.akka" %% "akka-stream" % "2.4.17"

If you want to stream query results to FS2:

libraryDependencies += "co.fs2" %% "fs2-core" % "0.9.4"

If you want to stream query results to iteratee.io:

libraryDependencies += "org.typelevel" %% "cats" % "0.9.0"
libraryDependencies += "io.iteratee" %% "iteratee-core" % "0.10.0"

If you want to stream query results to Play enumerators:

libraryDependencies += "com.typesafe.play" %% "play-iteratees" % "2.6.1"

building the artifacts yourself

download the source

The source code for longevity, and for dependency emblem, is housed in the longevity project on GitHub. To use it, first create a clone of that project:

% git clone https://github.com/longevityframework/longevity.git
% cd longevity

choose the right branch

You probably want to be on the master branch, as this holds the latest working version. You are probably already there, but just in case:

% git checkout master
% git pull

publish local

Now use SBT to publish the emblem and longevity artifacts locally. From the command line:

% sbt publishLocal

include as a library dependency

In the projects where you want to use longevity, include a library dependency. If you are on the master branch, use:

libraryDependencies += "org.longevityframework" %% "longevity" % "0.23-SNAPSHOT"
prev: what is longevity
up: preliminaries
next: the domain model