2019-07-17 20:03:10 +00:00
|
|
|
|
import com.github.eikek.sbt.openapi._
|
|
|
|
|
import scala.sys.process._
|
|
|
|
|
import com.typesafe.sbt.SbtGit.GitKeys._
|
2019-07-22 22:53:30 +00:00
|
|
|
|
import docspell.build._
|
2020-02-27 22:58:43 +00:00
|
|
|
|
import microsites.ExtraMdFileConfig
|
2019-07-17 20:03:10 +00:00
|
|
|
|
|
2020-01-19 19:32:52 +00:00
|
|
|
|
val toolsPackage = taskKey[Seq[File]]("Package the scripts/extension tools")
|
2019-12-29 19:52:43 +00:00
|
|
|
|
val elmCompileMode = settingKey[ElmCompileMode]("How to compile elm sources")
|
|
|
|
|
|
2020-05-06 20:04:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// --- Settings
|
|
|
|
|
|
2019-07-17 20:03:10 +00:00
|
|
|
|
val sharedSettings = Seq(
|
|
|
|
|
organization := "com.github.eikek",
|
2020-04-24 20:24:31 +00:00
|
|
|
|
scalaVersion := "2.13.2",
|
2019-07-17 20:03:10 +00:00
|
|
|
|
scalacOptions ++= Seq(
|
|
|
|
|
"-deprecation",
|
|
|
|
|
"-encoding", "UTF-8",
|
|
|
|
|
"-language:higherKinds",
|
|
|
|
|
"-feature",
|
2019-07-22 22:53:30 +00:00
|
|
|
|
"-Werror", // fail when there are warnings
|
2019-07-17 20:03:10 +00:00
|
|
|
|
"-unchecked",
|
2019-07-22 22:53:30 +00:00
|
|
|
|
"-Xlint:_",
|
2019-09-28 20:17:45 +00:00
|
|
|
|
"-Wdead-code",
|
|
|
|
|
"-Wunused",
|
|
|
|
|
"-Wvalue-discard",
|
|
|
|
|
"-Wnumeric-widen"
|
2019-07-17 20:03:10 +00:00
|
|
|
|
),
|
2020-01-19 19:32:52 +00:00
|
|
|
|
LocalRootProject/toolsPackage := {
|
|
|
|
|
val v = version.value
|
|
|
|
|
val logger = streams.value.log
|
|
|
|
|
val dir = (LocalRootProject/baseDirectory).value / "tools"
|
|
|
|
|
packageTools(logger, dir, v)
|
|
|
|
|
},
|
2019-07-22 22:53:30 +00:00
|
|
|
|
scalacOptions in (Compile, console) :=
|
|
|
|
|
(scalacOptions.value.filter(o => !o.contains("Xlint")) ++ Seq("-Xlint:_,-unused")),
|
|
|
|
|
scalacOptions in (Test, console) :=
|
|
|
|
|
(scalacOptions.value.filter(o => !o.contains("Xlint")) ++ Seq("-Xlint:_,-unused"))
|
2019-07-17 20:03:10 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
val testSettings = Seq(
|
|
|
|
|
testFrameworks += new TestFramework("minitest.runner.Framework"),
|
2019-07-22 22:53:30 +00:00
|
|
|
|
libraryDependencies ++= Dependencies.miniTest ++ Dependencies.logging.map(_ % Test)
|
2019-07-17 20:03:10 +00:00
|
|
|
|
)
|
|
|
|
|
|
2020-03-17 21:34:50 +00:00
|
|
|
|
lazy val noPublish = Seq(
|
|
|
|
|
publish := {},
|
|
|
|
|
publishLocal := {},
|
|
|
|
|
publishArtifact := false
|
|
|
|
|
)
|
|
|
|
|
|
2019-07-17 20:03:10 +00:00
|
|
|
|
val elmSettings = Seq(
|
2019-12-29 19:52:43 +00:00
|
|
|
|
elmCompileMode := ElmCompileMode.Debug,
|
2019-07-22 22:53:30 +00:00
|
|
|
|
Compile/resourceGenerators += Def.task {
|
2019-07-17 20:03:10 +00:00
|
|
|
|
compileElm(streams.value.log
|
|
|
|
|
, (Compile/baseDirectory).value
|
|
|
|
|
, (Compile/resourceManaged).value
|
|
|
|
|
, name.value
|
2019-12-29 19:52:43 +00:00
|
|
|
|
, version.value
|
|
|
|
|
, elmCompileMode.value)
|
2019-07-22 22:53:30 +00:00
|
|
|
|
}.taskValue,
|
2019-07-17 20:03:10 +00:00
|
|
|
|
watchSources += Watched.WatchSource(
|
|
|
|
|
(Compile/sourceDirectory).value/"elm"
|
|
|
|
|
, FileFilter.globFilter("*.elm")
|
|
|
|
|
, HiddenFileFilter
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
val webjarSettings = Seq(
|
2019-07-22 22:53:30 +00:00
|
|
|
|
Compile/resourceGenerators += Def.task {
|
2019-07-17 20:03:10 +00:00
|
|
|
|
copyWebjarResources(Seq((sourceDirectory in Compile).value/"webjar")
|
|
|
|
|
, (Compile/resourceManaged).value
|
|
|
|
|
, name.value
|
|
|
|
|
, version.value
|
|
|
|
|
, streams.value.log
|
|
|
|
|
)
|
2019-07-22 22:53:30 +00:00
|
|
|
|
}.taskValue,
|
2019-07-17 20:03:10 +00:00
|
|
|
|
watchSources += Watched.WatchSource(
|
|
|
|
|
(Compile / sourceDirectory).value/"webjar"
|
|
|
|
|
, FileFilter.globFilter("*.js") || FileFilter.globFilter("*.css")
|
|
|
|
|
, HiddenFileFilter
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
2019-07-22 22:53:30 +00:00
|
|
|
|
def debianSettings(cfgFile: String) = Seq(
|
2019-07-17 20:03:10 +00:00
|
|
|
|
maintainer := "Eike Kettner <eike.kettner@posteo.de>",
|
|
|
|
|
packageSummary := description.value,
|
|
|
|
|
packageDescription := description.value,
|
|
|
|
|
mappings in Universal += {
|
|
|
|
|
val conf = (Compile / resourceDirectory).value / "reference.conf"
|
|
|
|
|
if (!conf.exists) {
|
|
|
|
|
sys.error(s"File $conf not found")
|
|
|
|
|
}
|
2019-07-22 22:53:30 +00:00
|
|
|
|
conf -> s"conf/$cfgFile.conf"
|
2019-07-17 20:03:10 +00:00
|
|
|
|
},
|
2019-07-22 22:53:30 +00:00
|
|
|
|
bashScriptExtraDefines += s"""addJava "-Dconfig.file=$${app_home}/../conf/$cfgFile.conf""""
|
2019-07-17 20:03:10 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
val buildInfoSettings = Seq(
|
|
|
|
|
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion, gitHeadCommit, gitHeadCommitDate, gitUncommittedChanges, gitDescribedVersion),
|
|
|
|
|
buildInfoOptions += BuildInfoOption.ToJson,
|
|
|
|
|
buildInfoOptions += BuildInfoOption.BuildTime
|
|
|
|
|
)
|
|
|
|
|
|
2019-07-22 22:53:30 +00:00
|
|
|
|
val openapiScalaSettings = Seq(
|
|
|
|
|
openapiScalaConfig := ScalaConfig().withJson(ScalaJson.circeSemiauto).
|
|
|
|
|
addMapping(CustomMapping.forType({
|
|
|
|
|
case TypeDef("LocalDateTime", _) =>
|
|
|
|
|
TypeDef("Timestamp", Imports("docspell.common.Timestamp"))
|
|
|
|
|
})).
|
|
|
|
|
addMapping(CustomMapping.forFormatType({
|
|
|
|
|
case "ident" => field =>
|
|
|
|
|
field.copy(typeDef = TypeDef("Ident", Imports("docspell.common.Ident")))
|
|
|
|
|
case "collectivestate" => field =>
|
|
|
|
|
field.copy(typeDef = TypeDef("CollectiveState", Imports("docspell.common.CollectiveState")))
|
|
|
|
|
case "userstate" => field =>
|
|
|
|
|
field.copy(typeDef = TypeDef("UserState", Imports("docspell.common.UserState")))
|
|
|
|
|
case "password" => field =>
|
|
|
|
|
field.copy(typeDef = TypeDef("Password", Imports("docspell.common.Password")))
|
|
|
|
|
case "contactkind" => field =>
|
|
|
|
|
field.copy(typeDef = TypeDef("ContactKind", Imports("docspell.common.ContactKind")))
|
|
|
|
|
case "direction" => field =>
|
|
|
|
|
field.copy(typeDef = TypeDef("Direction", Imports("docspell.common.Direction")))
|
|
|
|
|
case "priority" => field =>
|
|
|
|
|
field.copy(typeDef = TypeDef("Priority", Imports("docspell.common.Priority")))
|
|
|
|
|
case "jobstate" => field =>
|
|
|
|
|
field.copy(typeDef = TypeDef("JobState", Imports("docspell.common.JobState")))
|
|
|
|
|
case "loglevel" => field =>
|
|
|
|
|
field.copy(typeDef = TypeDef("LogLevel", Imports("docspell.common.LogLevel")))
|
|
|
|
|
case "mimetype" => field =>
|
|
|
|
|
field.copy(typeDef = TypeDef("MimeType", Imports("docspell.common.MimeType")))
|
|
|
|
|
case "itemstate" => field =>
|
|
|
|
|
field.copy(typeDef = TypeDef("ItemState", Imports("docspell.common.ItemState")))
|
|
|
|
|
case "nertag" => field =>
|
|
|
|
|
field.copy(typeDef = TypeDef("NerTag", Imports("docspell.common.NerTag")))
|
|
|
|
|
case "language" => field =>
|
|
|
|
|
field.copy(typeDef = TypeDef("Language", Imports("docspell.common.Language")))
|
2020-04-17 22:50:46 +00:00
|
|
|
|
case "calevent" => field =>
|
|
|
|
|
field.copy(typeDef = TypeDef("CalEvent", Imports("com.github.eikek.calev.CalEvent",
|
|
|
|
|
"com.github.eikek.calev.circe.CalevCirceCodec._")))
|
2019-07-22 22:53:30 +00:00
|
|
|
|
}))
|
|
|
|
|
)
|
|
|
|
|
|
2020-05-06 20:04:51 +00:00
|
|
|
|
|
|
|
|
|
|
2019-07-22 22:53:30 +00:00
|
|
|
|
// --- Modules
|
2019-07-17 20:03:10 +00:00
|
|
|
|
|
2020-04-29 20:44:05 +00:00
|
|
|
|
// Base module, everything depends on this – including restapi and
|
|
|
|
|
// joexapi modules. This should aim to have least possible
|
|
|
|
|
// dependencies
|
2019-07-17 20:03:10 +00:00
|
|
|
|
val common = project.in(file("modules/common")).
|
2020-02-08 16:58:40 +00:00
|
|
|
|
disablePlugins(RevolverPlugin).
|
2019-07-17 20:03:10 +00:00
|
|
|
|
settings(sharedSettings).
|
|
|
|
|
settings(testSettings).
|
|
|
|
|
settings(
|
|
|
|
|
name := "docspell-common",
|
|
|
|
|
libraryDependencies ++=
|
2019-07-22 22:53:30 +00:00
|
|
|
|
Dependencies.fs2 ++
|
|
|
|
|
Dependencies.circe ++
|
|
|
|
|
Dependencies.loggingApi ++
|
2020-03-08 14:26:56 +00:00
|
|
|
|
Dependencies.calevCore ++
|
2020-04-17 22:50:46 +00:00
|
|
|
|
Dependencies.calevCirce ++
|
2019-07-22 22:53:30 +00:00
|
|
|
|
Dependencies.pureconfig.map(_ % "optional")
|
2019-07-17 20:03:10 +00:00
|
|
|
|
)
|
|
|
|
|
|
2020-02-11 21:46:23 +00:00
|
|
|
|
// Some example files for testing
|
|
|
|
|
// https://file-examples.com/index.php/sample-documents-download/sample-doc-download/
|
2020-02-15 15:40:50 +00:00
|
|
|
|
val files = project.in(file("modules/files")).
|
2020-02-11 21:46:23 +00:00
|
|
|
|
disablePlugins(RevolverPlugin).
|
|
|
|
|
settings(sharedSettings).
|
|
|
|
|
settings(testSettings).
|
|
|
|
|
settings(
|
2020-02-14 10:14:09 +00:00
|
|
|
|
name := "docspell-files",
|
2020-02-14 10:09:39 +00:00
|
|
|
|
libraryDependencies ++=
|
2020-03-23 21:43:15 +00:00
|
|
|
|
Dependencies.tika ++
|
|
|
|
|
Dependencies.icu4j,
|
2020-02-14 10:09:39 +00:00
|
|
|
|
Test / sourceGenerators += Def.task {
|
|
|
|
|
val base = (Test/resourceDirectory).value
|
|
|
|
|
val files = (base ** (_.isFile)) pair sbt.io.Path.relativeTo(base)
|
|
|
|
|
val lines = files.toList.map(_._2).map(s => {
|
|
|
|
|
val ident = s.replaceAll("[^a-zA-Z0-9_]+", "_")
|
|
|
|
|
ident -> s"""val $ident = createUrl("${s}")"""
|
|
|
|
|
})
|
2020-02-14 10:14:09 +00:00
|
|
|
|
val content = s"""package docspell.files
|
2020-02-14 10:09:39 +00:00
|
|
|
|
|
|
|
|
|
object ExampleFiles extends ExampleFilesSupport {
|
|
|
|
|
|
|
|
|
|
${lines.map(_._2).mkString("\n")}
|
|
|
|
|
|
|
|
|
|
val all = List(
|
|
|
|
|
${lines.map(_._1).mkString(",\n")}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
"""
|
|
|
|
|
val target = (Test/sourceManaged).value/"scala"/"ExampleFiles.scala"
|
|
|
|
|
IO.createDirectory(target.getParentFile)
|
|
|
|
|
IO.write(target, content)
|
|
|
|
|
Seq(target)
|
|
|
|
|
}.taskValue
|
|
|
|
|
).dependsOn(common)
|
2020-02-11 21:46:23 +00:00
|
|
|
|
|
2019-07-17 20:03:10 +00:00
|
|
|
|
val store = project.in(file("modules/store")).
|
2020-02-08 16:58:40 +00:00
|
|
|
|
disablePlugins(RevolverPlugin).
|
2019-07-17 20:03:10 +00:00
|
|
|
|
settings(sharedSettings).
|
|
|
|
|
settings(testSettings).
|
|
|
|
|
settings(
|
|
|
|
|
name := "docspell-store",
|
|
|
|
|
libraryDependencies ++=
|
|
|
|
|
Dependencies.doobie ++
|
|
|
|
|
Dependencies.bitpeace ++
|
2019-07-22 22:53:30 +00:00
|
|
|
|
Dependencies.tika ++
|
2019-07-17 20:03:10 +00:00
|
|
|
|
Dependencies.fs2 ++
|
|
|
|
|
Dependencies.databases ++
|
|
|
|
|
Dependencies.flyway ++
|
2020-01-04 23:12:23 +00:00
|
|
|
|
Dependencies.loggingApi ++
|
2020-03-08 01:48:47 +00:00
|
|
|
|
Dependencies.emil ++
|
2020-03-24 22:27:24 +00:00
|
|
|
|
Dependencies.emilDoobie ++
|
2020-04-17 22:50:46 +00:00
|
|
|
|
Dependencies.calevCore ++
|
|
|
|
|
Dependencies.calevFs2
|
2019-07-22 22:53:30 +00:00
|
|
|
|
).dependsOn(common)
|
2019-07-17 20:03:10 +00:00
|
|
|
|
|
2020-02-15 15:40:50 +00:00
|
|
|
|
val extract = project.in(file("modules/extract")).
|
2020-02-08 16:58:40 +00:00
|
|
|
|
disablePlugins(RevolverPlugin).
|
2019-07-22 22:53:30 +00:00
|
|
|
|
settings(sharedSettings).
|
|
|
|
|
settings(testSettings).
|
|
|
|
|
settings(
|
2020-02-15 15:40:50 +00:00
|
|
|
|
name := "docspell-extract",
|
2019-07-22 22:53:30 +00:00
|
|
|
|
libraryDependencies ++=
|
|
|
|
|
Dependencies.fs2 ++
|
2020-02-18 20:32:21 +00:00
|
|
|
|
Dependencies.twelvemonkeys ++
|
2020-02-15 15:40:50 +00:00
|
|
|
|
Dependencies.pdfbox ++
|
2020-02-16 20:37:26 +00:00
|
|
|
|
Dependencies.poi ++
|
|
|
|
|
Dependencies.commonsIO ++
|
|
|
|
|
Dependencies.julOverSlf4j
|
2020-02-15 15:40:50 +00:00
|
|
|
|
).dependsOn(common, files % "compile->compile;test->test")
|
2020-02-10 23:33:52 +00:00
|
|
|
|
|
|
|
|
|
val convert = project.in(file("modules/convert")).
|
|
|
|
|
disablePlugins(RevolverPlugin).
|
|
|
|
|
settings(sharedSettings).
|
|
|
|
|
settings(testSettings).
|
|
|
|
|
settings(
|
|
|
|
|
name := "docspell-convert",
|
|
|
|
|
libraryDependencies ++=
|
2020-02-18 20:32:21 +00:00
|
|
|
|
Dependencies.flexmark ++
|
|
|
|
|
Dependencies.twelvemonkeys
|
2020-02-15 15:40:50 +00:00
|
|
|
|
).dependsOn(common, files % "compile->compile;test->test")
|
|
|
|
|
|
|
|
|
|
val analysis = project.in(file("modules/analysis")).
|
|
|
|
|
disablePlugins(RevolverPlugin).
|
|
|
|
|
enablePlugins(NerModelsPlugin).
|
|
|
|
|
settings(sharedSettings).
|
|
|
|
|
settings(testSettings).
|
|
|
|
|
settings(NerModelsPlugin.nerClassifierSettings).
|
|
|
|
|
settings(
|
|
|
|
|
name := "docspell-analysis",
|
|
|
|
|
libraryDependencies ++=
|
|
|
|
|
Dependencies.fs2 ++
|
|
|
|
|
Dependencies.stanfordNlpCore
|
|
|
|
|
).dependsOn(common, files % "test->test")
|
2019-07-22 22:53:30 +00:00
|
|
|
|
|
2019-07-17 20:03:10 +00:00
|
|
|
|
val restapi = project.in(file("modules/restapi")).
|
2020-02-08 16:58:40 +00:00
|
|
|
|
disablePlugins(RevolverPlugin).
|
2019-07-17 20:03:10 +00:00
|
|
|
|
enablePlugins(OpenApiSchema).
|
|
|
|
|
settings(sharedSettings).
|
|
|
|
|
settings(testSettings).
|
2019-07-22 22:53:30 +00:00
|
|
|
|
settings(openapiScalaSettings).
|
2019-07-17 20:03:10 +00:00
|
|
|
|
settings(
|
|
|
|
|
name := "docspell-restapi",
|
|
|
|
|
libraryDependencies ++=
|
|
|
|
|
Dependencies.circe,
|
|
|
|
|
openapiTargetLanguage := Language.Scala,
|
|
|
|
|
openapiPackage := Pkg("docspell.restapi.model"),
|
|
|
|
|
openapiSpec := (Compile/resourceDirectory).value/"docspell-openapi.yml",
|
2019-07-22 22:53:30 +00:00
|
|
|
|
).dependsOn(common)
|
2019-07-17 20:03:10 +00:00
|
|
|
|
|
|
|
|
|
val joexapi = project.in(file("modules/joexapi")).
|
2020-02-08 16:58:40 +00:00
|
|
|
|
disablePlugins(RevolverPlugin).
|
2019-07-17 20:03:10 +00:00
|
|
|
|
enablePlugins(OpenApiSchema).
|
|
|
|
|
settings(sharedSettings).
|
|
|
|
|
settings(testSettings).
|
2019-07-22 22:53:30 +00:00
|
|
|
|
settings(openapiScalaSettings).
|
2019-07-17 20:03:10 +00:00
|
|
|
|
settings(
|
|
|
|
|
name := "docspell-joexapi",
|
|
|
|
|
libraryDependencies ++=
|
2020-03-03 22:07:49 +00:00
|
|
|
|
Dependencies.circe ++
|
|
|
|
|
Dependencies.http4sClient,
|
2019-07-17 20:03:10 +00:00
|
|
|
|
openapiTargetLanguage := Language.Scala,
|
|
|
|
|
openapiPackage := Pkg("docspell.joexapi.model"),
|
2019-07-22 22:53:30 +00:00
|
|
|
|
openapiSpec := (Compile/resourceDirectory).value/"joex-openapi.yml"
|
|
|
|
|
).dependsOn(common)
|
2019-07-17 20:03:10 +00:00
|
|
|
|
|
|
|
|
|
val backend = project.in(file("modules/backend")).
|
2020-02-08 16:58:40 +00:00
|
|
|
|
disablePlugins(RevolverPlugin).
|
2019-07-17 20:03:10 +00:00
|
|
|
|
settings(sharedSettings).
|
|
|
|
|
settings(testSettings).
|
|
|
|
|
settings(
|
|
|
|
|
name := "docspell-backend",
|
|
|
|
|
libraryDependencies ++=
|
|
|
|
|
Dependencies.loggingApi ++
|
2019-07-22 22:53:30 +00:00
|
|
|
|
Dependencies.fs2 ++
|
|
|
|
|
Dependencies.bcrypt ++
|
2020-01-04 23:12:23 +00:00
|
|
|
|
Dependencies.http4sClient ++
|
|
|
|
|
Dependencies.emil
|
2020-03-03 22:07:49 +00:00
|
|
|
|
).dependsOn(store, joexapi)
|
2019-07-17 20:03:10 +00:00
|
|
|
|
|
|
|
|
|
val webapp = project.in(file("modules/webapp")).
|
2020-02-08 16:58:40 +00:00
|
|
|
|
disablePlugins(RevolverPlugin).
|
2019-07-17 20:03:10 +00:00
|
|
|
|
enablePlugins(OpenApiSchema).
|
|
|
|
|
settings(sharedSettings).
|
|
|
|
|
settings(elmSettings).
|
|
|
|
|
settings(webjarSettings).
|
|
|
|
|
settings(
|
|
|
|
|
name := "docspell-webapp",
|
|
|
|
|
openapiTargetLanguage := Language.Elm,
|
|
|
|
|
openapiPackage := Pkg("Api.Model"),
|
|
|
|
|
openapiSpec := (restapi/Compile/resourceDirectory).value/"docspell-openapi.yml",
|
|
|
|
|
openapiElmConfig := ElmConfig().withJson(ElmJson.decodePipeline)
|
|
|
|
|
)
|
|
|
|
|
|
2020-05-06 20:04:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// --- Application(s)
|
|
|
|
|
|
|
|
|
|
val joex = project.in(file("modules/joex")).
|
|
|
|
|
enablePlugins(BuildInfoPlugin
|
|
|
|
|
, JavaServerAppPackaging
|
|
|
|
|
, DebianPlugin
|
|
|
|
|
, SystemdPlugin).
|
|
|
|
|
settings(sharedSettings).
|
|
|
|
|
settings(testSettings).
|
|
|
|
|
settings(debianSettings("docspell-joex")).
|
|
|
|
|
settings(buildInfoSettings).
|
|
|
|
|
settings(
|
|
|
|
|
name := "docspell-joex",
|
|
|
|
|
libraryDependencies ++=
|
|
|
|
|
Dependencies.fs2 ++
|
|
|
|
|
Dependencies.http4s ++
|
|
|
|
|
Dependencies.circe ++
|
|
|
|
|
Dependencies.pureconfig ++
|
|
|
|
|
Dependencies.emilTnef ++
|
|
|
|
|
Dependencies.emilMarkdown ++
|
|
|
|
|
Dependencies.emilJsoup ++
|
|
|
|
|
Dependencies.jsoup ++
|
|
|
|
|
Dependencies.yamusca ++
|
|
|
|
|
Dependencies.loggingApi ++
|
|
|
|
|
Dependencies.logging.map(_ % Runtime),
|
|
|
|
|
addCompilerPlugin(Dependencies.kindProjectorPlugin),
|
|
|
|
|
addCompilerPlugin(Dependencies.betterMonadicFor),
|
|
|
|
|
buildInfoPackage := "docspell.joex",
|
|
|
|
|
reStart/javaOptions ++= Seq(s"-Dconfig.file=${(LocalRootProject/baseDirectory).value/"local"/"dev.conf"}")
|
|
|
|
|
).dependsOn(store, backend, extract, convert, analysis, joexapi, restapi)
|
|
|
|
|
|
2019-07-17 20:03:10 +00:00
|
|
|
|
val restserver = project.in(file("modules/restserver")).
|
|
|
|
|
enablePlugins(BuildInfoPlugin
|
|
|
|
|
, JavaServerAppPackaging
|
|
|
|
|
, DebianPlugin
|
|
|
|
|
, SystemdPlugin).
|
|
|
|
|
settings(sharedSettings).
|
|
|
|
|
settings(testSettings).
|
2019-07-22 22:53:30 +00:00
|
|
|
|
settings(debianSettings("docspell-server")).
|
2019-07-17 20:03:10 +00:00
|
|
|
|
settings(buildInfoSettings).
|
|
|
|
|
settings(
|
|
|
|
|
name := "docspell-restserver",
|
|
|
|
|
libraryDependencies ++=
|
|
|
|
|
Dependencies.http4s ++
|
|
|
|
|
Dependencies.circe ++
|
|
|
|
|
Dependencies.pureconfig ++
|
|
|
|
|
Dependencies.yamusca ++
|
|
|
|
|
Dependencies.webjars ++
|
|
|
|
|
Dependencies.loggingApi ++
|
2019-07-22 22:53:30 +00:00
|
|
|
|
Dependencies.logging.map(_ % Runtime),
|
2019-07-17 20:03:10 +00:00
|
|
|
|
addCompilerPlugin(Dependencies.kindProjectorPlugin),
|
|
|
|
|
addCompilerPlugin(Dependencies.betterMonadicFor),
|
|
|
|
|
buildInfoPackage := "docspell.restserver",
|
2019-07-22 22:53:30 +00:00
|
|
|
|
Compile/sourceGenerators += Def.task {
|
2019-07-17 20:03:10 +00:00
|
|
|
|
createWebjarSource(Dependencies.webjars, (Compile/sourceManaged).value)
|
2019-07-22 22:53:30 +00:00
|
|
|
|
}.taskValue,
|
|
|
|
|
Compile/resourceGenerators += Def.task {
|
|
|
|
|
copyWebjarResources(Seq((restapi/Compile/resourceDirectory).value/"docspell-openapi.yml")
|
|
|
|
|
, (Compile/resourceManaged).value
|
|
|
|
|
, name.value
|
|
|
|
|
, version.value
|
|
|
|
|
, streams.value.log)
|
|
|
|
|
}.taskValue,
|
|
|
|
|
Compile/unmanagedResourceDirectories ++= Seq((Compile/resourceDirectory).value.getParentFile/"templates"),
|
2019-12-31 12:00:16 +00:00
|
|
|
|
reStart/javaOptions ++= Seq(s"-Dconfig.file=${(LocalRootProject/baseDirectory).value/"local"/"dev.conf"}")
|
2019-07-17 20:03:10 +00:00
|
|
|
|
).dependsOn(restapi, joexapi, backend, webapp)
|
|
|
|
|
|
2020-05-06 20:04:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// --- Microsite Documentation
|
|
|
|
|
|
2019-07-22 22:53:30 +00:00
|
|
|
|
val microsite = project.in(file("modules/microsite")).
|
2020-02-08 16:58:40 +00:00
|
|
|
|
disablePlugins(RevolverPlugin).
|
2019-07-22 22:53:30 +00:00
|
|
|
|
enablePlugins(MicrositesPlugin).
|
2019-12-29 22:37:32 +00:00
|
|
|
|
disablePlugins(ReleasePlugin).
|
2019-07-22 22:53:30 +00:00
|
|
|
|
settings(sharedSettings).
|
|
|
|
|
settings(
|
|
|
|
|
name := "docspell-microsite",
|
|
|
|
|
publishArtifact := false,
|
|
|
|
|
skip in publish := true,
|
|
|
|
|
micrositeFooterText := Some(
|
|
|
|
|
"""
|
2020-02-21 23:48:58 +00:00
|
|
|
|
|<p>© 2020 <a href="https://github.com/eikek/docspell">Docspell, v{{site.version}}</a></p>
|
2019-07-22 22:53:30 +00:00
|
|
|
|
|""".stripMargin
|
|
|
|
|
),
|
|
|
|
|
micrositeName := "Docspell",
|
2020-02-21 23:48:58 +00:00
|
|
|
|
micrositeDescription := "Auto-tagging Document Organizer",
|
2020-03-28 15:35:28 +00:00
|
|
|
|
micrositeDocumentationUrl := "doc",
|
|
|
|
|
micrositeDocumentationLabelDescription := "Documentation",
|
2019-12-29 22:37:32 +00:00
|
|
|
|
micrositeFavicons := Seq(microsites.MicrositeFavicon("favicon.png", "96x96")),
|
2019-07-22 22:53:30 +00:00
|
|
|
|
micrositeAuthor := "eikek",
|
|
|
|
|
micrositeGithubOwner := "eikek",
|
|
|
|
|
micrositeGithubRepo := "docspell",
|
|
|
|
|
micrositeGitterChannel := false,
|
|
|
|
|
micrositeShareOnSocial := false,
|
|
|
|
|
micrositeHighlightLanguages ++= Seq("json", "javascript"),
|
2019-12-29 22:37:32 +00:00
|
|
|
|
micrositeEditButton := Some(microsites.MicrositeEditButton("Improve this page", "/edit/master/modules/microsite/docs/{{ page.path }}")),
|
|
|
|
|
fork in run := true,
|
|
|
|
|
micrositeCompilingDocsTool := WithMdoc,
|
|
|
|
|
mdocVariables := Map(
|
2020-01-24 20:56:48 +00:00
|
|
|
|
"VERSION" -> version.value,
|
|
|
|
|
"PVERSION" -> version.value.replace('.', '_')
|
2019-12-29 22:37:32 +00:00
|
|
|
|
),
|
2020-02-27 22:58:43 +00:00
|
|
|
|
micrositeExtraMdFiles := Map(
|
|
|
|
|
file("Changelog.md") -> ExtraMdFileConfig(
|
|
|
|
|
"changelog.md",
|
|
|
|
|
"docs",
|
|
|
|
|
Map("title" -> "Changelog", "permalink" -> "changelog")
|
|
|
|
|
)
|
|
|
|
|
),
|
2019-12-29 22:37:32 +00:00
|
|
|
|
Compile/resourceGenerators += Def.task {
|
2020-06-14 19:35:20 +00:00
|
|
|
|
val jekyllOut = resourceManaged.value/"main"/"jekyll"
|
|
|
|
|
val logger = streams.value.log
|
|
|
|
|
|
|
|
|
|
val templates = Seq(
|
|
|
|
|
(resourceDirectory in (restserver, Compile)).value / "reference.conf" -> jekyllOut /"_includes"/"server.conf",
|
|
|
|
|
(resourceDirectory in (joex, Compile)).value / "reference.conf" -> jekyllOut/"_includes"/"joex.conf",
|
|
|
|
|
(LocalRootProject / baseDirectory).value / "tools" / "exim" / "exim.conf" -> jekyllOut/ "_includes"/"sample-exim.conf"
|
|
|
|
|
)
|
|
|
|
|
val res1 = templates.map { case (s, t) =>
|
|
|
|
|
logger.info(s"Copying $s -> $t")
|
|
|
|
|
IO.write(t, "{% raw %}\n")
|
|
|
|
|
IO.append(t, IO.readBytes(s))
|
|
|
|
|
IO.write(t, "\n{% endraw %}", append = true)
|
|
|
|
|
t
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val files = Seq(
|
|
|
|
|
(resourceDirectory in (restapi, Compile)).value/"docspell-openapi.yml" -> jekyllOut/"openapi"/"docspell-openapi.yml"
|
|
|
|
|
)
|
|
|
|
|
IO.copy(files)
|
|
|
|
|
res1 ++ files.map(_._2)
|
2019-07-22 22:53:30 +00:00
|
|
|
|
}.taskValue,
|
2019-12-29 22:37:32 +00:00
|
|
|
|
Compile/resourceGenerators += Def.task {
|
2019-07-22 22:53:30 +00:00
|
|
|
|
val staticDoc = (restapi/Compile/openapiStaticDoc).value
|
|
|
|
|
val target = resourceManaged.value/"main"/"jekyll"/"openapi"/"docspell-openapi.html"
|
|
|
|
|
IO.copy(Seq(staticDoc -> target))
|
|
|
|
|
Seq(target)
|
2019-12-29 22:37:32 +00:00
|
|
|
|
}.taskValue
|
2019-07-22 22:53:30 +00:00
|
|
|
|
)
|
|
|
|
|
|
2019-07-17 20:03:10 +00:00
|
|
|
|
val root = project.in(file(".")).
|
|
|
|
|
settings(sharedSettings).
|
2020-03-17 21:34:50 +00:00
|
|
|
|
settings(noPublish).
|
2019-07-17 20:03:10 +00:00
|
|
|
|
settings(
|
|
|
|
|
name := "docspell-root"
|
|
|
|
|
).
|
2019-07-22 22:53:30 +00:00
|
|
|
|
aggregate(common
|
2020-02-15 15:40:50 +00:00
|
|
|
|
, extract
|
2020-02-10 23:33:52 +00:00
|
|
|
|
, convert
|
2020-02-15 15:40:50 +00:00
|
|
|
|
, analysis
|
|
|
|
|
, files
|
2019-07-22 22:53:30 +00:00
|
|
|
|
, store
|
|
|
|
|
, joexapi
|
|
|
|
|
, joex
|
|
|
|
|
, backend
|
|
|
|
|
, webapp
|
|
|
|
|
, restapi
|
2019-12-29 22:37:32 +00:00
|
|
|
|
, restserver)
|
2019-07-22 22:53:30 +00:00
|
|
|
|
|
2019-07-17 20:03:10 +00:00
|
|
|
|
|
|
|
|
|
|
2020-05-06 20:04:51 +00:00
|
|
|
|
// --- Helpers
|
2019-07-22 22:53:30 +00:00
|
|
|
|
|
2019-07-17 20:03:10 +00:00
|
|
|
|
def copyWebjarResources(src: Seq[File], base: File, artifact: String, version: String, logger: Logger): Seq[File] = {
|
|
|
|
|
val targetDir = base/"META-INF"/"resources"/"webjars"/artifact/version
|
2019-07-22 22:53:30 +00:00
|
|
|
|
logger.info(s"Copy webjar resources from ${src.size} files/directories.")
|
2019-07-17 20:03:10 +00:00
|
|
|
|
src.flatMap { dir =>
|
|
|
|
|
if (dir.isDirectory) {
|
|
|
|
|
val files = (dir ** "*").filter(_.isFile).get pair Path.relativeTo(dir)
|
|
|
|
|
files.map { case (f, name) =>
|
|
|
|
|
val target = targetDir/name
|
|
|
|
|
IO.createDirectories(Seq(target.getParentFile))
|
|
|
|
|
IO.copy(Seq(f -> target))
|
|
|
|
|
target
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
val target = targetDir/dir.name
|
|
|
|
|
IO.createDirectories(Seq(target.getParentFile))
|
|
|
|
|
IO.copy(Seq(dir -> target))
|
|
|
|
|
Seq(target)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-29 19:52:43 +00:00
|
|
|
|
def compileElm(logger: Logger, wd: File, outBase: File, artifact: String, version: String, mode: ElmCompileMode): Seq[File] = {
|
2019-07-17 20:03:10 +00:00
|
|
|
|
logger.info("Compile elm files ...")
|
|
|
|
|
val target = outBase/"META-INF"/"resources"/"webjars"/artifact/version/"docspell-app.js"
|
2019-12-29 19:52:43 +00:00
|
|
|
|
val cmd = Seq("elm", "make") ++ mode.flags ++ Seq("--output", target.toString)
|
|
|
|
|
val proc = Process(cmd ++ Seq(wd/"src"/"main"/"elm"/"Main.elm").map(_.toString), Some(wd))
|
2019-07-17 20:03:10 +00:00
|
|
|
|
val out = proc.!!
|
|
|
|
|
logger.info(out)
|
|
|
|
|
Seq(target)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def createWebjarSource(wj: Seq[ModuleID], out: File): Seq[File] = {
|
|
|
|
|
val target = out/"Webjars.scala"
|
|
|
|
|
val fields = wj.map(m => s"""val ${m.name.toLowerCase.filter(_ != '-')} = "/${m.name}/${m.revision}" """).mkString("\n\n")
|
|
|
|
|
val content = s"""package docspell.restserver.webapp
|
|
|
|
|
|object Webjars {
|
|
|
|
|
|$fields
|
|
|
|
|
|}
|
|
|
|
|
|""".stripMargin
|
|
|
|
|
|
|
|
|
|
IO.write(target, content)
|
|
|
|
|
Seq(target)
|
|
|
|
|
}
|
2019-07-22 22:53:30 +00:00
|
|
|
|
|
2020-01-19 19:32:52 +00:00
|
|
|
|
def packageTools(logger: Logger, dir: File, version: String): Seq[File] = {
|
|
|
|
|
val target = dir/"target"
|
|
|
|
|
IO.delete(target)
|
|
|
|
|
IO.createDirectory(target)
|
|
|
|
|
val archive = target/s"docspell-tools-${version}.zip"
|
|
|
|
|
logger.info(s"Packaging tools to $archive ...")
|
|
|
|
|
val webext = target/"docspell-firefox-extension.xpi"
|
|
|
|
|
val wx = dir/"webextension"
|
|
|
|
|
IO.zip(Seq(
|
|
|
|
|
wx/"_locales/de/messages.json" -> "_locales/de/messages.json",
|
|
|
|
|
wx/"_locales/en/messages.json" -> "_locales/en/messages.json",
|
|
|
|
|
wx/"docspell.js" -> "docspell.js",
|
|
|
|
|
wx/"icons"/"logo-48.png" -> "icons/logo-48.png",
|
|
|
|
|
wx/"icons"/"logo-96.png" -> "icons/logo-96.png",
|
|
|
|
|
wx/"manifest.json" -> "manifest.json"
|
|
|
|
|
), webext)
|
|
|
|
|
|
|
|
|
|
IO.zip(Seq(
|
|
|
|
|
webext -> s"docspell-tools-${version}/firefox/docspell-extension.xpi",
|
|
|
|
|
wx/"native/app_manifest.json" ->s"docspell-tools-${version}/firefox/native/app_manifest.json",
|
|
|
|
|
wx/"native/native.py" ->s"docspell-tools-${version}/firefox/native/native.py",
|
|
|
|
|
dir/"ds.sh" -> s"docspell-tools-${version}/ds.sh",
|
|
|
|
|
dir/"consumedir.sh" -> s"docspell-tools-${version}/consumedir.sh"
|
|
|
|
|
), archive)
|
|
|
|
|
|
|
|
|
|
Seq(archive)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --- aliases
|
2019-07-22 22:53:30 +00:00
|
|
|
|
|
2019-12-31 12:00:16 +00:00
|
|
|
|
addCommandAlias("make", ";set webapp/elmCompileMode := ElmCompileMode.Production ;root/openapiCodegen ;root/test:compile")
|
2019-07-22 22:53:30 +00:00
|
|
|
|
addCommandAlias("make-zip", ";restserver/universal:packageBin ;joex/universal:packageBin")
|
|
|
|
|
addCommandAlias("make-deb", ";restserver/debian:packageBin ;joex/debian:packageBin")
|
2020-01-19 19:32:52 +00:00
|
|
|
|
addCommandAlias("make-tools", ";root/toolsPackage")
|
|
|
|
|
addCommandAlias("make-pkg", ";clean ;make ;make-zip ;make-deb ;make-tools")
|