作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在将几个大型 scala 项目合并为一个。目前他们使用剪切和粘贴(不是很多代码)共享代码,我正在制作它以便有一个通用的实用程序 jar。这些项目大部分部署在亚马逊云上,使用 sbt-native-packager 打包
我的问题是我不知道如何为 sbt native manager 配置多个项目。我也不是很熟悉它,在完成所有初始工作后才进入该项目。
我已将问题减少到我能解决的最小问题。在 https://github.com/stave-escura/multiprojectissue.git 有一个 git repo这说明了问题
在 project/plugins.sbt 中,重要的几行是
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.6")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.0")
import com.typesafe.sbt.SbtNativePackager
import com.typesafe.sbt.packager.archetypes.JavaServerAppPackaging
enablePlugins(SbtNativePackager)
enablePlugins(JavaServerAppPackaging)
lazy val commonSettings = Seq(
...
scalaVersion := "2.11.8",
assemblyJarName in assembly := s"${name.value}.jar",
assemblyMergeStrategy in assembly := {
case "BUILD" => MergeStrategy.discard
case other => MergeStrategy.defaultMergeStrategy(other)
}
)
lazy val project1Settings = commonSettings ++ Seq(
rpmVendor := "someOrganisation",
packageDescription in Rpm := "Some description1",
rpmLicense := Some("Copyright 2016 someOrganisation. All rights reserved."),
rpmRequirements := Seq(
"java-1.8.0-openjdk"
),
version in Rpm := "1",
rpmRelease := version.value,
rpmDaemonLogFile := s"${name.value}.log",
daemonUser in Linux := "someUserName",
daemonGroup in Linux := (daemonUser in Linux).value,
rpmPost := Some(
"""|chkconfig --add someService1
|chkconfig someService1 on
""".stripMargin),
linuxPackageMappings ++= Seq() // <--- line 53
)
lazy val project2Settings = commonSettings ++ Seq(
identical to project 1 settings except
packageDescription in Rpm := "Some description2",
rpmPost := Some(
"""|chkconfig --add someService2
|chkconfig someService2 on
""".stripMargin),
linuxPackageMappings ++= Seq() // <--- line 72
)
lazy val project1 = (project in file("components/service1")).settings(project1Settings: _*)
lazy val project2 = (project in file("components/service2")).settings(project2Settings: _*)
References to undefined settings:
project2/*:linuxPackageMappings from project2/*:linuxPackageMappings (~/git/multiprojectissue/build.sbt:72)
project1/*:linuxPackageMappings from project1/*:linuxPackageMappings (~/git/multiprojectissue/build.sbt:53)
at sbt.Init$class.Uninitialized(Settings.scala:265)
...
at xsbt.boot.Boot.main(Boot.scala)
[error] References to undefined settings:
[error]
[error] project2/*:linuxPackageMappings from project2/*:linuxPackageMappings (/Users/ricep02/git/multiprojectissue/build.sbt:72)
[error]
[error] project1/*:linuxPackageMappings from project1/*:linuxPackageMappings (/Users/ricep02/git/multiprojectissue/build.sbt:53)
最佳答案
它看起来像 SbtNativePackager
需要为 project1
启用和 project2
在他们的设置中。
尝试通过添加 enablePlugins(SbtNativePackager)
来修改您的设置:
lazy val project1Settings = commonSettings ++ Seq(
rpmVendor := "someOrganisation",
packageDescription in Rpm := "Some description1",
rpmLicense := Some("Copyright 2016 someOrganisation. All rights reserved."),
rpmRequirements := Seq(
"java-1.8.0-openjdk"
),
version in Rpm := "1",
rpmRelease := version.value,
rpmDaemonLogFile := s"${name.value}.log",
daemonUser in Linux := "someUserName",
daemonGroup in Linux := (daemonUser in Linux).value,
rpmPost := Some(
"""|chkconfig --add someService1
|chkconfig someService1 on
""".stripMargin),
enablePlugins(SbtNativePackager),
linuxPackageMappings ++= Seq() // <--- line 53
)
关于scala - 如何在多个项目中使用 sbt-native-packager,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37916987/
我是一名优秀的程序员,十分优秀!