dmcnelis dmcnelis - 25 days ago 10
Scala Question

Sbt native packager not finding SystemdPlugin

I'm trying to get an rpm built that uses the Systemd archetype. However, I'm getting errors on my import in build.sbt. I am using sbt version 0.13.11 Specifically, I am seeing:

build.sbt:3: error: object systemloader is not a member of package com.typesafe.sbt.packager.archetypes


I'm trying to use version 1.1.4 of sbt-native-packager. Here is my plugins.sbt:

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

// The Sonatype snapshots repository
resolvers += "Sonatype snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"

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


My build.sbt:

import com.typesafe.sbt.packager.linux.LinuxSymlink
import com.typesafe.sbt.packager.rpm.RpmPlugin.autoImport._
import com.typesafe.sbt.packager.archetypes.systemloader._

scalaVersion := "2.11.7"

name := "systemdtest"

organization := "myTestOrg"

enablePlugins(JavaServerAppPackaging, RpmPlugin, SystemdPlugin)

version := "1.0"

// RPM SETTINGS
rpmVendor := "me"

packageSummary in Linux := "A summary"

packageDescription := "Do some stuff"

rpmRelease := "1"

rpmBrpJavaRepackJars := false

rpmLicense := Some("Copyright this project")

rpmGroup := Some("mygroup")

rpmPrefix := Some("/opt/mypath")


I am getting the error when I try to run

sbt stage


or

sbt rpm:packageBin

Answer

The documentation for 1.1 on the native packager site (http://www.scala-sbt.org/sbt-native-packager/archetypes/systemloaders.html) says to use an auto-plugin called SystemdPlugin.

However, this does not exist in the 1.1 branch, and was introduced in the 1.2 branch that is (at time of this post, is 1.2.0M3), and not yet GA.

The correct convention is to add an assignment in your build.sbt called "serverLoading."

In my case, to use with an RPM, I needed to change my build.sbt to the following:

import com.typesafe.sbt.packager.rpm.RpmPlugin.autoImport._
import com.typesafe.sbt.packager.archetypes.ServerLoader

scalaVersion := "2.11.7"

name := "systemdtest"

organization := "myTestOrg"

enablePlugins(JavaServerAppPackaging)

version := "1.0"

// RPM SETTINGS
rpmVendor := "me"

packageSummary in Linux := "A summary"

packageDescription := "Do some stuff"

rpmRelease := "1"

rpmBrpJavaRepackJars := false

rpmLicense := Some("Copyright this project")

rpmGroup := Some("mygroup")

rpmPrefix := Some("/opt/mypath")

//THIS IS THE KEY PIECE!!
serverLoading in Rpm := ServerLoader.Systemd

I found my solution reading through the comments on this issue. https://github.com/sbt/sbt-native-packager/pull/785