Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 851
dmcnelis Avatar asked Jan 06 '23 16:01

dmcnelis


2 Answers

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

like image 97
dmcnelis Avatar answered Jan 08 '23 05:01

dmcnelis


sbt native-packager 1.2.0 i s almost released (Nov. 2016) and Muki Seiler details this new feature coming form PR 785:

Systemloaders are AutoPlugins now

Previously, the Java Server Application Archetype provided a setting serverLoading where you could define your system loader like this:

import com.typesafe.sbt.packager.archetypes.ServerLoader

serverLoading in Rpm := ServerLoader.Upstart

This adds the necessary configuration files and maintainer scripts (postinst, postun, etc. ) in order to register and start your application.

The biggest problem with the tight coupling between the server archetype and the systemloaders is that it’s hard to add systemloader specific settings without changing a lot in the server archetype.
It’s also a lot harder to reason about the code and the output.

With extra systemloader plugins we open the possibility to

  • easily extend a single systemloader
  • have a place to put generic systemloader functionality ( there is a SystemLoaderPlugin which takes care of common settings )
  • test systemloaders in isolation
  • better developer experience

You enable a systemloader by enabling a concrete systemloader plugin

enablePlugins(SystemdPlugin)
like image 44
VonC Avatar answered Jan 08 '23 07:01

VonC