Search code examples
playframeworkplayframework-2.0sbtsbt-native-packager

sbt-native-packager plugin errors out rpm build of Play project


I am trying to package a Play Framework application using an RPM file and I do not know where to put the configuration that is required in the Play Framework project.

I have added the plugin to my project/plugins.sbt file

// Comment to get more information during initialization
logLevel := Level.Warn

// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

resolvers += "tomax repository" at "http://maven.tmx.com/nexus"

// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.1")

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

I get an error in Play when I run the following command:

rpm:package-bin

I then run the last command for the error as suggested and I get

Creating SPEC file: /projects/myproj/target/rpm/SPECS/MyProj.spec
[debug] Executing rpmbuild with: rpmbuild -bb --buildroot /projects/myproj/target/rpm/buildroot --define _topdir /projects/myproj/target/rpm --target noarch--Linux MyProj.spec
[error] error: line 4: Empty tag: Summary:
[info] Building target platforms: noarch--Linux
[info] Building for target noarch--Linux
java.lang.RuntimeException: Unable to run rpmbuild, check output for details

Solution

  • One way to make the sbt-native-packager work with play is to add the following to your settings in Build.scala

    val storeOpsServer = play.Project(
        "storeops-server", appVersion, appDependencies, path = file("storeops-server")
      ).settings(
        //Packaging for RPMs
        name in Rpm := "my-server",
        version in Rpm := appVersion,
        rpmRelease := "0",
        packageSummary := "Some summary of your software",
        rpmVendor := "My Corporation",
        rpmUrl := Some("http://www.mycorp.com"),
        rpmLicense := Some("MIT"),
        packageDescription := "Some description of what your server does",
        rpmGroup := Some("Group")
      ).dependsOn(adapterApi)
    

    You don't need all of the values above but these are the ones that I used and was successful with.

    Here are the imports that were in the file

    import com.typesafe.sbt.packager.linux.{LinuxPackageMapping, LinuxSymlink}
    import com.typesafe.sbt.packager.rpm.RpmDependencies
    import com.typesafe.sbteclipse.core._
    import sbt._
    import Keys._
    import play.Project._
    
    import com.typesafe.sbt.packager.Keys._
    import com.typesafe.sbt.SbtNativePackager._