sbt-assembly icon indicating copy to clipboard operation
sbt-assembly copied to clipboard

Creating a Jar with conf files not working

Open joesan opened this issue 7 years ago • 1 comments

I have been trying to create a Jar file with application.conf files inside the jar. But unfortunately, seems the .conf files are not being included in the final jar. Here is my BuildSettings.scala file:


object BuildSettings {

  lazy val basicSettings = Seq[Setting[_]](
    organization  := "com.my.project",
    version       := "0.1.0-SNAPAHOT",
    description   := "sample preparation",
    scalaVersion  := "2.11.7",
    scalacOptions := Seq("-deprecation", "-encoding", "utf8"),
    resolvers     ++= Dependencies.resolutionRepos
  )

  // sbt-assembly settings for building one fat jar
  import sbtassembly.Plugin._
  import AssemblyKeys._
  lazy val sbtAssemblySettings = assemblySettings ++ Seq(

    jarName in assembly := {
      name.value + "-" + version.value + ".jar"
    },

    // META-INF discarding
    mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) =>
       {
         case "application.conf" => MergeStrategy.concat
         case PathList("META-INF", xs @ _*) => MergeStrategy.discard
         case x => MergeStrategy.first
       }
    }
  )

  lazy val buildSettings = basicSettings ++ sbtAssemblySettings
}

What should I do to include the conf folder? Here is my project structure:

MyProject -src

  • main
    • mypackages and source files
    • conf // contains application.conf, application.test.conf and so on
  • test -project // contains all the build related files
  • README.md

joesan avatar May 15 '17 18:05 joesan

Try place them under src/main/resources

manuzhang avatar Jul 25 '17 12:07 manuzhang