Skip to content

mariogalic/play-scala-sbt-assembly-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

play-scala-sbt-assembly-example

This is a working example of how to deploy Play app using sbt-assembly instead of using sbt-native-packager. It is based on playframework/play-scala-starter-example and Play docs

Also, it attempts to answer Stack Overflow question Merge Strategy in sbt assembly and missing application loader

Deploying:

  1. Add sbt-assembly to project/plugins.sbt:
    addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.5")
    
  2. Exclude docs from package:
    sources in (Compile, doc) := Seq.empty
    publishArtifact in (Compile, packageDoc) := false
    
  3. Define assemblyMergeStrategy
    assemblyMergeStrategy in assembly := {
      case manifest if manifest.contains("MANIFEST.MF") =>
        // We don't need manifest files since sbt-assembly will create
        // one with the given settings
        MergeStrategy.discard
      case referenceOverrides if referenceOverrides.contains("reference-overrides.conf") =>
        // Keep the content for all reference-overrides.conf files
        MergeStrategy.concat
      case x =>
        // For all the other files, use the default sbt-assembly merge strategy
        val oldStrategy = (assemblyMergeStrategy in assembly).value
        oldStrategy(x)
    }
    
  4. Package with sbt assembly which should create a package in:
    /Users/mario/IdeaProjects/play-scala-sbt-assembly-example/target/scala-2.12/play-scala-sbt-assembly-example-assembly-1.0-SNAPSHOT.jar
    
  5. Run with
    java -Dplay.http.secret.key=ad31779d4ee49d5ad5162bf1429c32e2e9933f3 -jar /Users/mario/IdeaProjects/play-scala-sbt-assembly-example/target/scala-2.12/play-scala-sbt-assembly-example-assembly-1.0-SNAPSHOT.jar
    
  6. Test by hitting localhost:9000/

About

How to deploy Play app using sbt-assembly

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published