Skip to content

Commit

Permalink
Updating assembly-one-jar
Browse files Browse the repository at this point in the history
  • Loading branch information
muuki88 committed Nov 8, 2015
1 parent 9144fc2 commit 08e88fc
Show file tree
Hide file tree
Showing 21 changed files with 78 additions and 128 deletions.
27 changes: 0 additions & 27 deletions akka-server-app/build.sbt

This file was deleted.

4 changes: 0 additions & 4 deletions akka-server-app/project/plugins.sbt

This file was deleted.

3 changes: 3 additions & 0 deletions application-conf/README.md
@@ -0,0 +1,3 @@
## Application Conf

Demonstrates how to use custom mappings.
12 changes: 11 additions & 1 deletion application-conf/build.sbt
Expand Up @@ -5,7 +5,8 @@ name := "mukis-application-conf"
version := "1.0"

libraryDependencies ++= Seq(
"com.typesafe" % "config" % "1.2.1"
"com.typesafe" % "config" % "1.2.1",
"org.scalatest" %% "scalatest" % "2.2.4" % "test"
)

mainClass in Compile := Some("de.mukis.ConfigApp")
Expand All @@ -20,3 +21,12 @@ mappings in Universal += {
val conf = (resourceDirectory in Compile).value / "reference.conf"
conf -> "conf/application.conf"
}

// for publish task
// import com.typesafe.sbt.packager.SettingsHelper
// SettingsHelper.addPackage(Debian, packageBin in Test, "jar")

mappings in Universal += {
var testjar = (packageBin in Test).value
testjar -> s"lib/${testjar.getName}"
}
2 changes: 1 addition & 1 deletion application-conf/project/plugins.sbt
@@ -1,4 +1,4 @@
// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

addSbtPlugin("com.typesafe.sbt" %% "sbt-native-packager" % "1.0.1")
addSbtPlugin("com.typesafe.sbt" %% "sbt-native-packager" % "1.0.4")
22 changes: 22 additions & 0 deletions application-conf/src/test/scala/ExampleSpec.scala
@@ -0,0 +1,22 @@
package com.example

import collection.mutable.Stack
import org.scalatest._

class ExampleSpec extends FlatSpec with Matchers {

"A Stack" should "pop values in last-in-first-out order" in {
val stack = new Stack[Int]
stack.push(1)
stack.push(2)
stack.pop() should be (2)
stack.pop() should be (1)
}

it should "throw NoSuchElementException if an empty stack is popped" in {
val emptyStack = new Stack[Int]
a [NoSuchElementException] should be thrownBy {
emptyStack.pop()
}
}
}
38 changes: 3 additions & 35 deletions assembly-one-jar/README.md
Expand Up @@ -5,49 +5,17 @@ This example demonstrates how to assembly a single jar.
## plugin.sbt

```scala
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.0")
```

## build.sbt

```scala
import NativePackagerKeys._
import AssemblyKeys._

name := "assemblyProject"

version := "1.0"

// add some dependencies
libraryDependencies ++= Seq(
"com.typesafe" % "config" % "1.2.0",
"com.google.guava" % "guava" % "18.0"
)

mainClass in Compile := Some("de.mukis.ConfigApp")

// the assembly settings
assemblySettings
Important settings

```scala
// we specify the name for our fat jar
jarName in assembly := "assembly-project.jar"

// using the java server for this application
packageArchetype.java_server

maintainer in Linux := "Nepomuk Seiler <nepomuk.seiler@mukis.de>"

packageSummary in Linux := "Custom application configuration"

packageDescription := "Custom application configuration"

mappings in Universal <+= (packageBin in Compile, sourceDirectory ) map { (_, src) =>
// we are using the reference.conf as default application.conf
// the user can override settings here
val conf = src / "main" / "resources" / "reference.conf"
conf -> "conf/application.conf"
}

