Making stand-alone jar with Simple Build Tool

前端 未结 5 863
日久生厌
日久生厌 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 19:59

    The simplest method is just to create the jar from the command line. If you don't know how to do this I would highly recommend that you do so. Automation is useful, but its much better if you know what the automation is doing.

    The easiest way to automate the creation of a runnable jar is to use a bash script or batch script in windows.

    The simplest way in sbt is just to add the Scala libraries you need to the resource directories:

    unmanagedResourceDirectories in Compile := Seq(file("/sdat/bins/ScalaCurrent/lib/scalaClasses"))
    

    So in my environment ScalaCurrent is a link to the current Scala library. 2.11.4 at the time of writing. The key point is that I extract the Scala library but place it inside a ScalaClassses directory. Each extracted library needs to go into its top level directory.

提交回复
热议问题