gpt4 book ai didi

sbt - 如何使用 sbt-native-packager 定义多项目构建,为每个子项目创建一个 RPM

转载 作者:行者123 更新时间:2023-12-01 12:29:04 25 4
gpt4 key购买 nike

在我看到的关于多模块构建和 sbt-native-packager 的所有示例中,它们都将子项目聚合到一个包中。我有每个子项目都提供微服务。我相信它们中的每一个都应该有自己的本地包,但我不知道如何做到这一点,也不知道如何为所有子项目构建一个命令。

最佳答案

事实证明这很简单。只需为您要打包的每个子项目提供 native-packager 设置,不要在聚合项目上提供任何设置。

我通过修改 https://github.com/muuki88/sbt-native-packager-examples/tree/master/multi-module-build 进行测试因此:

import NativePackagerKeys._

name := "mukis-fullstack"

// used like the groupId in maven
organization in ThisBuild := "de.mukis"

// all sub projects have the same version
version in ThisBuild := "1.0"

scalaVersion in ThisBuild := "2.11.2"

// common dependencies
libraryDependencies in ThisBuild ++= Seq(
"com.typesafe" % "config" % "1.2.0"
)

// this is the root project, aggregating all sub projects
lazy val root = Project(
id = "root",
base = file("."),
// configure your native packaging settings here
// settings = packageArchetype.java_server++ Seq(
// maintainer := "John Smith <john.smith@example.com>",
// packageDescription := "Fullstack Application",
// packageSummary := "Fullstack Application",
// entrypoint
// mainClass in Compile := Some("de.mukis.frontend.ProductionServer")
// ),
// always run all commands on each sub project
aggregate = Seq(frontend, backend, api)
) dependsOn(frontend, backend, api) // this does the actual aggregation

// --------- Project Frontend ------------------
lazy val frontend = Project(
id = "frontend",
base = file("frontend"),
settings = packageArchetype.java_server++ Seq(
maintainer := "John Smith <john.smith@example.com>",
packageDescription := "Frontend appplication",
mainClass in Compile := Some("de.mukis.frontend.ProductionServer")
)
) dependsOn(api)


// --------- Project Backend ----------------
lazy val backend = Project(
id = "backend",
base = file("backend"),
settings = packageArchetype.java_server++ Seq(
maintainer := "John Smith <john.smith@example.com>",
packageDescription := "Fullstack Application",
packageSummary := "Fullstack Application",
// entrypoint
mainClass in Compile := Some("de.mukis.frontend.ProductionServer")
)
) dependsOn(api)

// --------- Project API ------------------
lazy val api = Project(
id = "api",
base = file("api")

结果:

debian:packageBin
...misc messages elided...
[info] dpkg-deb: building package `frontend' in `../frontend_1.0_all.deb'.
[info] dpkg-deb: building package `backend' in `../backend_1.0_all.deb'.

关于sbt - 如何使用 sbt-native-packager 定义多项目构建,为每个子项目创建一个 RPM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36283603/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com