Skip to content

hackmann/sbt-native-packager

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SBT Native Packager

This is a work in process project. The goal is to be able to bundle up Scala software built with SBT for native packaging systems, like deb, rpm, homebrew, msi.

Issues/Discussions

  • Discussion/Questions: If you wish to ask questions about the native packager, we're very active on Stack Overflow. You can either use the sbt tag or the sbt-native-packager tag. They also have far better search support for working around issues.
  • Docs: Our docs are available online. If you'd like to help improve the docs, they're part of this repository in the src/sphinx directory.
  • Issues/Feature Requests: Finally, any bugs or features you find you need, please report to our issue tracker.

Installation

Add the following to your project/plugins.sbt file:

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

Then, in the project you wish to use the plugin, You need to select what kind of project you are packaging:

Java Application

If you are packaging a Java Application, this implies that you have one main method defined in the project. The native packager will generate two scrips to run your application (one for 'nix [bash] and one for windows [bat]). The generic layout of your application will be:

 <installation-dir>
    bin/
       <app>             <- bash script
       <app>.bat         <- windows script
    lib/
       *.jar             <- binaries

When mapping to debian or RPM, the packager will create symlinks in /usr/bin to the installation directory of your program. If you include a conf/ directory with configuration, this will show up as a symlink under /etc/<app>/. On windows, the directory structure remains unchanged, however the MSI will include a hook to automatically add the bin/ directory to the windows PATH.

Here's what to add to your build.sbt:

packageArchetype.java_application

If you'd like to add additional files to the installation dir, simply add them to the universal mappings:

import com.typesafe.sbt.SbtNativePackager.Universal

mappings in Universal += {
  file("my/local/conffile") -> "conf/my.conf"
}

The above adds a configuration file from the local project at my/local/conffile into the installation directory at conf/my.conf.

Java Server Application (Experimental)

If you are packaging a server, the configuration will be similar to a vanilla Java Application, except that the native packager will include service hooks inside the MSI, DEB and RPM. For DEB, these hooks will use upstart. For RPM, they will use init.d and for MSIs, there will be windows service hooks.

Right now there is no active release with complete Java Server hooks. You should be able to start experimenting with Java server hooks using debian packaging and the upstart system.

Here's what to add to your build.sbt:

packageArchetype.java_server

By-hand packaging

If you'd like to wire all of your packages by hand, use the minmal set of configuration provided. In your build.sbt enter the following:

packagerSettings

or to a Project instantiation in build.sbt/project/Build.scala:

settings(com.typesafe.sbt.SbtNativePackager.packagerSettings:_*)

If you use this configuration, you must fill out the mappings in Universal, mappings in Windows, linuxPackageMappings and wixXml settings yourself.

Usage

Once you've configured your packaging how you like it, you can run the following commands:

  • stage - Creates the universal distribution under the target/universal/stage directory
  • universal:packageZipTarball - Create the universal .tgz distribution.
  • universal:packageXzTarball - Creates the universal txz distribution. Note: xz sucks cpu like no other.
  • universal:packageBin - Creates the universal zip distribution
  • windows:packageBin - Creates the windows msi file.
  • debian:packageBin - Creates the debian deb file.
  • rpm:packageBin - Creates the redhast rpm file.

Publishing to bintray

Bintray has support for publishing RPM + DEB files into shared repositories. We can do this from sbt using the sbt-native-packager. TODO - outline details once we have them fleshed out.

A more complex project, which bundles the sbt project, can be found here.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Scala 92.8%
  • Python 7.2%