-
Notifications
You must be signed in to change notification settings - Fork 443
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…sal and Linux
- Loading branch information
Showing
4 changed files
with
380 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -195,3 +195,107 @@ You can use ``${{variable_name}}`` to reference variables when writing your scir | |
|
||
Creating a file here will override the ``/etc/default/<application>`` template | ||
used when SystemV is the server loader. | ||
|
||
|
||
SBT Assembly | ||
------------ | ||
|
||
This isn't currently an archetype itself, but you can configure it yourself very easily. | ||
First add the sbt-assembly plugin to your `plugins.sbt` file. | ||
|
||
.. code-block:: scala | ||
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2") | ||
The next step is to remove all the jar mappings from the normal mappings and only add the | ||
assembly jar. In this example we'll set the assembly jar name ourself, so we know exactly | ||
what the output should look like. Finally we change the ``scriptClasspath`` so it only | ||
contains the assembled jar. This is what the final ``build.sbt`` should contain: | ||
|
||
.. code-block:: scala | ||
// the assembly settings | ||
assemblySettings | ||
// we specify the name for our fat jar | ||
jarName in assembly := "assembly-project.jar" | ||
// using the java server for this application. java_application is fine, too | ||
packageArchetype.java_server | ||
// removes all jar mappings in universal and appends the fat jar | ||
mappings in Universal := { | ||
// universalMappings: Seq[(File,String)] | ||
val universalMappings = (mappings in Universal).value | ||
val fatJar = (assembly in Compile).value | ||
// removing means filtering | ||
val filtered = universalMappings filter { | ||
case (file, name) => ! name.endsWith(".jar") | ||
} | ||
// add the fat jar | ||
filtered :+ (fatJar -> ("lib/" + fatJar.getName)) | ||
} | ||
// the bash scripts classpath only needs the fat jar | ||
scriptClasspath := Seq( (jarName in assembly).value ) | ||
Multi Module Builds | ||
------------------- | ||
|
||
If you want to aggregate different projects in a multi module build to a single package, | ||
you can specify everthing in a single ``build.sbt`` | ||
|
||
.. code-block:: scala | ||
import NativePackagerKeys._ | ||
name := "mukis-fullstack" | ||
// used like the groupId in maven | ||
organization in ThisBuild := "de.mukis" | ||
// all sub projects have the same version | ||
version in ThisBuild := "1.0" | ||
scalaVersion in ThisBuild := "2.11.2" | ||
// common dependencies | ||
libraryDependencies in ThisBuild ++= Seq( | ||
"com.typesafe" % "config" % "1.2.0" | ||
) | ||
// this is the root project, aggregating all sub projects | ||
lazy val root = Project( | ||
id = "root", | ||
base = file("."), | ||
// configure your native packaging settings here | ||
settings = packageArchetype.java_server++ Seq( | ||
maintainer := "John Smith <[email protected]>", | ||
packageDescription := "Fullstack Application", | ||
packageSummary := "Fullstack Application", | ||
// entrypoint | ||
mainClass in Compile := Some("de.mukis.frontend.ProductionServer") | ||
), | ||
// always run all commands on each sub project | ||
aggregate = Seq(frontend, backend, api) | ||
) dependsOn(frontend, backend, api) // this does the actual aggregation | ||
// --------- Project Frontend ------------------ | ||
lazy val frontend = Project( | ||
id = "frontend", | ||
base = file("frontend") | ||
) dependsOn(api) | ||
// --------- Project Backend ---------------- | ||
lazy val backend = Project( | ||
id = "backend", | ||
base = file("backend") | ||
) dependsOn(api) | ||
// --------- Project API ------------------ | ||
lazy val api = Project( | ||
id = "api", | ||
base = file("api") | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.