DevOps(3)Build RPM and DEB
We are using maven plugin and sbt plugin to build rpm packages. I will check that and think about how to build deb because that we are thinking about change to ubuntu system.
I only try build universal package from sbt tool, all the examples are in sillycat-graph project.
Add plugins in plugins.sbt
addSbtPlugin("io.spray" % "sbt-revolver" % "0.7.2")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2")
addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.3.0")
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.2.0")
resolvers += "Sonatype snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.7.0-SNAPSHOT")
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.8.0-M1")
Using Packaging.scala to Place all the native-package configuration
import sbt._
import Keys._
import com.typesafe.sbt.packager.Keys._
import com.typesafe.sbt.SbtNativePackager._
object Packaging {
def app = packageArchetype.java_application
def server = packageArchetype.java_server
def settings: Seq[Setting[_]] =
packagerSettings ++
deploymentSettings ++
Seq(
publishArtifact in (Compile, packageBin) := false,
publishArtifact in (Universal, packageBin) := true
)
}
Change the Build.scala to using the native plugin
lazy val main = Project(
BuildSettings.projectName,
file("."),
settings = BuildSettings.buildSettings ++ assemblySettings
++
Seq(resolvers := myResolvers,
libraryDependencies ++= baseDeps,
mergeStrategy in assembly := mergeFirst
)
++
Packaging.settings
++
Packaging.server
) settings(
mainClass in assembly := Some("com.sillycat.graph.app.ExecutorApp"),
excludedJars in assembly <<= (fullClasspath in assembly) map { cp =>
cp filter {_.data.getName == "compile-0.1.0.jar"}
},
artifact in (Compile, assembly) ~= { art =>
art.copy(`classifier` = Some("assembly"))
},
mappings in Universal <++= sourceDirectory map { src =>
val resources = src / "main" / "resources"
val log4j = resources / "log4j.properties"
val reference = resources / "application.conf"
Seq(log4j -> "conf/log4j.properties", reference -> "conf/application.conf")
}
)
Command to generate the universal package
>sbt clean update compile universal:packageBin
References:
http://mojo.codehaus.org/unix/
https://github.com/sbt/sbt-native-packager
http://www.scala-sbt.org/sbt-native-packager/
example
https://github.com/muuki88/sbt-native-package-server#master
DevOps(3)Build RPM and DEB
最新推荐文章于 2025-08-11 12:14:53 发布