Making stand-alone jar with Simple Build Tool

前端 未结 5 845
日久生厌
日久生厌 2020-12-07 19:21

Is there a way to tell sbt to package all needed libraries (scala-library.jar) into the main package, so it is stand-alone? (static?)

5条回答
  •  太阳男子
    2020-12-07 20:07

    The simplest example using sbt-assembly

    1. Create directory project in your home project dir with file assembly.sbt including

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

    2. In file build.sbt

      import AssemblyKeys._ // put this at the top of the file

      assemblySettings

      jarName += "Mmyjarnameall.jar"

      libraryDependencies ++= Seq( "exmpleofmydependency % "mydep" % "0.1" )

      mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) =>

      {

      case s if s.endsWith(".class") => MergeStrategy.last

      case s if s.endsWith("pom.xml") => MergeStrategy.last

      case s if s.endsWith("pom.properties") => MergeStrategy.last

      case x => old(x)

      }

      }

提交回复
热议问题