DevOps(3)Build RPM and DEB

本文详细介绍了如何利用Maven和SBT插件构建RPMS和DEBs包,包括配置和实践步骤,适用于Ubuntu系统。同时讨论了如何在SbtTool中构建通用包,并通过配置来实现不同构建目标。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值