1) You should always use task output in sbt rather than raw filesystem lookups. Because sbt has parallel execution, if you don't put an explicit dependency on the output of a task, then you have no guarantee that a file will be created before you run your task.
In that vein you want to change your package mappings line to be something like this:
mappings in Universal += {
oneJar.value -> "/opt/projectname/projectname-0.1.jar"
},
Where the oneJar
key is defined in the onejar plugin.
2) Sbt just uses scala for the build language, so you can grab system properties similarly (but please also provide a default):
rpmRelease := Option(sys.props("rpm.buildNumber")) getOrElse "1"
3) Right now you're defining a generic package and redefining the same file in the Rpm with a different user. The mapGenericFilesToLinux
settings still lack a few customizations, but if you're not creating universal distributions, you should be able to drop that bit of settings and instead directly configure your linux package:
linuxPackageMappings in Rpm <+= (oneJar) map { jar:File =>
(packageMapping(jar -> "/opt/projectname/projectname-0.1.jar")
withUser "someusr" withGroup "somegroup" withPerms "0755")
},