// removes all jar mappings in universal and appends the fat jar
mappings in Universal <<= (mappings in Universal, assembly in Compile) map { (mappings, fatJar) =>
val filtered = mappings filter { case (file, name) => ! name.endsWith(".jar") }
Expand Down
14 changes: 1 addition & 13 deletions assembly-one-jar/build.sbt
@@ -1,8 +1,4 @@
import NativePackagerKeys._
import AssemblyKeys._

name := "assemblyProject"

version := "1.0"

// add some dependencies
Expand All @@ -11,21 +7,13 @@ libraryDependencies ++= Seq(
"com.google.guava" % "guava" % "18.0"
)

mainClass in Compile := Some("de.mukis.ConfigApp")

// the assembly settings
assemblySettings
enablePlugins(JavaAppPackaging)

// we specify the name for our fat jar
jarName in assembly := "assembly-project.jar"

// using the java server for this application
packageArchetype.java_server

maintainer in Linux := "Nepomuk Seiler <nepomuk.seiler@mukis.de>"

packageSummary in Linux := "Custom application configuration"

packageDescription := "Custom application configuration"

// removes all jar mappings in universal and appends the fat jar
Expand Down
2 changes: 1 addition & 1 deletion assembly-one-jar/project/build.properties
@@ -1 +1 @@
sbt.version=0.13.5
sbt.version=0.13.8
4 changes: 2 additions & 2 deletions assembly-one-jar/project/plugins.sbt
@@ -1,6 +1,6 @@
// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

addSbtPlugin("com.typesafe.sbt" %% "sbt-native-packager" % "0.8.0-M1")
addSbtPlugin("com.typesafe.sbt" %% "sbt-native-packager" % "1.0.4")

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.0")
29 changes: 3 additions & 26 deletions assembly-one-jar/src/main/scala/de/mukis/ConfigApp.scala
@@ -1,28 +1,5 @@
package de.mukis

import com.typesafe.config.ConfigFactory
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit
import java.nio.file.Files
import java.nio.charset.Charset

object ConfigApp extends App {

val logFile = Files.createTempFile("mukis-", ".log")

// Creating an executor service to schedule the config parsing
val service = Executors newScheduledThreadPool 1
service.scheduleAtFixedRate(new Runnable() {
override def run() {
// Loading config
ConfigFactory.invalidateCaches
val config = ConfigFactory load () getConfig ("mukis")

// Writing the config content to the logfile
val log = Files.newBufferedWriter(logFile, Charset forName "UTF-8")
log write (s"User:\t${config.root render ()}")
log.newLine
log.close
}
}, 0, 5, TimeUnit.SECONDS)
}
object HelloWorldApp extends App {
println("Hello, World!")
}
18 changes: 0 additions & 18 deletions assembly-one-jar/src/templates/etc-default

This file was deleted.

File renamed without changes.
20 changes: 20 additions & 0 deletions sbt-web-example/build.sbt
@@ -0,0 +1,20 @@
enablePlugins(
JavaServerAppPackaging,
SbtWeb
)

name := "mukis-akka-server-app"
version := "1.0"

val akkaVersion = "2.3.9"

libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % akkaVersion
)

mainClass in Compile := Some("de.mukis.AkkaServerApp")

maintainer := "Nepomuk Seiler <nepomuk.seiler@mukis.de>"
packageSummary := "Custom application configuration"
packageDescription := "Custom application configuration"

File renamed without changes.
11 changes: 11 additions & 0 deletions sbt-web-example/project/plugins.sbt
@@ -0,0 +1,11 @@
// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
resolvers += Resolver.url("GitHub repository", url("http://shaggyyeti.github.io/releases"))(Resolver.ivyStylePatterns)

// SBT web
addSbtPlugin("com.typesafe.sbt" % "sbt-web" % "1.2.1")
addSbtPlugin("default" % "sbt-sass" % "0.1.9")

addSbtPlugin("com.typesafe.sbt" %% "sbt-native-packager" % "1.0.2")


File renamed without changes.

0 comments on commit 08e88fc

Please sign in to comment.